(self, oid, host, port, community)
return ret
Perform an SNMP walk on a given OID
Perform an SNMP walk on a given OID
Perform an SNMP walk on a given OID
def walk(self, oid, host, port, community):
        """
        Perform an SNMP walk on a given OID
        """
        # Initialize return value
        ret = {}

        # Convert OID to tuple if necessary
        if not isinstance(oid, tuple):
            oid = self._convert_to_oid(oid)

        # Convert Host to IP if necessary
        host = socket.gethostbyname(host)

        # Assemble SNMP Auth Data
        snmpAuthData = cmdgen.CommunityData(
            'agent-{}'.format(community),
            community)

        # Assemble SNMP Transport Data
        snmpTransportData = cmdgen.UdpTransportTarget(
            (host, port),
            int(self.config['timeout']),
            int(self.config['retries']))

        # Assemble SNMP Next Command
        resultTable = self.snmpCmdGen.nextCmd(snmpAuthData,
                                              snmpTransportData,
                                              oid)
        varBindTable = resultTable[3]

        # TODO: Error Check

        for varBindTableRow in varBindTable:
            for o, v in varBindTableRow:
                ret[str(o)] = v.prettyPrint()

        return ret
def walk ( self , oid , host , port , community ) : # Initialize return value ret = { } # Convert OID to tuple if necessary if not isinstance ( oid , tuple ) : oid = self . _convert_to_oid ( oid ) # Convert Host to IP if necessary host = socket . gethostbyname ( host ) # Assemble SNMP Auth Data snmpAuthData = cmdgen . CommunityData ( 'agent-{}' . format ( community ) , community ) # Assemble SNMP Transport Data snmpTransportData = cmdgen . UdpTransportTarget ( ( host , port ) , int ( self . config [ 'timeout' ] ) , int ( self . config [ 'retries' ] ) ) # Assemble SNMP Next Command resultTable = self . snmpCmdGen . nextCmd ( snmpAuthData , snmpTransportData , oid ) varBindTable = resultTable [ 3 ] # TODO: Error Check for varBindTableRow in varBindTable : for o , v in varBindTableRow : ret [ str ( o ) ] = v . prettyPrint ( ) return ret