SNMPTrapMgr Class
Properties Methods Events Configuration Settings Errors
The SNMPTrapMgr class provides a UDP-based listening point for SNMP traps.
Syntax
class ipworkssnmp.SNMPTrapMgr
Remarks
The SNMPTrapMgr class provides a UDP-based listening point for SNMP traps and informs as specified by the SNMP RFCs. The class supports v1, v2c, and v3 traps.
The class provides both encoding/decoding and transport capabilities, making the task of developing a custom SNMP Trap manager as simple as setting a few key properties and handling a few events. SNMP data, such as for instance SNMP object id-s (OID-s) are exchanged as text strings, thus further simplifying the task of handling them.
The class is activated/deactivated by setting the Active property. This property enables or disables sending and receiving.
Messages are received through events such as on_trap, on_inform_request, or on_discovery_request.
SNMP OIDs, types, and values are provided in the objects collection of SNMP objects for both sent and received packets.
SNMPv3 USM security passwords are requested through the on_get_user_password event, and event parameters such as User and SecurityLevel provide information about the security attributes of received requests, and enable granular decision capability about what to provide and what not to provide.
The add_user, remove_user, show_cache, clear_cache, add_engine, and remove_engine methods are used to manage an internal authentication cache. This internal cache can be used as an alternative to the on_get_user_password event, automatically checking the cache against the security parameters provided in the request signature.
Property List
The following is the full list of the properties of the class with short descriptions. Click on the links for further details.
accept_data | Enables or disables data reception. |
active | Enables or disables sending and receiving of SNMP packets. |
local_engine_id | The Engine Id (for SNMPv3). |
local_host | The name of the local host or user-assigned IP interface through which connections are initiated or accepted. |
local_port | The port in the local host where the class is bound to. |
obj_count | The number of records in the Obj arrays. |
obj_type | The current object's type. |
obj_id | The current object's id which is encoded as a string of numbers separated by periods. |
obj_type_string | A string representation of the current object's ObjectType . |
obj_value | The current object's value. |
request_id | The request-id to mark outgoing packets with. |
Method List
The following is the full list of the methods of the class with short descriptions. Click on the links for further details.
add_engine | Adds the engine specified by EngineId to the internal authentication cache. |
add_user | Adds a user for the engine specified by EngineId to the internal authentication cache. |
clear_cache | Clears the internal authentication database. |
config | Sets or retrieves a configuration setting. |
do_events | Processes events from the internal message queue. |
hash_passwords | Hashes all passwords in the cache. |
remove_engine | Removes the engine specified by EngineId from the internal authentication cache. |
remove_user | Removes the user specified by User of the engine specified by EngineId from the internal authentication cache. |
reset | Clears the object arrays. |
show_cache | Lists all entries in the internal user and engine database. |
value | Returns the value corresponding to an OID. |
Event List
The following is the full list of the events fired by the class with short descriptions. Click on the links for further details.
on_bad_packet | Fired for erroneous and/or malformed messages. |
on_cache_entry | Shows engines and users in the internal cache. |
on_check_engine | Fired to check engine parameters (timeliness, etc.). |
on_discovery_request | Fired when an SNMPv3 discovery packet is received. |
on_error | Information about errors during data delivery. |
on_get_user_password | Retrieves a password associated with a user. |
on_get_user_security_level | Sets the security level for an incoming packet. |
on_hash_password | Fired before and after a password is hashed. |
on_inform_request | Fired when an InformRequest packet is received. |
on_packet_trace | Fired for every packet sent or received. |
on_trap | Fired when a SNMP trap packet is received. |
Configuration Settings
The following is a list of configuration settings for the class with short descriptions. Click on the links for further details.
AuthenticationKey | The key to use for authentication. |
CompatibilityMode | Whether to operate the class in a specific compatibility mode. |
ContextEngineId | Sets the context engine id of the SNMP entity. |
ContextName | Sets the context name of the SNMP entity. |
DecryptLogPackets | Whether to decrypt logged packets. |
EncryptionKey | The key to use for encryption. |
ForceLocalPort | Forces the class to bind to a specific port. |
ShowCacheForUser | Shows the cache entry for a single user. |
SourceAddress | The source address of the received packet. |
SourcePort | The source port of the received packet. |
TimeWindow | The time window used for SNMPv3 timeliness checking (authentication). |
CaptureIPPacketInfo | Used to capture the packet information. |
DestinationAddress | Used to get the destination address from the packet information. |
DontFragment | Used to set the Don't Fragment flag of outgoing packets. |
LocalHost | The name of the local host through which connections are initiated or accepted. |
LocalPort | The port in the local host where the class binds. |
MaxPacketSize | The maximum length of the packets that can be received. |
QOSDSCPValue | Used to specify an arbitrary QOS/DSCP setting (optional). |
QOSTrafficType | Used to specify QOS/DSCP settings (optional). |
ShareLocalPort | If set to True, allows more than one instance of the class to be active on the same local port. |
SourceIPAddress | Used to set the source IP address used when sending a packet. |
SourceMacAddress | Used to set the source MAC address used when sending a packet. |
UseConnection | Determines whether to use a connected socket. |
UseIPv6 | Whether or not to use IPv6. |
AbsoluteTimeout | Determines whether timeouts are inactivity timeouts or absolute timeouts. |
FirewallData | Used to send extra data to the firewall. |
InBufferSize | The size in bytes of the incoming queue of the socket. |
OutBufferSize | The size in bytes of the outgoing queue of the socket. |
BuildInfo | Information about the product's build. |
CodePage | The system code page used for Unicode to Multibyte translations. |
LicenseInfo | Information about the current license. |
ProcessIdleEvents | Whether the class uses its internal event loop to process events when the main thread is idle. |
SelectWaitMillis | The length of time in milliseconds the class will wait when DoEvents is called if there are no events to process. |
UseInternalSecurityAPI | Tells the class whether or not to use the system security libraries or an internal implementation. |