VMware Cloud Community
krik0011
Contributor
Contributor

Script to Generate Email after Alarm Help

I am trying to create a ps script that will fire after a certain Alarm is triggered in Vcenter. I want the script to include in the subject of the email the name of the guest as well as the alarm name. I am not a programmer by any means but have found the variable list for the alarms ( )

I started here but like I said I am not a programmer by any means:

$emailFrom = ""

$emailTo = ""

$subject = VMWARE_ALARM_EVENT_VM, VMWARE_ALARM_NAME

$body =

$smtpServer = ""

$smtp = new-object Net.Mail.SmtpClient($smtpServer)

$smtp.Send($emailFrom, $emailTo, $subject, $body)

Any one ever done this or can provide me with some guidance? I am perplexed why VMware does not allow you through Vsphere Client to edit the default email of an alarm.

Reply
0 Kudos
2 Replies
LucD
Leadership
Leadership

Did you have a look at my Alarm expressions – Part 2 : Event alarms post ?

____________

Blog: LucD notes

Twitter: lucd22


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
krik0011
Contributor
Contributor

That is helpful but I think it is more than I want to do at this point.. code anyway. Basically when an alarm is tripped (in this case VM CPU usage) I want the action to be a ps script that simply just puts the VM name in the subject as well as the name of the alarm.

Reply
0 Kudos