-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsnmp_trap_generator.py
More file actions
29 lines (21 loc) · 956 Bytes
/
Copy pathsnmp_trap_generator.py
File metadata and controls
29 lines (21 loc) · 956 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
__author__ = 'venkat'
from pysnmp.entity.rfc3413.oneliner import ntforg
from pysnmp.proto import rfc1902
class SnmpTrapGenerator(object):
def __init__(self):
self.community = 'public'
self.snmpServerIP = '127.0.0.1'
self.snmpPort = 162
self.snmpTrapVariable = 'LinkMonitoring'
self.snmpTrapOID = '1.3.6.1.2.1.1.1.0'
self.snmpVarBind = ''
def send_snmp_trap(self,param):
if(param != None):
self.snmpVarBind = param
ntfOrg = ntforg.NotificationOriginator()
ntfOrg.sendNotification(ntforg.CommunityData(self.community, mpModel=0),
ntforg.UdpTransportTarget((self.snmpServerIP, self.snmpPort)),
'trap',
'1.3.6.1.4.1.20408.4.1.1.2.0.432',
(self.snmpTrapOID, rfc1902.OctetString(self.snmpVarBind)))
print("Sending SNMP Trap")