I am trying to retrieve printer toner information from networked printers.
I found the following reference record for printer supplies -> http://oidref.com/1.3.6.1.2.1.43.11 (OID = prtMarkerSupplies)
I tried integrating the OID in the following code:
from pysnmp.hlapi import *
iterator = getCmd(
SnmpEngine(),
CommunityData('public', mpModel=0),
UdpTransportTarget(('here goes ip of a printer', 161)),
ContextData(),
ObjectType(ObjectIdentity('SNMPv2-MIB', "prtMarkerSupplies", 0))
)
errorIndication, errorStatus, errorIndex, varBinds = next(iterator)
if errorIndication:
print(errorIndication)
elif errorStatus:
print('%s at %s' % (errorStatus.prettyPrint(),
errorIndex and varBinds[int(errorIndex) - 1][0] or '?'))
else:
for varBind in varBinds:
print(' = '.join([x.prettyPrint() for x in varBind]))
The above code returns:
pysnmp.smi.error.SmiError: No symbol SNMPv2-MIB::prtMarkerSupplies at <pysnmp.smi.builder.MibBuilder object at 0x000001F8D1FC3D00>
How can I retrieve toner information using the SNMP protocol and pysnmp?
Retrieving system information works as intended:
ObjectType(ObjectIdentity('SNMPv2-MIB', "sysDescr", 0))
I used the answer from the following thread -> snmpwalk with PySNMP
Instead of iterating over getCmd, I used SNMP walk to walk through all of the OIDs.