Discussion:
How to query events based on EventView definition via API
trentos7
2012-09-12 03:54:08 UTC
Permalink
trentos7 [http://community.zenoss.org/people/trentos7] created the discussion

"How to query events based on EventView definition via API"

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

--------------------------------------------------------------
Hi,

I can query events from the MySQL event DB, no problemo.

I would like to filter those events based on the same filters in a particular user's EventView (without manually replicating the filters in my WHERE clause).

I could parse the output of wget <URL to eventview>, but I suspect there is an easier way?

Please help.

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

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

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]
trentos7
2012-09-26 05:15:56 UTC
Permalink
trentos7 [http://community.zenoss.org/people/trentos7] created the discussion

"Re: How to query events based on EventView definition via API"

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

--------------------------------------------------------------
I worked it out.

Conect to ZenDMD, get the user or group that the view blongs to, then call getEventList() on the view object of that user:

from Products.ZenUtils.ZenScriptBase import ZenScriptBase
dmd = ZenScriptBase(connect=True,noopts=True).dmd


zenoss_user = dmd.ZenUsers.findObject(user)
view = zenoss_user.findObject(event_view_name)
events = view.getEventList()

for event in events:
    print event.device, event.summary,event.severity
--------------------------------------------------------------

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

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