Package linspector :: Package lib :: Package services :: Module snmpget
[hide private]
[frames] | no frames]

Source Code for Module linspector.lib.services.snmpget

 1  """ 
 2  The snmpget service in pure Python. 
 3  """ 
 4   
 5  #from pysnmp.entity.rfc3413.oneliner import cmdgen 
 6  from service import Service 
 7   
 8   
9 -class SnmpgetService(Service):
10 - def __init__(self, **kwargs):
11 super(SnmpgetService, self).__init__(**kwargs) 12 13 args = self.get_arguments() 14 15 if "community" in args: 16 self.community = args["community"] 17 else: 18 raise Exception("There is no community") 19 20 if "oid" in args: 21 self.oid = args["oid"] 22 else: 23 raise Exception("There is no oid") 24 25 self.port = "161" 26 if "port" in args: 27 self.port = args["port"]
28
29 - def needs_arguments(self):
30 return True
31
32 - def execute(self):
33 pass
34 #cmdGen = cmdgen.CommandGenerator() 35 36 #errorIndication, errorStatus, errorIndex, varBinds = cmdGen.getCmd( 37 # cmdgen.CommunityData(self.community), 38 # cmdgen.UdpTransportTarget((self._host, self.port)), 39 # cmdgen.MibVariable(self.oid) 40 #) 41 42 #if errorIndication: 43 # print(errorIndication) 44 #else: 45 # if errorStatus: 46 # print('%s at %s' % ( 47 # errorStatus.prettyPrint(), 48 # errorIndex and varBinds[int(errorIndex) - 1] or '?' 49 # )) 50 # else: 51 # for name, val in varBinds: 52 # print('%s = %s' % (name.prettyPrint(), val.prettyPrint())) 53 54
55 -def create(kargs):
56 return SnmpgetService(**kwargs)
57