VMware Cloud Community
tsinfra
Contributor
Contributor

ScheduledTaskManage script and alarmspec.setEnabled(true) to create a schedule task that enables/disables an alarm

Hey there,

is there any way to combine ScheduledTaskManage script and alarmspec.setEnabled(true) to create a schedule task that enables/disables an alarm for a give period?

I've been lloking at http://www.vmware.com/support/developer/vc-sdk/visdk25pubs/visdk25programmingguide.pdf and other doco's, but no joy so far.

Thanks a mill!

Shane.

0 Kudos
3 Replies
tsinfra
Contributor
Contributor

Folks,

just thought of an alternative way of approaching this.

How bout in the event an alarm is trigger the action is to run a script. Within the script it checks to see if the currrent time is between days/time, if so email user.

Sounds easy, but the header and body would need to contain the vm identified by the alarm.

Hmm, getting completely lost!!!

Shane.

0 Kudos
tsinfra
Contributor
Contributor

Hi again,

sorry for appearing to answer my own question, however as I dig deeper & getting closer to resolution, I might as well share the outcome with everyone.

I found a reference to passing parameters to the script here:

http://communities.vmware.com/thread/198656

So it's getting there!

Shane.

0 Kudos
tsinfra
Contributor
Contributor

Done!

Alarm action set to run script:

c:\windows\system32\cscript.exe D:\Apps\Alarm_Scripts\send_email.vbs

Script details:

OPTION EXPLICIT
* If Hour(Now()) >= 8 And Hour(Now()) < 18 and WeekDayName(WeekDay(DateValue(Now()))) = vbMonday or vbTuesday or vbWednesday or vbThursday or vbFriday Then*
* Dim sPageText, sSubject*
* sSubject = "Warning: " & WScript.Arguments.Item(0) & " triggered " & WScript.Arguments.Item(1)*
* sPagetext = NOW() & " CPU usage on " & WScript.Arguments.Item(0) & WScript.Arguments.Item(2)*
* 'Send Email*
* SendEmail sSubject, sPageText*
* Function SendEmail (sSubjectText,sBodyText)*
* Dim oEmail*
* Set oEmail = CreateObject("CDO.Message")*
* oEmail.From = "ESX_Alerts@___________.com.au"*
* oEmail.To = "________@____________.com.au"*
* oEmail.Subject = sSubjectText*
* oEmail.Textbody = sBodyText*
* oEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2*
* oEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "_______________"*
* oEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25*
* oEmail.Configuration.Fields.Update*
* oEmail.Send*
* END FUNCTION*
* Else*
* WScript.Quit*
* End If*

It could probably be cleaner, but hey it works!

0 Kudos