Discussion:
Zenoss 4 getEventList ?
ieldib
2012-02-23 13:36:54 UTC
Permalink
ieldib [http://community.zenoss.org/people/ieldib] created the discussion

"Zenoss 4 getEventList ?"

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

--------------------------------------------------------------
So I used to be able to do the following to get a list of events:

events = dmd.ZenEventManager.getEventList()

I can no longer loop through this as this is no longer an available function. Can anyone point me into the right direction on what to use as a replacement for zenoss 4  ? Thanks
--------------------------------------------------------------

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

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
jplouis
2012-02-23 22:53:56 UTC
Permalink
jplouis [http://community.zenoss.org/people/jplouis] created the discussion

"Re: Zenoss 4 getEventList ?"

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

--------------------------------------------------------------
From zendmd:

zep = getFacade('zep')
events = zep.getEventSummariesGenerator()

If not in zendmd, you need to import getFacade
from Products.Zuul import getFacade
--------------------------------------------------------------

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

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
Ryan Matte
2012-08-20 18:30:49 UTC
Permalink
Ryan Matte [http://community.zenoss.org/people/rmatte] created the discussion

"Re: Zenoss 4 getEventList ?"

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

--------------------------------------------------------------
So I'm working with these same functions.  In the old event system it was possible to also do something like...

evt = dmd.ZenEventManager.getEventDetailFromStatusOrHistory(e.evid)

evt would then become the context of that events and it would be possible to retrieve properties and manipulate the event the same way as you would in a transform.  I've been digging and I've found that there's an EventProxy routine that deals with this when transforms are applied against "raw" events that are sitting in the queue (before they make their way to the database).

What I would like to know is if there is an equivalent for getEventDetailFromStatusOrHistory in Zenoss 4.  Right now I'm having to do something like...

zep = getFacade('zep')
eventlist = []
for e in zep.getEventSummariesGenerator():
    eventlist.append(e)

for evt in eventlist:
    print 'Device: %s' % (evt['occurrence'][0]['actor']['element_identifier'])
    print 'Summary: %s' % (evt['occurrence'][0]['summary'])
    print ''


It's a bit ridiculous having to traverse through various dictionaries and lists to pull the data out.  Also, who is to say that the list value after occurence is necessarily always going to be 0?  There has to be a saner way of doing this.
--------------------------------------------------------------

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

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
Chet Luther
2012-08-20 23:21:30 UTC
Permalink
Chet Luther [http://community.zenoss.org/people/cluther] created the discussion

"Re: Zenoss 4 getEventList ?"

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

--------------------------------------------------------------
Good question. We have a class you can use to turn a typical EventSummary into a proxy that behaves like the old "evt". However, this class needs the native event summary instead of the JSON representation that comes out of that call to zep.getEventSummariesGenerator. So we'll also need to take that JSON representation and turn it back into a native EventSummary.

Here's an update to your example that works for me.
from zenoss.protocols.jsonformat import from_dict
from zenoss.protocols.protobufs.zep_pb2 import EventSummary
from Products.ZenEvents.events2.proxy import EventSummaryProxy
zep = getFacade('zep')
    evt = EventSummaryProxy(from_dict(EventSummary, summary))
    print 'Device: %s' % (evt.device)
    print 'Summary: %s' % (evt.summary)
    print ''
--------------------------------------------------------------

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

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
ieldib
2012-08-29 15:43:48 UTC
Permalink
ieldib [http://community.zenoss.org/people/ieldib] created the discussion

"Re: Zenoss 4 getEventList ?"

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

--------------------------------------------------------------
Is there an easyway to delete events ? I don't see any easy way to do so. I have a closeoldevents script htat uses zip - but unfortunately it never completes cleanly and ends up timing out.

Thanks
--------------------------------------------------------------

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

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
ieldib
2012-08-29 15:52:20 UTC
Permalink
ieldib [http://community.zenoss.org/people/ieldib] created the discussion

"Re: Zenoss 4 getEventList ?"

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

--------------------------------------------------------------
Also,

I can't import one of the modules you are trying to call:

Traceback (most recent call last):
  File "eventlist.py", line 3, in <module>
    from Products.ZenEvents.events2.proxy import EventSummaryProxy
ImportError: No module named ZenEvents.events2.proxy
--------------------------------------------------------------

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

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
Ryan Matte
2012-08-29 18:44:07 UTC
Permalink
Ryan Matte [http://community.zenoss.org/people/rmatte] created the discussion

"Re: Zenoss 4 getEventList ?"

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

--------------------------------------------------------------
I put this together the other day: http://wiki.zenoss.org/ZenDMD_Tip_-_Manipulate_Events http://wiki.zenoss.org/ZenDMD_Tip_-_Manipulate_Events
--------------------------------------------------------------

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

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