Get printer status with SNMP using Pysnmp
<p>I try to get status from my printer using SNMP protocol
The problem is, I've never used the SNMP and I have trouble understanding how can I get my status like ( PAPER OUT, RIBBON OUT etc... ).</p>

<p>I configured my printer to enable the SNMP protocol using the community name "public"<br>
I presume SNMP messages are sended on the port 161</p>

<p>I'm using Pysnmp because I want to integrate the python script in my program to listen my printer and display a status if there is a problem with the printer.</p>

<p>For now I've tried this code :</p>

<pre><code>import socket
import random
from struct import pack, unpack
from datetime import datetime as dt
from pysnmp.entity.rfc3413.oneliner import cmdgen
from pysnmp.proto.rfc1902 import Integer, IpAddress, OctetString


ip = '172.20.0.229'
community = 'public'
value = (1,3,6,1,2,1,25,3,5,1,2)

generator = cmdgen.CommandGenerator()
comm_data = cmdgen.CommunityData('server', community, 1)  # 1 means version SNMP v2c
transport = cmdgen.UdpTransportTarget((ip, 161))

real_fun = getattr(generator, 'getCmd')
res = (errorIndication, errorStatus, errorIndex, varBinds) \
    = real_fun(comm_data, transport, value)

if not errorIndication is None or errorStatus is True:
    print "Error: %s %s %s %s" % res
else:
    print "%s" % varBinds
</code></pre>

<p>The ip address is the ip of my printer
The problem is the OID : I don't know what to put in the OID field because I have trouble understanding how does OID works.</p>

<p>I found this page but i'm not sure it fit with all printers ==> <a href="https://secure.n-able.com/webhelp/NC_7-2-0_Cust_en/Content/N-central/Services/Services_PrinterStatus.html" rel="nofollow">click here</a></p>

<p>You need your printer specific MIB file in common case. E.g., printer in my office seems to be not support both oids by your link. Also you can use <code>snmpwalk</code> to get available oids and values on your printer and if you somehow understand which values you need, you can use it for specific instance of your printer.</p>

python snmp zebra