def getsnmpinfo(self): #Run over interfaces #get number of interfaces snmpDevice = lib_SNMP.SNMPv2(self.ipaddr) returnValue = {} number = self.getDataDict['maxIfNumber'] InterfaceCount = snmpDevice.readSNMP(number, ReadCommunity='public') for x in range(1, int(InterfaceCount) + 1): dictionary = {} port = snmpDevice.readSNMP(self.getDataDict['ifDescr'] + "." + str(x)).replace(" ", "_") #dictionary["port"] = snmpDevice.readSNMP(self.getDataDict['ifDescr'] + "." + str(x)).replace(" ","_") dictionary["IfMac"] = self.converttomac( snmpDevice.readSNMP(self.getDataDict['ifPhysAddress'] + "." + str(x))) if dictionary["IfMac"] == None: dictionary["IfMac"] = "N/A" temp = snmpDevice.readSNMP(self.getDataDict['ifAdminStatus'] + "." + str(x)) dictionary["ifAdminStatus"] = self.ifAdminStatusList[int(temp)] temp = snmpDevice.readSNMP(self.getDataDict['ifOperStatus'] + "." + str(x)) dictionary["ifOperStatus"] = self.ifOperStatusList[int(temp)] dictionary["vlan"] = snmpDevice.readSNMP( self.getDataDict['vlanId'] + "." + str(x)) if dictionary["vlan"] == None: dictionary["vlan"] = 'N/A' try: temp = snmpDevice.readSNMP(self.getDataDict['vlanStatus'] + "." + str(x)) dictionary["vlanStatus"] = self.vlanStatusList[int(temp)] except: dictionary["vlanStatus"] = 'N/A' try: temp = snmpDevice.readSNMP(self.getDataDict['vlanMembership'] + "." + str(x)) dictionary["vlanMembership"] = self.vlanMembershipList[int( temp)] except: dictionary["vlanMembership"] = 'N/A' dictionary["ifInOctets"] = snmpDevice.readSNMP( self.getDataDict['ifInOctets'] + "." + str(x)) if dictionary["ifInOctets"] == None: dictionary["ifInOctets"] = 'N/A' dictionary["ifOutOctets"] = snmpDevice.readSNMP( self.getDataDict['ifOutOctets'] + "." + str(x)) if dictionary["ifOutOctets"] == None: dictionary["ifOutOctets"] = 'N/A' returnValue[port] = dictionary #Get General information returnValue["General"] = {} #get serial returnValue["General"]["SerialNumber"] = snmpDevice.readSNMP( self.getDataDict['serialNumber']) returnValue["General"]["ModelNumber"] = snmpDevice.readSNMP( self.getDataDict['modelNumber']) returnValue["General"]["SoftwareVersion"] = snmpDevice.readSNMP( self.getDataDict['softVersion']) return returnValue
def RebootOutlet(self, command): if "Option" in command: #isinstance(command["Option"],( int, long )): if command["Option"].isdigit(): id = int(command["Option"]) #get number of outputs snmpDevice = lib_SNMP.SNMPv2(self.ipaddr) outletCount = snmpDevice.readSNMP(self.getDataDict['infeedOutletCount']) if outletCount is not None: outletCount = int(outletCount) if id > 0 and id <= outletCount: self.log.printInfo("Rebooting outlet %s" % id) #outletControlAction 1.3.6.1.4.1.1718.3.2.3.1.11.1.1.1-8 # readWrite ! - 0 none, 1 on, 2 off, 3 reboot oid = netsnmp.Varbind('.1.3.6.1.4.1.1718.3.2.3.1.11.1.1.' + str(id),'','3','INTEGER') res = netsnmp.snmpset(oid, Version=2, DestHost=self.ipaddr, Community='private') # res = netsnmp.snmpset(oid, version=2, hostname=self.ipaddr, community='private') return False else: self.log.printWarning("Given outlet was not a number") return True else: self.log.printWarning("No outlet-number was given") return True
def SNMPRequests(self): result = {} if self.Error == False: try: ipaddr = self.INI.getOption(self.deviceDescr, self.devNumber, "IP") self.getDataDict = { 'BlockZones': '1.3.6.1.4.1.13745.100.1.1.26.0', } snmpDevice = lib_SNMP.SNMPv2(ipaddr) BlockZones = snmpDevice.readSNMP( self.getDataDict['BlockZones']) BlockZones = BlockZones.split(";") i = 1 for zone in BlockZones: result["blockzone" + str(i)] = {} items = zone.split(",") result["blockzone" + str(i)]["Status"] = items[0] result["blockzone" + str(i)]["AzStart"] = items[1] result["blockzone" + str(i)]["AzEnd"] = items[2] result["blockzone" + str(i)]["ElEnd"] = items[3] i += 1 except Exception as e: return None return result
def __init__(self, INI, deviceDescr, devNumber): self.Error = False self.log = lib_Log.Log(PrintToConsole=True) #for inhiretance from device class self.INI = INI self.deviceDescr = deviceDescr self.devNumber = devNumber self.log.increaseLevel() self.ipaddr = self.INI.getOption(self.deviceDescr, self.devNumber, "IP") self.getDataDict = { 'pduManufacturer': '1.3.6.1.4.1.13742.6.3.2.1.1.2.1', 'pduModel': '1.3.6.1.4.1.13742.6.3.2.1.1.3.1', 'pduSerialNumber': '1.3.6.1.4.1.13742.6.3.2.1.1.4.1', #'pduRatedVoltage' : '1.3.6.1.4.1.13742.6.3.2.1.1.5.1', #'pduRatedCurrent' : '1.3.6.1.4.1.13742.6.3.2.1.1.6.1', #'pduRatedFrequency' : '1.3.6.1.4.1.13742.6.3.2.1.1.7.1', #'pduRatedVA' : '1.3.6.1.4.1.13742.6.3.2.1.1.8.1', 'OutletCount': '1.3.6.1.4.1.13742.6.3.2.2.1.4.1', 'pduName': '1.3.6.1.4.1.13742.6.3.2.2.1.13.1', 'pduPower': '1.3.6.1.4.1.13742.6.5.2.3.1.6.1.1.5', 'pduVA': '1.3.6.1.4.1.13742.6.5.2.3.1.6.1.1.6', 'pduLineFrequency': '1.3.6.1.4.1.13742.6.5.2.3.1.6.1.1.23', 'pduMAC': '1.3.6.1.2.1.2.2.1.6.2', 'pduInletCurrent': '1.3.6.1.4.1.13742.6.5.2.3.1.6.1.1.1', 'pduInletVoltage': '1.3.6.1.4.1.13742.6.5.2.3.1.4.1.1.4', } #get number of outputs snmpDevice = lib_SNMP.SNMPv2(self.ipaddr) outletCount = snmpDevice.readSNMP(self.getDataDict['OutletCount']) #loop over outlets if outletCount is not None: for x in range(1, int(outletCount) + 1): self.getDataDict["outlet" + str(x)] = {} self.getDataDict["outlet" + str( x)]['name'] = '1.3.6.1.4.1.13742.6.3.5.3.1.3.1.' + str(x) self.getDataDict["outlet" + str( x )]['status'] = '1.3.6.1.4.1.13742.6.4.1.2.1.2.1.' + str( x ) #0 off, 1 on, 2 offWait, 3 onWait, 4 offError, 5 On Error, 6nocomm, 7 reading, 8 offFuse, 9 onFuse self.getDataDict["outlet" + str( x )]['uptime'] = '1.3.6.1.4.1.13742.6.4.1.2.1.4.1.' + str( x ) #0 idleOff, 1 idleOn, 2 wakeOff, 3 wakeOn, 4 off, 5 on, 6 lockedOff, 7 lockedOn, 8 reboot, 9 shutdown, 10 pendOn, 11 pendOff, 12 minimumOff, 13 minimumOn, 14 eventOff, 15 eventOn, 16 eventReboot, 17 eventShutdown
def __init__(self, INI, deviceDescr, devNumber): self.Error = False self.log = lib_Log.Log(PrintToConsole=True) #for inhiretance from device class self.INI = INI self.deviceDescr = deviceDescr self.devNumber = devNumber self.log.increaseLevel() self.ipaddr = self.INI.getOption(self.deviceDescr, self.devNumber, "IP") self.getDataDict = { 'systemDescription' : '1.3.6.1.2.1.1.1.0', 'systemUpTime' : '1.3.6.1.2.1.1.3.0', 'systemContact' : '1.3.6.1.2.1.1.4.0', 'systemName' : '1.3.6.1.2.1.1.5.0', 'systemLocation' : '1.3.6.1.2.1.1.6.0', 'systemVersion' : '1.3.6.1.4.1.1718.3.1.1.0', 'systemNICSerialNumber' : '1.3.6.1.4.1.1718.3.1.2.0', 'systemTotalPower' : '1.3.6.1.4.1.1718.3.1.6.0', 'infeedID' : '1.3.6.1.4.1.1718.3.2.2.1.2.1.1', 'infeedName' : '1.3.6.1.4.1.1718.3.2.2.1.3.1.1', 'infeedStatus' : '1.3.6.1.4.1.1718.3.2.2.1.5.1.1', #0 off, 1 on, 2 offWait, 3 onWait, 4 offError, 5 On Error, 6nocomm, 7 reading, 8 offFuse, 9 onFuse 'infeedLoadValue' : '1.3.6.1.4.1.1718.3.2.2.1.7.1.1', #in 1/100th of Amps 'infeedLoadHighThresh' : '1.3.6.1.4.1.1718.3.2.2.1.8.1.1', 'infeedOutletCount' : '1.3.6.1.4.1.1718.3.2.2.1.9.1.1', #number of outputs 'infeedCapacity' : '1.3.6.1.4.1.1718.3.2.2.1.10.1.1', 'infeedVoltage' : '1.3.6.1.4.1.1718.3.2.2.1.11.1.1', 'infeedPower' : '1.3.6.1.4.1.1718.3.2.2.1.12.1.1', 'towerStatus' : '1.3.6.1.4.1.1718.3.2.1.1.4.1', #0 normal, 1 noComm, 2, fanFail, 3 overTemp, 4 nvmfail, 5 outOfBalance 'towerProductSN' : '1.3.6.1.4.1.1718.3.2.1.1.6.1', 'towerModelNumber' : '1.3.6.1.4.1.1718.3.2.1.1.7.1', } #get number of outputs snmpDevice = lib_SNMP.SNMPv2(self.ipaddr) outletCount = snmpDevice.readSNMP(self.getDataDict['infeedOutletCount']) #loop over outlets if outletCount is not None: for x in range(1, int(outletCount) + 1): self.getDataDict["outlet" + str(x)] = {} self.getDataDict["outlet" + str(x)]['ID'] = '1.3.6.1.4.1.1718.3.2.3.1.2.1.1.' + str(x) self.getDataDict["outlet" + str(x)]['name'] = '1.3.6.1.4.1.1718.3.2.3.1.3.1.1.' + str(x) self.getDataDict["outlet" + str(x)]['status'] = '1.3.6.1.4.1.1718.3.2.3.1.5.1.1.' + str(x) #0 off, 1 on, 2 offWait, 3 onWait, 4 offError, 5 On Error, 6nocomm, 7 reading, 8 offFuse, 9 onFuse self.getDataDict["outlet" + str(x)]['controlState'] = '1.3.6.1.4.1.1718.3.2.3.1.10.1.1.' + str(x) #0 idleOff, 1 idleOn, 2 wakeOff, 3 wakeOn, 4 off, 5 on, 6 lockedOff, 7 lockedOn, 8 reboot, 9 shutdown, 10 pendOn, 11 pendOff, 12 minimumOff, 13 minimumOn, 14 eventOff, 15 eventOn, 16 eventReboot, 17 eventShutdown
def SNMPBlockages(self): getDataDict = { #'BlockingzoneIndex' : '1.3.6.1.4.1.33721.3.1.15.1.1.1.1', 'BlockingzoneEnabled': '1.3.6.1.4.1.33721.3.1.15.1.1.2', 'BlockingzoneType': '1.3.6.1.4.1.33721.3.1.15.1.1.3', 'BlockingzoneStart': '1.3.6.1.4.1.33721.3.1.15.1.1.4', 'BlockingzoneEnd': '1.3.6.1.4.1.33721.3.1.15.1.1.5', 'BlockingzoneLow': '1.3.6.1.4.1.33721.3.1.15.1.1.6', 'BlockingzoneHigh': '1.3.6.1.4.1.33721.3.1.15.1.1.6', } #get number of outputs snmpDevice = lib_SNMP.SNMPv2( self.INI.getOption(self.deviceDescr, self.devNumber, "IP")) #BlockingzoneIndexes = snmpDevice.readSNMP(self.getDataDict['BlockingzoneIndex']) result = {} for x in range(1, 9): try: result["blockzone" + str(x)] = {} enabledList = ["", "DISABLE", "ENABLE"] zoneList = ["", "TxAllowed", "TxProhibited"] temp = snmpDevice.readSNMP(getDataDict['BlockingzoneEnabled'] + "." + str(x)) result["blockzone" + str(x)]["Status"] = enabledList[int(temp)] temp = snmpDevice.readSNMP(getDataDict['BlockingzoneType'] + "." + str(x)) result["blockzone" + str(x)]["Type"] = zoneList[int(temp)] temp = snmpDevice.readSNMP(getDataDict['BlockingzoneStart'] + "." + str(x)) result["blockzone" + str(x)]["AzStart"] = "{0:.3f}".format( float(temp) / 1000) temp = snmpDevice.readSNMP(getDataDict['BlockingzoneEnd'] + "." + str(x)) result["blockzone" + str(x)]["AzEnd"] = "{0:.3f}".format( float(temp) / 1000) temp = snmpDevice.readSNMP(getDataDict['BlockingzoneLow'] + "." + str(x)) result["blockzone" + str(x)]["ElStart"] = "{0:.3f}".format( float(temp) / 1000) temp = snmpDevice.readSNMP(getDataDict['BlockingzoneHigh'] + "." + str(x)) result["blockzone" + str(x)]["ElEnd"] = "{0:.3f}".format( float(temp) / 1000) except: pass del snmpDevice return result
def __init__(self, INI, deviceDescr, devNumber): self.Error = False self.log = lib_Log.Log(PrintToConsole=True) #for inhiretance from device class self.INI = INI self.deviceDescr = deviceDescr self.devNumber = devNumber self.log.increaseLevel() self.ipaddr = self.INI.getOption(self.deviceDescr, self.devNumber, "IP") self.getDataDict = { #'sysDescr' : '1.3.6.1.2.1.1.1.0', 'sysUpTime': '1.3.6.1.2.1.1.3.0', #'sysContact' : '1.3.6.1.2.1.1.4.0', 'sysName': '1.3.6.1.2.1.1.5.0', #'sysLocation' : '1.3.6.1.2.1.1.6.0', 'outletCount': '1.3.6.1.4.1.318.1.1.12.1.8.0', #'1.3.6.1.4.1.318.1.1.4.5.1.0', #Num of Outputs 'loadStatusCurrent': '1.3.6.1.4.1.318.1.1.12.2.3.1.1.2.1', #phase/bank load measured in tenths of Amps 'HardwareRev': '1.3.6.1.4.1.318.1.1.12.1.2.0', 'FirmwareRev': '1.3.6.1.4.1.318.1.1.12.1.3.0', 'DateOfManufacture': '1.3.6.1.4.1.318.1.1.12.1.4.0', 'ModelNumber': '1.3.6.1.4.1.318.1.1.12.1.5.0', 'SerialNumber': '1.3.6.1.4.1.318.1.1.12.1.6.0', 'DeviceRating': '1.3.6.1.4.1.318.1.1.12.1.7.0', #max amps 'SerialNumber': '1.3.6.1.4.1.318.1.1.12.1.6.0', 'DevicePowerWatts': '1.3.6.1.4.1.318.1.1.12.1.16.0', 'DevicePowerVA': '1.3.6.1.4.1.318.1.1.12.1.18.0', } #get number of outputs snmpDevice = lib_SNMP.SNMPv2(self.ipaddr) outletCount = snmpDevice.readSNMP(self.getDataDict['outletCount']) #loop over outlets if outletCount is not None: for x in range(1, int(outletCount) + 1): self.getDataDict["outlet" + str(x)] = {} # self.getDataDict["outlet" + str(x)]['ID'] = '1.3.6.1.4.1.1718.3.2.3.1.2.1.1.' + str(x) self.getDataDict["outlet" + str( x)]['name'] = '1.3.6.1.4.1.318.1.1.12.3.5.1.1.2.' + str(x) self.getDataDict["outlet" + str(x)][ 'status'] = '1.3.6.1.4.1.318.1.1.12.3.5.1.1.4.' + str(x) #
def getsnmpinfo(self): result = {} SNMPDevice = lib_SNMP.SNMPv2(self.ipaddr) for keyword in self.getDataDict: if isinstance(self.getDataDict[keyword], dict): result[keyword] = {} for option in self.getDataDict[keyword]: result[keyword][option] = SNMPDevice.readSNMP( self.getDataDict[keyword][option]) else: if not "General" in result: result["General"] = {} result["General"][keyword] = SNMPDevice.readSNMP( self.getDataDict[keyword]) result = self.SnmpDataCleanup(result) return result
def SNMPData(self): snmpDevice = lib_SNMP.SNMPv2( self.INI.getOption(self.deviceDescr, self.devNumber, "IP")) getDataDict = { 'SoftwareVersion': '1.3.6.1.4.1.33721.3.1.1.4.0', 'ACUName': '1.3.6.1.4.1.33721.3.1.1.3.0', 'ACUSerial': '1.3.6.1.4.1.33721.3.1.1.2.0', 'AntennaName': '1.3.6.1.4.1.33721.3.1.1.13.0', 'AntennaSerial': '1.3.6.1.4.1.33721.3.2.2.1.7000.3.4.0', 'SatelliteName': '1.3.6.1.4.1.33721.3.2.2.1.7090.1.1.0', 'SatelliteLongitude': '1.3.6.1.4.1.33721.3.2.2.1.7090.2.2.0', 'SatelliteSkew': '1.3.6.1.4.1.33721.3.2.2.1.7090.1.4.0', 'SatelliteRxPol': '1.3.6.1.4.1.33721.3.2.2.1.7090.2.9.0', 'SatelliteTxPol': '1.3.6.1.4.1.33721.3.2.2.1.7090.2.10.0', 'SatelliteElevationCutOff': '1.3.6.1.4.1.33721.3.2.2.1.7090.1.5', 'Down_Translation': '1.3.6.1.4.1.33721.3.2.2.1.7090.2.4.0', 'RxIfFreq': '1.3.6.1.4.1.33721.3.2.2.1.7090.2.11.0', 'HuntFrequency': '1.3.6.1.4.1.33721.3.2.2.1.7090.2.5.0', 'Up_Translation': '1.3.6.1.4.1.33721.3.2.2.1.7090.2.7.0', 'TxIfFreq': '1.3.6.1.4.1.33721.3.2.2.1.7090.2.6.0', 'TransmitFrequency': '1.3.6.1.4.1.33721.3.2.2.1.7090.2.8.0', 'Heading': '1.3.6.1.4.1.33721.3.1.3.3.1.4.0', 'RelativeAz': '1.3.6.1.4.1.33721.3.1.14.1.0', 'Elevation': '1.3.6.1.4.1.33721.3.1.14.2.0', 'RelativePol': '1.3.6.1.4.1.33721.3.1.14.3.0', 'Latitude': '1.3.6.1.4.1.33721.3.1.3.1.1.2.0', 'Longitude': '1.3.6.1.4.1.33721.3.1.3.1.1.3.0', 'AntennaStatus': '1.3.6.1.4.1.33721.3.2.2.1.7090.2.1.0', 'signalstrength': '1.3.6.1.4.1.33721.3.2.2.1.7000.4.1.0', } result = {} result["General"] = {} for item in getDataDict: try: result["General"][item] = snmpDevice.readSNMP( getDataDict[item]) except: pass if "SatelliteLongitude" in result["General"]: result["General"]["SatelliteLongitude"] = "{0:.1f}".format( float(result["General"]["SatelliteLongitude"]) / 1000) if "Heading" in result["General"]: result["General"]["Heading"] = "{0:.1f}".format( float(result["General"]["Heading"]) / 1000) if "RelativeAz" in result["General"]: result["General"]["RelativeAz"] = "{0:.1f}".format( float(result["General"]["RelativeAz"]) / 1000) if "Elevation" in result["General"]: result["General"]["Elevation"] = "{0:.1f}".format( float(result["General"]["Elevation"]) / 1000) if "RelativePol" in result["General"]: result["General"]["RelativePol"] = "{0:.1f}".format( float(result["General"]["RelativePol"]) / 1000) if "Latitude" in result["General"]: result["General"]["Latitude"] = "{0:.6f}".format( float(result["General"]["Latitude"]) / 1000000) if "Longitude" in result["General"]: result["General"]["Longitude"] = "{0:.6f}".format( float(result["General"]["Longitude"]) / 1000000) del snmpDevice return result
def GetData(self): #== INIT ====================================== self.log.printBoldInfo('Initialize SNMP Object') self.log.increaseLevel() snmpDevice = lib_SNMP.SNMPv2(self.ipaddr) data = {} self.log.decreaseLevel() #== SNMPv2 MIB ================================ self.log.printBoldInfo('SNMPv2') self.log.increaseLevel() self.log.printInfo('Do basic walk (no table)') snmpV2Result = snmpDevice.getWalk_SNMPv2MIB() self.log.printInfo('Merge with previous data') snmpDevice.dictMerge( data, {'General': snmpDevice.getFormattedDictionary(snmpV2Result)}) self.log.decreaseLevel() #== ENTITY MIB ================================ self.log.printBoldInfo('Entity MIB') self.log.increaseLevel() self.log.printInfo('Init table') snmpDevice.initTable('entitymib').presetEntityMib() self.log.printInfo('Get table over SNMP') snmpDevice.fillTable('entitymib') self.log.printInfo('Keep only main entity (highest parent/child)') snmpDevice.getTable('entitymib').filterBySnmpObject( -1, lib_SNMP.SnmpTable.FILTER_KEEP, lib_SNMP.SnmpTable.FILTER_BY_RAWVALUE, 'entPhysicalParentRelPos') self.log.printInfo('Remove not needed columns') snmpDevice.getTable('entitymib').filterByTag( ['entPhysicalParentRelPos', 'entPhysicalClass'], lib_SNMP.SnmpTable.FILTER_REMOVE) self.log.printInfo('Format result') entMib, indexMappingEntMib = snmpDevice.getTable( 'entitymib').getFormattedDictionary(snmpDevice, None) self.log.printInfo('Change to "General"-module') entMib['General'] = entMib.pop(entMib.keys()[0]) self.log.printInfo('Merge with previous data') snmpDevice.dictMerge(data, entMib) self.log.decreaseLevel() #== QBRIDGE =================================== self.log.printBoldInfo('QBRIDGE-MIB') self.log.increaseLevel() self.log.printInfo('Init table') snmpDevice.initQBridgeTable('qbridge').presetQBrideMib_VlanBased() self.log.printInfo('Get table over SNMP') snmpDevice.fillTable('qbridge') self.log.printInfo('Get VLAN info per interface') interfaceVlanInfoTable = snmpDevice.getTable( 'qbridge').getInterfaceVlanInfoTable() #self.log.printInfo('Keep only real interfaces') #snmpDevice.getTable('qbridge').filterBySnmpObject( # snmpDevice.textualConversionToValue('ifMib_IANAifType', 'ethernetCsmacd'), # lib_SNMP.SnmpTable.FILTER_KEEP, # lib_SNMP.SnmpTable.FILTER_BY_RAWVALUE, # 'ifType' # ) self.log.printInfo('Remove not needed columns') snmpDevice.getTable('qbridge').filterByTag( ['dot1qVlanCurrentEgressPorts', 'dot1qVlanCurrentUntaggedPorts'], lib_SNMP.SnmpTable.FILTER_REMOVE) #remove not-needed columns self.log.printInfo('Format result') qbridge, indexMapping2 = snmpDevice.getTable( 'qbridge').getFormattedDictionary(snmpDevice, None, modulePrefix='vlan') self.log.printInfo('Merge with previous data') snmpDevice.dictMerge(data, qbridge) self.log.decreaseLevel() #== IF MIB ==================================== self.log.printBoldInfo('IF-MIB') self.log.increaseLevel() self.log.printInfo('Init table') snmpDevice.initTable('ifmib').presetIfMib() self.log.printInfo('Merge with VLAN Info') snmpDevice.getTable('ifmib').table = interfaceVlanInfoTable self.log.printInfo('Get table over SNMP') snmpDevice.fillTable('ifmib') self.log.printInfo('Keep only real interfaces') snmpDevice.getTable('ifmib').filterBySnmpObject( snmpDevice.textualConversionToValue('ifMib_IANAifType', 'ethernetCsmacd'), lib_SNMP.SnmpTable.FILTER_KEEP, lib_SNMP.SnmpTable.FILTER_BY_RAWVALUE, 'ifType') self.log.printInfo('Remove not needed columns') snmpDevice.getTable('ifmib').filterByTag( ['ifType', 'ifSpeed', 'ifIndex'], lib_SNMP.SnmpTable.FILTER_REMOVE) #remove not-needed columns self.log.printInfo('Format result, use "ifName" as moduleName') ifMib, indexMapping = snmpDevice.getTable( 'ifmib').getFormattedDictionary(snmpDevice, 'ifName') self.log.printInfo('Merge with previous data') snmpDevice.dictMerge(data, ifMib) self.log.decreaseLevel() #== POWER OVER ETHERNET (Interfaces) ========== self.log.printBoldInfo('Power Over Ethernet (interfaces)') self.log.increaseLevel() self.log.printInfo('Init table') snmpDevice.initTable('peth').presetPowerEthernetMib() self.log.printInfo('Get table over SNMP') snmpDevice.fillTable('peth') self.log.printInfo('Checking if index remapping is needed') indexMappingRemapped = indexMapping.copy() if not (data.get('General', {}).get('entPhysicalDescr', '').find('C2960') == -1): self.log.increaseLevel() self.log.printInfo( 'Catalyst 2960 Found, rebuilding index mapping for PoE') for index, value in indexMapping.items(): indexInt = int(index) indexLowered = (indexInt - 10000) if (indexInt > 10000) else indexInt indexMappingRemapped.update({str(indexLowered): value}) self.log.decreaseLevel() self.log.printInfo( 'Format result, use "ifName" as moduleName (re-use indexmapping from IF-MIB)' ) peth, indexMapping2 = snmpDevice.getTable( 'peth').getFormattedDictionary(snmpDevice, indexMappingRemapped) self.log.printInfo('Merge with previous data') snmpDevice.dictMerge(data, peth) self.log.decreaseLevel() #== POWER OVER ETHERNET (Group) =============== self.log.printBoldInfo('Power Over Ethernet (group)') self.log.increaseLevel() self.log.printInfo('Init table') snmpDevice.initTable('pethGrp').presetPowerEthernetGroupMib() self.log.printInfo('Get table over SNMP') snmpDevice.fillTable('pethGrp') self.log.printInfo('Format result') pethGrp, indexMapping2 = snmpDevice.getTable( 'pethGrp').getFormattedDictionary(snmpDevice, {'1': 'PoEGroup1'}) self.log.printInfo('Merge with previous data') snmpDevice.dictMerge(data, pethGrp) self.log.decreaseLevel() #== RETURNING RESULT ========================== sqlArray = {} sqlArray[self.deviceDescr] = {} sqlArray[self.deviceDescr][self.devNumber] = data sqlArray[self.deviceDescr][self.devNumber]["_ExtractInfo"] = {} sqlArray[self.deviceDescr][ self.devNumber]["_ExtractInfo"]["ExtractTime"] = time.time() sqlArray["ReadError"] = False return sqlArray """ test.filterBySnmpObject( 6, lib_SNMP.SNMPTable.FILTER_KEEP, lib_SNMP.SNMPTable.FILTER_BY_RAWVALUE, '.1.3.6.1.2.1.2.2.1.3', ) test.filterByTag('.1.3.6.1.2.1.2.2.1.3', lib_SNMP.SNMPTable.FILTER_REMOVE) #test.filterByTag([".1.3.6.1.2.1.2.2.1.2", ".1.3.6.1.2.1.2.2.1.8"], lib_SNMP.SNMPTable.FILTER_KEEP) pprint.pprint(test.getFormattedDictionary('.1.3.6.1.2.1.31.1.1.1.1')) """ '''