VMware Cloud Community
BryITGuy
Contributor
Contributor
Jump to solution

How do I add tags to a vcenter alarm email?

Hi,

I see that we can customize the body of a VCenter alarm with powercli.  Is there a way to add tags?  For instance, I have automated grabbing the iDRAC IP with powercli and adding a tag for it, I would like to include the iDRAC IP in the email alert for that host.  

Or, I have also added the address and site contact of the host, I would also like to include that in the alert as well.  

Thank you!

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

No, not with supported methods.

In an Alarm that has an eMail action, you can add a number of variables in the email body the Alarm sends out.
See the ActionParameter enumeration.

When you define an Alarm to trigger a RunScriptAction you could in that script do whatever PowerCLI is capable of doing.
Including retrieving Tags.
Now the problem is that by default this script will have to be uploaded and run on the VCSA.
And if you want to use PowerCLI you would have to install PowerShell and the PowerCLI modules on the VCSA.

Which is officially not supported!

There are a number of semi-official ways around this.

One runs a minimal script on the VCSA in a language that is available by default on the VCSA.
That minimal script then triggers the real script on a separate server.
Kamen wrote a blog about this method, see Use-Case: Execute PowerCLI Scripts as vSphere Alarm Actions using Script Runtime Service
Kamen uses SRS as the remote server to run the PowerCLI script, but this could be whatever reachable server where you run PowerCLI.

A method I prefer, since it doesn't require anything on the VCSA that could jeopardize your support, is to use SNMP traps.
An Alarm can generate an SNMP trap with the SendSnmpAction.
Now on your SNMP Server you can intercept that trap and take action accordingly, i.e. run a PowerCLI script.

As you can see, nothing to support referring to Tags directly in the official Alarm methods.
But there are a number of workarounds, some of which require installing additional servers.


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

View solution in original post

2 Replies
LucD
Leadership
Leadership
Jump to solution

No, not with supported methods.

In an Alarm that has an eMail action, you can add a number of variables in the email body the Alarm sends out.
See the ActionParameter enumeration.

When you define an Alarm to trigger a RunScriptAction you could in that script do whatever PowerCLI is capable of doing.
Including retrieving Tags.
Now the problem is that by default this script will have to be uploaded and run on the VCSA.
And if you want to use PowerCLI you would have to install PowerShell and the PowerCLI modules on the VCSA.

Which is officially not supported!

There are a number of semi-official ways around this.

One runs a minimal script on the VCSA in a language that is available by default on the VCSA.
That minimal script then triggers the real script on a separate server.
Kamen wrote a blog about this method, see Use-Case: Execute PowerCLI Scripts as vSphere Alarm Actions using Script Runtime Service
Kamen uses SRS as the remote server to run the PowerCLI script, but this could be whatever reachable server where you run PowerCLI.

A method I prefer, since it doesn't require anything on the VCSA that could jeopardize your support, is to use SNMP traps.
An Alarm can generate an SNMP trap with the SendSnmpAction.
Now on your SNMP Server you can intercept that trap and take action accordingly, i.e. run a PowerCLI script.

As you can see, nothing to support referring to Tags directly in the official Alarm methods.
But there are a number of workarounds, some of which require installing additional servers.


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

BryITGuy
Contributor
Contributor
Jump to solution

The legendary LucD....  Thank you, you have helped me out a lot over the years.  First time I had to actually post the question because I couldn't find it.  

Reply
0 Kudos