xixeventlib API

xixeventlib.xixeventlib.event(event_id, event_text='', target='localhost', port=162, community='public', version=2, user=None, authkey=None, privkey=None, authproto=None, privproto=None, inform=False, timeout=1, retries=3, callback=None, context=None, lifetime=0)[source]

Send an xixEventSet or xixEventClear SNMP trap/notification.

Depending on the command line arguments, any of the following may be sent.

xixEventSet (SNMPv1 trap)
Sent if event_text is not empty and version is 1.
xixEventClear (SNMPv1 trap)
Sent if event_text is empty and version is 1.
xixEventSet(SNMPv2c notification)
Sent if event_text is not empty.
xixEventClear(SNMPv2c notification)
Sent if event_text is empty.
xixEventSet(SNMPv2c inform)
Sent if event_text is not empty and inform evaluates to true. Set timeout and retries to tune this.
xixEventClear(SNMPv2c inform)
Sent if event_text is empty and inform evaluates to true. Set timeout and retries to tune this.
xixEventSet(SNMPv3 notification)
Sent if event_text is not empty and SNMPv3 arguments are set.
xixEventClear(SNMPv3 notification)
Sent if event_text is empty and SNMPv3 arguments are set.
xixEventSet(SNMPv3 notification)
Sent if event_text is not empty, inform evaluates to true
and SNMPv3 arguments are set.
xixEventClear(SNMPv3 notification)
Sent if event_text is empty, inform evaluates to true and SNMPv3 arguments are set.
Parameters:
  • event_id (String (xixEventSet) or anything that evaluates to False (xixEventClear).) – xixEventId.
  • event_textxixEventText for xixEventSet events or left empty (or anything else that evaluates to False) for xixEventClear events.
  • target (String.) – The host to send the trap/notification to. The default is localhost which is useful for forwarding traps through snmptrapd_.
  • port (Integer.) – The UDP port the target(s) listen to. Naturally port defaults to 162.
  • community (String.) – Community for SNMPv1 and SNMPv2c operations. Ignored if any of the SNMPv3 related arguments are given. community defaults to public.
  • version (Integer.) – SNMP version (1=SNMPv1, 2=SNMPv2c, 3=SNMPv3). Setting version explicitly is only necessary if SNMPv1 is to be used. It defaults to SNMPv2 and will automatically change to SNMPv3 if user is given.
  • user (String or None.) – The SNMPv3 user. If set, SNMPv3 will be used regardless of version. Also set authkey and (if required) privkey or SNMPv3 security level will be noAuthNoPriv.
  • authkey (String or None.) – SNMPv3 authentication key. Setting this will set the SNMPv3 security level to AuthNoPriv.
  • privkey (String or None.) – SNMPv3 privacy key. Setting this will set the SNMPv3 security level to AuthPriv as long as authkey is also set.
  • authproto – SNMPv3 authentication protocol. This can be set to a PySNMP_ protocol. The default is pysnmp.entity.rfc3413.oneliner.ntforg.usmHMACSHAAuthProtocol.
  • privproto – SNMPv3 privacy protocol. This can be set to a PySNMP_ protocol. The default is pysnmp.entity.rfc3413.oneliner.ntforg.usmAesCfb128Protocol.
  • inform (Truth value.) – Send SNMPv2c/V3 inform instead of notification. Setting inform to true will force SNMPv2c/3 even if version is 1 as SNMPv1 does not implement SNMP inform.
  • timeout (Integer.) – Timeout parameter of SNMP inform operation.
  • retries (Integer.) – Retries parameter of SNMP inform operation.
  • callback (Function.) – Setting callback to a function makes all operations asynchronous. The callback function must have the same signature as the callback functions in PySNMP_.
  • context – Context for callback. See the PySNMP_ documentation for details.
  • lifetime – Setting lifetime to a positive number will suppress any future calls to xixeventlib.event() for as many seconds if the event_id, event_text, target and, port have been identical. This may be useful to reduce the number of effectively identical traps/notifications being sent to the same target.