Skip navigation
3282 Views 6 Replies Latest reply: Aug 29, 2012 2:44 PM by Ryan Matte RSS
ieldib Rank: White Belt 43 posts since
Jun 29, 2011
Currently Being Moderated

Feb 23, 2012 8:36 AM

Zenoss 4 getEventList ?

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

  • jplouis ZenossEmployee 93 posts since
    May 7, 2008
    Currently Being Moderated
    1. Feb 23, 2012 5:53 PM (in response to ieldib)
    Re: Zenoss 4 getEventList ?

    From zendmd:

     

    zep = getFacade('zep')

    events = zep.getEventSummariesGenerator()

     

    If not in zendmd, you need to import getFacade

    from Products.Zuul import getFacade

  • Ryan Matte ZenossMaster 653 posts since
    Mar 26, 2009
    Currently Being Moderated
    2. Aug 20, 2012 2:34 PM (in response to jplouis)
    Re: Zenoss 4 getEventList ?

    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 event 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.

     

    Ideally I would like to be able to do something like...

     

    zep = getFacade('zep')
    eventlist = []
    for o in zep.getEventSummariesGenerator():
        eventlist.append(o)
    
    for e in eventlist:
        evt = someFunctionToGetTheEventContextByUUID(e['uuid'])
        print 'Device: %s' % (evt.device)
        print 'Summary: %s' % (evt.summary)
        print ''
    
  • Chet Luther ZenossEmployee 1,302 posts since
    May 22, 2007
    Currently Being Moderated
    3. Aug 20, 2012 7:21 PM (in response to Ryan Matte)
    Re: Zenoss 4 getEventList ?

    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')

    for summary in zep.getEventSummariesGenerator():

        evt = EventSummaryProxy(from_dict(EventSummary, summary))

        print 'Device: %s' % (evt.device)

        print 'Summary: %s' % (evt.summary)

        print ''

  • Ryan Matte ZenossMaster 653 posts since
    Mar 26, 2009
    Currently Being Moderated
    6. Aug 29, 2012 2:44 PM (in response to ieldib)
    Re: Zenoss 4 getEventList ?

More Like This

  • Retrieving data ...

Legend

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