def sendEvents(count, dev, sev, event_class, production_state, priority, details, duplicate, requested_summary): from uuid import uuid4 from Products.ZenMessaging.queuemessaging.publisher import EventPublisher from Products.ZenEvents.Event import buildEventFromDict publisher = EventPublisher() if duplicate > 0: if requested_summary == "not_set": summary = "sent from tool events_add -- duplicate set of: %s (%s)" % (duplicate, uuid4()) else: summary = requested_summary for x in xrange(count): if duplicate == 0: if requested_summary == "not_set": summary = "sent from tool events_add: %s (%s)" % (x, uuid4()) else: summary = requested_summary event = { "evid": str(uuid4()), "device": dev, "severity": sev, "eventClass": event_class, "summary": "%s" % (summary), "zenoss.device.production_state": production_state, "zenoss.device.priority": priority, } if details: event.update(details) publisher.publish(buildEventFromDict(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}" "jwhitworth-tb3.zenoss.loc:8080/zport/dmd/evconsole_router" publisher.close()
def testUsingPublisher(self): event = self._createDummyEvent() publisher = EventPublisher() publisher.publish(event)
def testUsingPublisher(self): event = self._createDummyEvent() publisher = EventPublisher() EventPublisher._publisher = DummyQueuePublisher() publisher.publish(event) EventPublisher._publisher = None