Discussion:
Need Help Transforming Device ID into Device Title. Anyone Seen this Error?
Shane Ketterman
2013-07-18 03:24:41 UTC
Permalink
Shane Ketterman [http://community.zenoss.org/people/shaneketterman] created the discussion

"Need Help Transforming Device ID into Device Title. Anyone Seen this Error?"

To view the discussion, visit: http://community.zenoss.org/message/74031#74031

--------------------------------------------------------------
Per another forum post, someone discovered a way to display the Device Title in the email template as opposed to the Device ID which is something that should be really really simple and an option.  I used this:

d=dmd.Devices.findDevice(evt.device)
if d is not None:
     evt.device_title=d.title

And then you can change the email template to:

Device: ${evt/device_title}

That works for some devices and only some of the time but mostly when I implement this, I get no alert notifications and the following error in zenactiond.log:

*2013-07-17 20:00:38,882 ERROR zen.actions: Error when processing tales expression string:[zenoss] ${evt/device_title} ${evt/summary} on context {'evt': <Products.ZenModel.NotificationSubscription.NotificationEventSummaryProxy object at 0x76433d0>, 'trigger': {'name': 'Critical Events'}, 'urls': {'ackUrl': u' http://zenoss:8080/zport/dmd/Events/manage_ackEvents?evids=00212845-0b02-8fc0-11e2-ef56394dec52&zenScreenName=viewEvents http://zenoss:8080/zport/dmd/Events/manage_ackEvents?evids=00212845-0b02-8fc0-11e2-ef56394dec52&zenScreenName=viewEvents', 'reopenUrl': u' http://zenoss:8080/zport/dmd/Events/manage_undeleteEvents?evids=00212845-0b02-8fc0-11e2-ef56394dec52&zenScreenName=viewEvents http://zenoss:8080/zport/dmd/Events/manage_undeleteEvents?evids=00212845-0b02-8fc0-11e2-ef56394dec52&zenScreenName=viewEvents', 'eventUrl': u' http://zenoss:8080/zport/dmd/Events/viewDetail?evid=00212845-0b02-8fc0-11e2-ef56394dec52 http://zenoss:8080/zport/dmd/Events/viewDetail?evid=00212845-0b02-8fc0-11e2-ef56394dec52', 'baseUrl': ' http://zenoss:8080 http://zenoss:8080', 'closeUrl': u' http://zenoss:8080/zport/dmd/Events/manage_deleteEvents?evids=00212845-0b02-8fc0-11e2-ef56394dec52&zenScreenName=viewHistoryEvents http://zenoss:8080/zport/dmd/Events/manage_deleteEvents?evids=00212845-0b02-8fc0-11e2-ef56394dec52&zenScreenName=viewHistoryEvents', 'deviceUrl': u' http://zenoss:8080/zport/dmd/DevicesNone/devices/10.209.0.12/devicedetail http://zenoss:8080/zport/dmd/DevicesNone/devices/10.209.0.12/devicedetail', 'eventsUrl': ' http://zenoss:8080/zport/dmd/viewEvents http://zenoss:8080/zport/dmd/viewEvents'}, 'clearEvt': {}, 'notification': {'name': 'Critical_Email_Alerts'}, 'clearEventSummary': {}, 'eventSummary': <zenoss.protocols.wrappers.EventSummaryAdapter object at 0x766a890>} : Exception Class <class 'zope.location.interfaces.LocationError'>*

*Message: (<Products.ZenModel.NotificationSubscription.NotificationEventSummaryProxy object at 0x76433d0>, 'device_title')*

*2013-07-17 20:00:38,882 ERROR zen.actions: Error executing action Critical_Email_Alerts on set([ mailto:'***@bendbroadband.net '***@bendbroadband.net'])*
*2013-07-17 20:00:38,887 ERROR zen.zenactiond: Error executing action: email on notification Critical_Email_Alerts*
*2013-07-17 20:00:38,888 INFO zen.zenactiond: Event:'10.209.0.12||/Unknown|5|Test Alert' Trigger:critical Action:email Status:FAIL Target: mailto:***@bendbroadband.net ***@bendbroadband.net Info:Failed Email for notification Critical_Email_Alerts on targets ***@bendbr*

I'm totally confused how this works for some alerts but not others and why. 
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/74031#74031]

Start a new discussion in zenoss-users at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
jmp242
2013-07-18 12:19:12 UTC
Permalink
jmp242 [http://community.zenoss.org/people/jmp242] created the discussion

"Re: Need Help Transforming Device ID into Device Title. Anyone Seen this Error?"

To view the discussion, visit: http://community.zenoss.org/message/74042#74042

--------------------------------------------------------------
See:
if d is not None:

If d *is* None, then you don't get  evt.device_title=d.title and so Device: ${evt/device_title} = NULL as far as I can tell. You need to have an else to set it to *something* for the TALES not to barf.

--
James Pulver
ZCA Member
CLASSE Computer Group
Cornell University
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/74042#74042]

Start a new discussion in zenoss-users at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
Shane Ketterman
2013-07-18 14:49:05 UTC
Permalink
Shane Ketterman [http://community.zenoss.org/people/shaneketterman] created the discussion

"Re: Need Help Transforming Device ID into Device Title. Anyone Seen this Error?"

To view the discussion, visit: http://community.zenoss.org/message/74047#74047

--------------------------------------------------------------
Thanks James!

Here is the odd thing though.  In each case of my testing, there IS something in both the device ID and the Device Title field.  that's why this is very strange and confusing.  I can't tell from the errors why it fails on some and not others. 

I presume that this is also Python in which this transform is built?
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/74047#74047]

Start a new discussion in zenoss-users at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
jeronimo
2013-10-11 21:09:49 UTC
Permalink
jeronimo [http://community.zenoss.org/people/jeronimo] created the discussion

"Re: Need Help Transforming Device ID into Device Title. Anyone Seen this Error?"

To view the discussion, visit: http://community.zenoss.org/message/74954#74954

--------------------------------------------------------------
You may have already solved this by now, but I ran into a similar issue.  For me, there were a few devices where device.title = '' (empty string).  I confirmed this by going into dmd and looking at it there.  The tricky thing is that in the GUI, it fills title with Id if title is empty.  So you think it has a title but it doesn't.

This bites you because if you set a attribute to '' in a transform, it just drops that property.  So evt.device_title = '' results in an event which does not have a device_title attribute.

The way I got around it was:
evt.device_title = device.titleOrId()
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/74954#74954]

Start a new discussion in zenoss-users at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
Loading...