Skip navigation
1 2 3 4 Previous Next 26535 Views 47 Replies Latest reply: Sep 20, 2013 11:01 AM by pwinkeler RSS
amardeepj Rank: White Belt 20 posts since
Jul 19, 2010
Currently Being Moderated

Apr 18, 2011 9:19 AM

Customizing Email Notifications

Hello,

 

I'm trying to customize the e-mail notifications sent out by Zenoss Core 3.0.3. Here's what I have so far.

 

Summary:

%(device)s %(summary)s

 

Body:

Device: %(device)s
Component: %(component)s
Severity: %(severityString)s
Time: %(firstTime)s
Message:
%(message)s
<a href="%(eventUrl)s">Event Detail</a>
<a href="%(ackUrl)s">Acknowledge</a>
<a href="%(deleteUrl)s">Delete</a>
<a href="%(eventsUrl)s">Device Events</a>

This works great for most devices, however any devices that are not registered in DNS only show the IP address in the notfication. For example I have a device named BURL-SERVER-UPS. IP address 192.168.17.98

 

When the up/down notification gets sent, it gives a notification saying:

 

192.168.17.98 ip 192.168.17.98 is up

 

What field can I use so that the notification shows the Device Name rather than the IP?

  • Paul Gienger Rank: White Belt 7 posts since
    Apr 4, 2011
    Currently Being Moderated
    1. Apr 18, 2011 12:52 PM (in response to amardeepj)
    Re: Customizing Email Notifications

    I think you're doing it right, but I believe there's an inconsistancy underneath your data that is coming into play here.  Did your devices detect with the IP and then you renamed them?  Assuming yes, did you just type in the "in the details screen?

     

    If you said yes to both, then try this:  Go to your device screen and hit the actions menu (lower left), rename device.  Now check your notification.

     

    I don't know why there is the difference between the two rename methods, but it is there.  Notice in the URL for the device that the deep down data files never change.

  • tec Rank: Green Belt 197 posts since
    Oct 21, 2008
    Currently Being Moderated
    3. May 10, 2011 3:31 PM (in response to amardeepj)
    Re: Customizing Email Notifications

    Hi..

     

    If all you want is the name of the device to show in the "Device" column for the event, you don't need to rename the device.

     

    Just put the device name in the "Device Name:" field on the Overview page for the device. The name will then show up in the Device

     

    column in Event Console and can be referenced in an alert message by using %(device)s.

     

    If you don't populate the "Device Name:" field, the device id (ip address) will be used instead.

  • tec Rank: Green Belt 197 posts since
    Oct 21, 2008
    Currently Being Moderated
    5. May 10, 2011 5:22 PM (in response to amardeepj)
    Re: Customizing Email Notifications

    Ok..

    I added all my devices using the IP as well and then edited the device name field to a friendly name and didnt have the problem your having.

     

    I wonder if the space in the name is causing a problem. Can you remove the space and see if it helps?

  • weeyin Rank: White Belt 9 posts since
    Jan 11, 2011
    Currently Being Moderated
    7. Aug 17, 2011 5:02 AM (in response to amardeepj)
    Re: Customizing Email Notifications

    Did you ever get this resolved?  We are having the same issue...

  • weeyin Rank: White Belt 9 posts since
    Jan 11, 2011
    Currently Being Moderated
    9. Aug 17, 2011 10:26 AM (in response to amardeepj)
    Re: Customizing Email Notifications

    I had another go after reading this post and I clicked on the clog icon, renamed the deviced, remodelled it and it's now reporting the name rather than IP address...

  • kamintech Rank: White Belt 12 posts since
    Apr 14, 2010
    Currently Being Moderated
    10. Aug 17, 2011 4:26 PM (in response to weeyin)
    Re: Customizing Email Notifications

    I had the same problem and added the host name to the host file and it took care of for me.

  • Jeremy Koerber Rank: White Belt 37 posts since
    Aug 14, 2012
    Currently Being Moderated
    11. Aug 17, 2012 11:09 AM (in response to amardeepj)
    Re: Customizing Email Notifications

    I'm using Zenoss 4.2 and monitoring AWS instances. All of my devices got imported automatically when I plugged in my AWS credentials to the EC2Manager plugin. However, it made their device id something like this -

    aws-i-252dsf5e

     

    But their device titles were populated like this: ec2-167-21-180-175.compute-1.amazonaws.com.

     

    All fine and good, except for the fact that the email notifications use %(device) and that references the Device ID, and not the device title. This is not helpful when I get an alert. I am able to rename the device with the Rename Device menu option in the lower left (by clicking the gear under Overview left hand pane for the device.). This changes the Device ID and then the alert has the name I want. But this seems to break the automatic linking between imported EC2 instances and their respective device objects. I really like that feature, and I'd be fine if I could just tell the email notifications to use something like %(deviceTitle) instead of the device ID. It seems silly that this isn't a notification variable. Also 'device group' should be a notification variable. Device ID's should be able to be left alone, and the more meaningful, easily modified, and human readable 'Device Title' is what I want to see in my notifications.

    Zenoss - please add one more little notification variable, pretty please!

  • Shane Scott ZenossMaster 1,373 posts since
    Jul 6, 2009
    Currently Being Moderated
    12. Aug 18, 2012 5:15 AM (in response to Jeremy Koerber)
    Re: Customizing Email Notifications

    Jeremy:

     

    You'll need to patch $ZENHOME/ZenModel/actions.py ~line 76 to add deviceTitle to the action context.

     

    Good luck!

     

    Best,

    --Shane Scott (Hackman238)

  • Jeremy Koerber Rank: White Belt 37 posts since
    Aug 14, 2012
    Currently Being Moderated
    13. Aug 18, 2012 2:05 PM (in response to Shane Scott)
    Re: Customizing Email Notifications

    Thanks Shane. So I'm looking at the block of code that starts on line 76 in /opt/zenoss/Products/ZenModel/actions.py and I'm not really seeing anything that looks related directly to my issue. I'm on version 4.2.0 and this is what I see:

     

    def _signalToContextDict(signal, zopeurl, notification=None, guidManager=None):
        summary = signal.event
        # build basic event context wrapper for notifications
        if signal.clear:
            # aged and closed events have clear == True, but they don't have an associated clear event
            #   spoof a clear event in those cases, so the notification messages contain useful info
            if summary.status == zep_pb2.STATUS_AGED:
                occur = signal.clear_event.occurrence.add()
                occur.summary = "Event aging task aged out the event."
                summary.cleared_by_event_uuid = "Event aging task"
            elif summary.status == zep_pb2.STATUS_CLOSED:
                occur = signal.clear_event.occurrence.add()
                occur.summary = "User '" + summary.current_user_name + "' closed the event in the Zenoss event console."
                summary.cleared_by_event_uuid = "User action"
            data = NotificationEventContextWrapper(summary, signal.clear_event)
        else:
            data = NotificationEventContextWrapper(summary)
    
    

     

    I hate be overly needy, but can you give me another hint or 2 as to what exactly I'm looking to do here? Really appreciate it...

     

    thanks,

    jeremy

     

    ps - whole file is attached

    Attachments:
  • Shane Scott ZenossMaster 1,373 posts since
    Jul 6, 2009
    Currently Being Moderated
    14. Aug 18, 2012 5:21 PM (in response to Jeremy Koerber)
    Re: Customizing Email Notifications

    Jeremy:

     

    My mistsake, I was looking at v4.1. For v4.2 it's around line 96.

     

    You will see where the other variables are defined in this area.

     

    Best,

    --Shane Scott (Hackman238)

1 2 3 4 Previous Next

More Like This

  • Retrieving data ...

Legend

  • Correct Answers - 4 points
  • Helpful Answers - 2 points