Follow

How To Create And Close Events Via curl With The JSON API

Pre-Requisites

  • Access to a machine with curl installed that can reach the web interface of the Zenoss server.
  • Login credentials for a user account with the Manager, ZenManager, or ZenOperator role assigned.

Applies To

  • Zenoss 5.x
  • Zenoss 4.x

Summary

The following are examples of creating and closing events using the curl command from a Linux terminal. These examples programmatically create and close events on your Zenoss system.

For these examples:

  • Login credentials are admin:zenoss
  • Zenoss Resource Manager system is sandbox411.zenoss.loc
  • zope/zenwebserver listens on port 8080.

Note: the two examples are formatted differently to demonstrate two ways of escaping characters in bash. Both are correct; use whichever method you prefer.

Create an event:

curl -u "admin:zenoss" -X POST -H "Content-Type:application/json" -d "{\"action\":\"EventsRouter\", \"method\":\"add_event\", \"data\":[{\"summary\":\"test55\", \"device\":\"test-rhel6.zenoss.loc\", \"component\":\"\", \"severity\":\"Critical\", \"evclasskey\":\"\", \"evclass\":\"/App\"}], \"type\":\"rpc\", \"tid\":1}" "sandbox411.zenoss.loc:8080/zport/dmd/evconsole_router"

Close an event:

curl -u "admin:zenoss" -X POST -H "Content-Type:application/json" -d '{"action":"EventsRouter","method":"close","data":[{"evids":["0050568a-2045-b48a-11e2-708c5755a8dd"],"params":"{\"severity\":[5,4,3,2,1,0],\"eventState\":[0,1,2]}","limit":1}],"type":"rpc","tid":1}' "sandbox411.zenoss.loc:8080/zport/dmd/evconsole_router"

UUID Returned

The uuid returned in the response from the JSON call to create the event is a uuid of the JSON call and is not directly tied to any uuid generated by the event processing system. As such, the uuid for the event will need to be determined before a curl command can be created to close the event. To identify the event's uuid, create a filter and send another request for events that match your filter.

For more information:

For more information, see our JSON API documentation @ http://wiki.zenoss.org/Working_with_the_JSON_API

Was this article helpful?
1 out of 1 found this helpful
Have more questions? Submit a request

Comments

Powered by Zendesk