12 Replies Latest reply on Apr 3, 2014 7:01 PM by MostlyLost

    Customize email alarm subject lines in vCenter Server 5.1.0?

    BWB8771 Lurker

      Is there anyway to modify the subject lines for emailed alarms in vCenter Server 5.x ?

       

      I want the subject lines to include what host/VM the alert pertains to, something very similar to this:

           HostMemoryUsageAlarm on server.contoso.local changed status from Yellow to Green

       

      Currently, this is how the out-of-the-box alerts look:

       

      Subject:

      [VMware vCenter - Alarm alarm.HostMemoryUsageAlarm] alarm.HostMemoryUsageAlarm changed status from Yellow to Green

       

      Body:

      Target: server.contoso.local

      Previous Status: Yellow

      New Status: Green

       

      Alarm Definition:

      ([Yellow metric Is above 90%; Red metric Is above 95%])

       

      Current values for metric/state:

      Metric Memory Usage = 91%

       

      Description:

      Alarm 'Host memory usage' on server.contoso.local changed from Yellow to Green

        • 2. Re: Customize email alarm subject lines in vCenter Server 5.1.0?
          BWB8771 Lurker

          Via the GUI, I've already tried that - there is no option or way to tweak the text for the SUBJ field.

          • 3. Re: Customize email alarm subject lines in vCenter Server 5.1.0?
            Expert

            Subject cannot be changed, since its a part of standard MIB.

            • 4. Re: Customize email alarm subject lines in vCenter Server 5.1.0?
              MostlyLost Novice

              This question seems to float around on a semi-regular basis.  I was also very frustrated by the formatting of the subject lines, and spent way too much time digging through databases, vmsg files, and dark corners of Google.  But I think I have it now.  I'm sure others have solved it before too, and I've gleaned ideas from many sources.  Credit goes to the pros.

               

              Using powercli, you can create an alarm email action and customize the subject (and the body if you want).  You'll obviously need to have PowerCLI up and running and be comfortable with it.  Better programmers than I could write more robust code, and you use it at your own risk.  I've only used it with ESXi 5.0 / Vcenter 5.  But this might get you started, though you'll need to customize it with the alarm you're actually trying to modify.  Note that the variables inside brackets are case sensitive.  You can use:

              {targetName}

              {newStatus}

              {oldStatus}

              {target}

              {eventDescription}

              {alarmName}

              {triggeringSummary}

              {declaringSummary}

               

               

              #Remove the existing action, and create a new email action with a custom subject line

              $alarm="Virtual machine memory usage"

              Get-AlarmDefinition $alarm | Get-AlarmAction | Remove-AlarmAction -Confirm:$false

              Get-AlarmDefinition $alarm | New-AlarmAction -Email -To 'name@domain.dom' -Subject "[vAlarm] {targetName} memory is {newStatus}"

              Get-AlarmDefinition $alarm | Get-AlarmAction -ActionType SendEmail | New-AlarmActionTrigger -StartStatus "Green" -EndStatus "Yellow"

              Get-AlarmDefinition $alarm | Get-AlarmAction -ActionType SendEmail | New-AlarmActionTrigger -StartStatus "Red" -EndStatus "Yellow"

              Get-AlarmDefinition $alarm | Get-AlarmAction -ActionType SendEmail | New-AlarmActionTrigger -StartStatus "Yellow" -EndStatus "Green"

              1 person found this helpful
              • 5. Re: Customize email alarm subject lines in vCenter Server 5.1.0?
                BWB8771 Lurker

                Thanks! I have zero experience with PowerCLI, but this will give me an excuse to begin the foray!

                • 6. Re: Customize email alarm subject lines in vCenter Server 5.1.0?
                  bmurtagh Novice

                  This is really annoying. Especially trying to organize and ease of reading. I'd simply like to be able to add the VM's name in the subject line and can't.    

                  • 7. Re: Customize email alarm subject lines in vCenter Server 5.1.0?
                    barrywise Lurker

                    I too have little experience with PowerCLI when starting from scratch but I'm pretty good at taking an existing script and tweaking it.

                     

                    I found this PowerCLI script to turn on the email notification which I used successfully yesterday so it shouldn't be a big leap to modify it to incorporate the revised subject line.

                     

                    See here http://fixingitpro.com/2012/07/09/powercli-script-to-automatically-setup-vcenter-alarm-email-notification/

                     

                    If I get a chance to do this for myself I shall repost it back here.

                     

                    Thanks for the info

                    • 8. Re: Customize email alarm subject lines in vCenter Server 5.1.0?
                      Sharantyr3 Enthusiast

                      Hi,

                       

                      I modified my emails by modifying "\VMware\Infrastructure\VirtualCenter Server\locale\en\stask.vmsg"

                       

                      Replace \en\ by the langage directory of your vcenter. (like \de or \fr ...)

                       

                      The lines I modified :

                       

                      ###

                      Email.statefulAlarm.subject                                            = "[vAlarm] {alarmName} changed from {oldStatus} to {newStatus}"

                      Email.statefulAlarm.body                                               =  "Target: {targetName}\nPrevious Status: {oldStatus}\nNew Status: {newStatus}\n\nAlarm Definition:\n{declaringSummary}\n\n{alarmValue}:\n {triggeringSummary}\n\nDescription:\n{eventDescription}"

                      ###

                      Email.statefulEventAlarm.subject                                            = "[vAlarm] {alarmName} {eventDescription}"

                      Email.statefulEventAlarm.body                                               = "Target: {targetName}\nPrevious Status: {oldStatus}\nNew Status: {newStatus}\n\nAlarm Definition:\n{declaringSummary}\n\n{alarmValue}:\n {eventDescription}"

                      ###

                      Email.statelessEventAlarm.subject                                           = "[vAlarm] {alarmName} {eventDescription}"

                      Email.statelessEventAlarm.body                                              = "Target: {targetName}\nStateless event alarm\n\nAlarm Definition:\n{declaringSummary}\n\n{alarmValue}:\n{eventDescription}"

                      ###

                      • 9. Re: Customize email alarm subject lines in vCenter Server 5.1.0?
                        bmurtagh Novice

                        Thank you for the update Sharantyr3, one quick question I had was... After the modifications to the stask.vmsg file, does vCenter or a related service need to be restarted to apply the changes? If so, can you specify which service(s) need to be restarted?

                        • 10. Re: Customize email alarm subject lines in vCenter Server 5.1.0?
                          Sharantyr3 Enthusiast

                          Don't know, restarted all the vcenter services

                          • 11. Re: Customize email alarm subject lines in vCenter Server 5.1.0?
                            Tom Enthusiast

                            This is an issue that we have as well. As our vSphere environment is in a secure network the email system MUST have [SEC=UNCLASSIFIED] in the header or it will discard the email. I have been looking into the powershell to see if there is any way to specify a subject line with creating the alarms, however I haven't had any success yet. Can anyone else shed light on this?

                             

                            --- update ---

                             

                            I have come accross this page

                            vSphere 5.5 Documentation Center

                            It discusses creating new alarms, below is an exampe to specify a subject line

                            Get-AlarmDefinition -Name "Alarm1" | New-AlarmAction -Email -To 'test@vmware.com' -CC @('test1@vmware.com', 'test2@vmware.com') -Body 'Test body' -Subject '[SEC=UNCLASSIFIED] Test subject '

                             

                            So it looks like I will have to create an entirely new set of alarms with [SEC=UNCLASSIFIED]

                             

                            Message was edited by: Tom

                            • 12. Re: Customize email alarm subject lines in vCenter Server 5.1.0?
                              MostlyLost Novice

                              That approach mirrors what I described above.  Unfortunately, as you've realized, in your case it would be rather painful to do every alarm this way.  My situation involved just a handful of common alarms that were high priority due to their useless and overly long subject lines.

                               

                              Sharantyr3 described an approach of modifying vsmg files.  I haven't tested it myself, but if it works it would likely be much simpler for your situation.

                               

                              I doubt this is an option for you given your environment, but you could look into finding a tool to relay the emails and append your string to the subject line.  For example, I've used the Symantec Messaging Gateway which can, among other things, adjust subject lines before delivering.  Just trying to think outside the box a little.

                               

                              Good luck.