Package Products :: Package ZenEvents :: Module zentrap :: Class ZenTrap
[hide private]
[frames] | no frames]

Class ZenTrap

source code

                 object --+                
                          |                
   ZenUtils.CmdBase.CmdBase --+            
                              |            
   ZenUtils.ZenDaemon.ZenDaemon --+        
                                  |        
twisted.spread.pb.Referenceable --+        
                                  |        
           ZenHub.PBDaemon.PBDaemon --+    
                                      |    
                EventServer.EventServer --+
                                          |
                             object --+   |
                                      |   |
   ZenUtils.captureReplay.CaptureReplay --+
                                          |
                                         ZenTrap

Listen for SNMP traps and turn them into events Connects to the TrapService service in zenhub.

Instance Methods [hide private]
 
__init__(self)
Initializer that takes care of basic daemon options.
source code
 
isReplaying(self)
@returns True if we are replaying a packet instead of capturing one
source code
 
configure(self) source code
string
getEnterpriseString(self, pdu)
Get the enterprise string from the PDU or replayed packet
source code
dictionary
getResult(self, pdu)
Get the values from the PDU or replayed packet
source code
string
getCommunity(self, pdu)
Get the communitry string from the PDU or replayed packet
source code
Python FakePacket object
convertPacketToPython(self, addr, pdu)
Store the raw packet for later examination and troubleshooting.
source code
 
replay(self, pdu)
Replay a captured packet
source code
Twisted deferred object
oid2name(self, oid, exactMatch=True, strip=False)
Returns a MIB name based on an OID and special handling flags.
source code
 
receiveTrap(self, pdu)
Accept a packet from the network and spin off a Twisted deferred to handle the packet.
source code
 
processPacket(self, addr, pdu, ts)
Wrapper around asyncHandleTrap to process the provided packet.
source code
Twisted deferred object
asyncHandleTrap(self, addr, pdu, ts)
Twisted callback to process a trap
source code
 
buildOptions(self)
Command-line options to be supported
source code

Inherited from EventServer.EventServer: connected, heartbeat, model, report, reportCycle, sendEvent, useTcpFileDescriptor, useUdpFileDescriptor

Inherited from ZenHub.PBDaemon.PBDaemon: connect, connectTimeout, eventService, getInitialServices, getService, getServiceNow, gotPerspective, pushEvents, pushEventsLoop, remote_getName, remote_setPropertyItems, remote_shutdown, remote_updateThresholdClasses, run, sendEvents, setExitCode, sigTerm, stop

Inherited from ZenUtils.ZenDaemon.ZenDaemon: becomeDaemon, becomeWatchdog, changeUser, niceDoggie, openPrivilegedPort, setupLogging, sighandler_USR1, watchdogCycleTime, watchdogMaxRestartTime, watchdogStartTimeout, writePidFile

Inherited from ZenUtils.CmdBase.CmdBase: buildParser, checkLogpath, generate_configs, generate_xml_configs, generate_xml_table, getConfigFileDefaults, parseOptions, pretty_print_config_comment

Inherited from ZenUtils.captureReplay.CaptureReplay: buildCaptureReplayOptions, capturePacket, processCaptureReplayOptions, replayAll, replayStop

Class Variables [hide private]
  name = 'zentrap'
  initialServices = EventServer.initialServices+ ['TrapService']
  oidMap = {}
  haveOids = False

Inherited from ZenHub.PBDaemon.PBDaemon: heartbeatEvent, heartbeatTimeout

Inherited from ZenUtils.ZenDaemon.ZenDaemon: pidfile

Inherited from ZenUtils.CmdBase.CmdBase: doesLogging

Method Details [hide private]

__init__(self)
(Constructor)

source code 

Initializer that takes care of basic daemon options. Creates a PID file.

Overrides: ZenUtils.CmdBase.CmdBase.__init__

configure(self)

source code 
Overrides: EventServer.EventServer.configure

getEnterpriseString(self, pdu)

source code 

Get the enterprise string from the PDU or replayed packet

Parameters:
  • pdu (binary) - raw packet
Returns: string
enterprise string

getResult(self, pdu)

source code 

Get the values from the PDU or replayed packet

Parameters:
  • pdu (binary) - raw packet
Returns: dictionary
variables from the PDU or Fake packet

getCommunity(self, pdu)

source code 

Get the communitry string from the PDU or replayed packet

Parameters:
  • pdu (binary) - raw packet
Returns: string
SNMP community

convertPacketToPython(self, addr, pdu)

source code 

Store the raw packet for later examination and troubleshooting.

Parameters:
  • addr ((string, number)) - packet-sending host's IP address and port
  • pdu (binary) - raw packet
Returns: Python FakePacket object
Python FakePacket object
Overrides: ZenUtils.captureReplay.CaptureReplay.convertPacketToPython

replay(self, pdu)

source code 

Replay a captured packet

Parameters:
  • pdu (binary) - raw packet
Overrides: ZenUtils.captureReplay.CaptureReplay.replay

oid2name(self, oid, exactMatch=True, strip=False)

source code 

Returns a MIB name based on an OID and special handling flags.

Parameters:
  • oid (string) - SNMP Object IDentifier
  • exactMatch (boolean) - find the full OID or don't match
  • strip (boolean) - show what matched, or matched + numeric OID remainder
Returns: Twisted deferred object
Twisted deferred object

receiveTrap(self, pdu)

source code 

Accept a packet from the network and spin off a Twisted deferred to handle the packet.

Parameters:
  • pdu (netsnmp_pdu object) - Net-SNMP object

processPacket(self, addr, pdu, ts)

source code 

Wrapper around asyncHandleTrap to process the provided packet.

Parameters:
  • addr (( host-ip, port)) - packet-sending host's IP address, port info
  • pdu (netsnmp_pdu object) - Net-SNMP object
  • ts (datetime) - time stamp

asyncHandleTrap(self, addr, pdu, ts)

source code 

Twisted callback to process a trap

Parameters:
  • addr (( host-ip, port)) - packet-sending host's IP address, port info
  • pdu (netsnmp_pdu object) - Net-SNMP object
  • ts (datetime) - time stamp
Returns: Twisted deferred object
Twisted deferred object

buildOptions(self)

source code 

Command-line options to be supported

Overrides: ZenUtils.CmdBase.CmdBase.buildOptions