Developer's Guide

  • Docs Home
  • Community Home

2. Sending an Event

Events can be created through a number of different ways:

  • From the command line (zensendevent)

  • Through the user interface (Add Event)

  • By daemons, which convert their messages into events (such as zentrap)

  • From daemons and programs that have detected error conditions

  • From an external source (using, for example, XML-RPC)

Regardless of what program generates the event, or from which protocol the event is sent to Zenoss, the following fields (at a minimum) should be specified:

Event fields

device

the name of the device from which this event originates

component

the sub-component of the device (for instance eth0, http, etc)

summary

the text message of the event

severity

an integer between 0 and 5 with higher numbers being higher severity. Zero is clear. Note that for Python code, that mappings to names are provided (see example below).

Here is an example using Python from within a program that connects to zenhub:

# Import severities (eg Clear, Debug, Info, Warning, Error Critical) and
# some event classes into our namespace
from Products.ZenEvents.ZenEventClasses import *

class exampleClass(PBDaemon):
    def examplefunc( self ):
        event= {}
        event[ 'component' ]= 'eth0'
        event[ 'severity' ]= Warning
        event[ 'summary' ]= 'eth0 is down'
        event[ 'message' ]= 'Received error code 0xa7 from listen()'
        self.sendEvent( event, device='mydevice' )

Using XML-RPC in Python:

from xmlrpclib import ServerProxy
myurl= 'http://admin:zenoss@MYHOST:8080/zport/dmd/ZenEventManager'
serv = ServerProxy( myurl )
evt = {'device':'mydevice', 'component':'eth0', 'summary':'eth0 is down',
       'severity':4, 'eventClass':'/Net'
       }
serv.sendEvent(evt)

Tip

Some suggested non-standard fields for adding to your event are:

resolution

Describe a method of fixing the situation that might have caused the event, or suggest a course of action for diagnosing the condition.

explanation

Describe in more detail the impact of this event on the computing environment. For instance, does the condition which generates this event prevent a service from starting or being monitored?