Discussion:
API: How to add and manage event using JSON python API
James M
2013-05-20 15:27:30 UTC
Permalink
James M [http://community.zenoss.org/people/James] created the discussion

"API: How to add and manage event using JSON python API"

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

--------------------------------------------------------------
I'm trying to use JSON/Python API to create a new event
I'm using the documentation (ZenossAPIExample) to create a new event (create_event_on_device)

Up to this point it's working and I am able to create a new event,
The problem is I don't understand how to use the data returns to manage the event,

For example, the return code is:

{u'uuid': u'b8791acb-b6f9-4071-b065-9c26e36acd45', u'tid': 1, u'result': {u'msg'
: u'Created event', u'success': True}, u'action': u'EventsRouter', u'type': u'rp
c', u'method': u'add_event'}

My questions:

1. Is there any way to get the "Event ID" in the return call?
2. What is the "u'uuid'" used for?

All event actions (Acknowledge, close, add note etc..) requires the event ID and I'm trying to sync Zenoss with 3rd party events.

System:
Zenoss: 4.2.3
OS: CentOS 6.4

Any suggestions?

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

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

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 Scott
2013-05-20 21:00:40 UTC
Permalink
Shane Scott [http://community.zenoss.org/people/hackman238] created the discussion

"Re: API: How to add and manage event using JSON python API"

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

--------------------------------------------------------------
James,

What are you trying to solve for? I may have a published solution I can point you to.

Best,
--Shane Scott (hackman238)
http://shanewilliamscott.com http://shanewilliamscott.com
http://linkedin.com/in/shanewilliamscott http://linkedin.com/in/shanewilliamscott
--------------------------------------------------------------

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

Start a new discussion in zenoss-users at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
James M
2013-05-21 06:59:42 UTC
Permalink
James M [http://community.zenoss.org/people/James] created the discussion

"Re: API: How to add and manage event using JSON python API"

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

--------------------------------------------------------------
Hey http://community.zenoss.org/people/hackman238 Shane Scott

I'm trying to integrate Zenoss events with an internal system (self developed).

Basically what I need is "2 ways integration"
Meaning:
Use API to open an event and get the event ID in the callback (return code)
and then update the event (notes, ack, close etc..)

I just don't understand how to get this value (event ID) in the callback while creating an event.

Any suggestions will be appreciated.

Many thanks!
--------------------------------------------------------------

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

Start a new discussion in zenoss-users at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
James M
2013-05-26 10:37:41 UTC
Permalink
James M [http://community.zenoss.org/people/James] created the discussion

"Re: API: How to add and manage event using JSON python API"

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

--------------------------------------------------------------
Any suggestions?
--------------------------------------------------------------

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

Start a new discussion in zenoss-users at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
vitaly_il
2013-05-27 10:28:30 UTC
Permalink
vitaly_il [http://community.zenoss.org/people/vitaly_il] created the discussion

"Re: API: How to add and manage event using JSON python API"

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

--------------------------------------------------------------
James, if I undersood properly (I haven't had hands-on experience with this stuff ), uuid and evid are two representation (formats) of the same ID.
See
http://community.zenoss.org/message/70515#70515 http://community.zenoss.org/message/70515
http://wiki.zenoss.org/ZenDMD_Tip_-_Manipulate_Events http://wiki.zenoss.org/ZenDMD_Tip_-_Manipulate_Events
and Jane's paper http://www.skills-1st.co.uk/papers/jane/zenoss4-events/ http://www.skills-1st.co.uk/papers/jane/zenoss4-events/
--------------------------------------------------------------

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

Start a new discussion in zenoss-users at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
James M
2013-12-24 17:55:49 UTC
Permalink
James M [http://community.zenoss.org/people/James] created the discussion

"Re: API: How to add and manage event using JSON python API"

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

--------------------------------------------------------------
Hi

Still didn't manage to do that..
I'm opening a new event and getting the next data:
{u'uuid': u'43e33625-9dbb-42b1-a609-6750481b4c9b', u'tid': 1, u'result': {u'msg': u'Created event', u'success': True}, u'action': u'EventsRouter', u'type': u'rpc', u'method': u'add_event'}

But I didn't understand how to "convert" the 'uuid' to 'evid'
I want to use API call to close the event but I need the evid to do that..

Any suggestions?
--------------------------------------------------------------

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

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

"Re: API: How to add and manage event using JSON python API"

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

--------------------------------------------------------------
Hi !

  As far as I know, evid and uuid are the same... Where you can find a difference, is in the MySQL database where the uuid is stored as a binary representation. Also, you can aknowledge an event using the zepfacade methods and an event's uuid. I never used the JSON API but using a dmd script, it can go this way:
    zendmd
     >>> from Products.Zuul import getFacade
     >>> 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')
     >>> filter1 =zep.createEventFilter(uuid=u'43e33625-9dbb-42b1-a609-6750481b4c9b')
     >>> eventDict = zep.getEventSummariesGenerator(filter=filter1).next()
     >>> eventDict['uuid']
     >>> evt = EventSummaryProxy(from_dict(EventSummary, eventDict))
     >>> evt.evid
     >>> zep.acknowledgeEventSummaries(eventFilter=filter1)

You should find out that eventDict['uuid'] == evt.evid and that your event has been aknowledged
--------------------------------------------------------------

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

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

"Re: API: How to add and manage event using JSON python API"

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

--------------------------------------------------------------
Why not to use snmp traps and event transforms?
--------------------------------------------------------------

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

Start a new discussion in zenoss-users at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
James M
2013-12-25 10:36:46 UTC
Permalink
James M [http://community.zenoss.org/people/James] created the discussion

"Re: API: How to add and manage event using JSON python API"

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

--------------------------------------------------------------
Hi http://community.zenoss.org/people/Photon Photon, http://community.zenoss.org/people/vitaly_il vitaly_il & http://community.zenoss.org/people/hackman238 Shane Scott

Thanks for your response.

I have converted the 'blob' to evid, BUT what I get is the evid which is not the same as the 'uuid' I'm getting in the API callback.
API uuid = 96bc2155-6a3a-422f-901c-ccd7370d27c7
evid = 0050568b-1ad6-bb6a-11e3-6cbd7bdf7e74

How do I correlate between them?
To be clearer:
1. I'm opening an event using JSON API
2. Receiving the 'uuid' in the callback
---3 --- Here I'm missing a way to use this 'uuis' and convert it to the evid (using THIS uuid)
4. with the evid I can use the API for additional actions (acknowledge, notes, close, etc...)

alex0cy (http://community.zenoss.org/people/alex0cy) - snmp traps are not what I'm looking for (Working on automation using API)

Any suggestions?
--------------------------------------------------------------

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

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

"Re: API: How to add and manage event using JSON python API"

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

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

Can you post your JSON API call so that I recreate the situation here ?
--------------------------------------------------------------

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

Start a new discussion in zenoss-users at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
James M
2013-12-25 11:39:26 UTC
Permalink
James M [http://community.zenoss.org/people/James] created the discussion

"Re: API: How to add and manage event using JSON python API"

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

--------------------------------------------------------------
Hi http://community.zenoss.org/people/Photon Photon
Thanks for your reply.

I'm using the python API script 'api_example.py' method: 'create_event_on_device' from the official documentation:
http://community.zenoss.org/servlet/JiveServlet/downloadBody/13242-102-1-16717/Zenoss_JSON_API.zip http://community.zenoss.org/servlet/JiveServlet/downloadBody/13242-102-1-16717/Zenoss_JSON_API.zip

method:

def create_event_on_device(self, device, severity, summary):
        if severity not in ('Critical', 'Error', 'Warning', 'Info', 'Debug', 'Clear'):
            raise Exception('Severity "' + severity +'" is not valid.')


        data = dict(device=device, summary=summary, severity=severity,
                    component='', evclasskey='', evclass='')
        return self._router_request('EventsRouter', 'add_event', [data])



The call is:
event = api.create_event_on_device('testDevice', 'Warning', 'TEST! zenoss api new event')

print event:
{u'uuid': u'96bc2155-6a3a-422f-901c-ccd7370d27c7', u'tid': 1, u'result': {u'msg': u'Created event', u'success': True}, u'action': u'EventsRouter', u'type': u'rpc', u'method': u'add_event'}


I need to get the 'evid' of this 'uuid'

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

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

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

"Re: API: How to add and manage event using JSON python API"

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

--------------------------------------------------------------
I used your code and noticed that when creating the same event multiple times (translated to an incrementation of the count field in the event console), I get each time a different uuid... I think there is no direct correlation between the uuid you get and the evid. I also checked if it corresponded to the occurence uuids of the created event, but that wasn't the case...
Maybe the uuid you get is just identifying your call and not the event.
Can't be of much help here...

Good luck !
--------------------------------------------------------------

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

Start a new discussion in zenoss-users at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
Andrew Kirch
2013-12-28 17:05:03 UTC
Permalink
Andrew Kirch [http://community.zenoss.org/people/akirch] created the discussion

"Re: API: How to add and manage event using JSON python API"

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

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

PLEASE DO NOT TRY TO REPLY HERE, IN FACT YOU PROBABLY CANT, TO FIND OUT WHY, KEEP READING!!!

I'm Andrew Kirch, the Community Manager here at Zenoss.  We've migrated the Community Forums to our new Drupal based forums.  I've copied your thread to the new forums http://www.zenoss.org/forum/76 HERE.  If you have an account on the community wiki, that login already works, if not, head over, and follow the links to create it.  If you have questions, problems using the site, or feedback, or if you're a Nigerian prince with 5000000USD you want to send me, please use our feedback form at the upper left of the new site.

Cheers!

Andrew
--------------------------------------------------------------

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

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