coolingDeviceReading1 = DellRoot1 + '.10892.1.700.12.1.6.1.1' # fails - PyASN1 requires integer OID
coolingDeviceReading2 = DellRoot2 + '.10892.1.700.12.1.6.1.1'

leaves = [sysName3, coolingDeviceReading2]

roots = [sysRoot2, coolingDeviceRoot2]

# Setup objects to connect to SNMP on localhost
cg = cmdgen.CommandGenerator()
authData = cmdgen.CommunityData('my-agent', 'public', 0)
transTarget = cmdgen.UdpTransportTarget(('localhost', 161))

# Loop through all the leaves
for leaf in leaves:
    print 'leaf is ' + leaf
    errorIndication, errorStatus, errorIndex, result = cg.getCmd(authData, transTarget, rfc1155.ObjectName(leaf))
    if errorIndication == None and len(result) > 0 and not isinstance(result[-1][1], univ.Null) :
        print 'result is ', result
    else:
        print 'Failed to get value for leaf ' + leaf, result

print ' '

# Loop through all the roots
for root in roots:
    print 'root is ' + root
    errorIndication, errorStatus, errorIndex, result = cg.nextCmd(authData, transTarget, rfc1155.ObjectName(root))
    if errorIndication == None and len(result) > 0:
        print 'result is ', result
    else:
        print 'Failed to get value for root ' + root, result
Example #2
0
class VarBind(univ.Sequence):
    componentType = namedtype.NamedTypes(
        namedtype.NamedType('name', rfc1155.ObjectName()),
        namedtype.NamedType('value', rfc1155.ObjectSyntax()))
Example #3
0
# Imported just in case new ASN.1 types would be created
from pyasn1.type import constraint, namedval
from pysnmp.proto import rfc1155

# Imports

(
    Integer,
    ObjectIdentifier,
    OctetString,
) = mibBuilder.importSymbols("ASN1", "Integer", "ObjectIdentifier",
                             "OctetString")
#( ObjectName, ) = mibBuilder.importSymbols("RFC1155", "ObjectName")
ObjectName = rfc1155.ObjectName()
(
    Bits,
    Integer32,
    MibIdentifier,
    TimeTicks,
) = mibBuilder.importSymbols("SNMPv2-SMI", "Bits", "Integer32",
                             "MibIdentifier", "TimeTicks")

(MibIdentifier, MibScalar, MibTableColumn, MibTableRow,
 MibTable) = mibBuilder.importSymbols(
     'SNMPv2-SMI',
     'MibIdentifier',
     'MibScalar',
     'MibTableColumn',
     'MibTableRow',
     'MibTable',
 )