Automation

 View Only
  • 1.  How do I add tags to a vcenter alarm email?

    Posted Jun 28, 2022 02:17 PM

    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!



  • 2.  RE: How do I add tags to a vcenter alarm email?
    Best Answer

    Posted Jun 28, 2022 05:09 PM

    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.



  • 3.  RE: How do I add tags to a vcenter alarm email?

    Posted Jun 28, 2022 09:36 PM

    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.