SNMP Printer Billing

So this is something iv been playing with recently, SNMP or the “Simple Network Management Protocol” is a Protocol that was created in 1988 and seems to have really taken off since then being included in most printers, switches, routers and other network devices.  Depending on the device it seems to offer a wide range of information using the command snmpwalk on a mac or other linux / unix system will let you look at what information that device offers over the protocal

snmpwalk -c public ip on your network

You can get some other IP’s on your network by running arp -a

Anyways,  so that’s pretty cool but what good is it if it doesn’t do anything?  So here’s my use case for it,  at the company I work at we have printers, like 14 printers and they are all leased because of the way we lease them we need to supply the company with how many “impressions” are printed (I’m not sure what an impression is but it seems like its either 1 page or more likely one inch of printing.)  The printers we have are xerox printers and its in the spec that they (and most printers it sounds like) record the impressions they make in the MIB or the management information base,  which from the look at it looks to be a hierarchical tree that happens to store the printers information about just random stuff.  Its all arranged by OIDs or object identifiers which happen to be quarry able threw SNMP FTW!

Fun scripting time,  So this is what I came up with

touch meterreads.txt

Echo Printer billing meters report >> meterreads.txt

date >> meterreads.txt

echo  ________________________________________________________________ >> meterreads.txt

Echo MX4357765 Xerox WorkCentre 7845 >> meterreads.txt

Echo black impressions >> meterreads.txt

snmpwalk -c public . >> meterreads.txt

Echo Color impressions >> meterreads.txt

sleep 10

snmpwalk -c public . >> meterreads.txt


This gets me a txt file named meterreads.txt that’s first line contains the name of the report the date a line to break up the confusion then the name of the printer and then finally a query that will spit out the black and color impressions data from the printers MIB.

The output looks something like this…

printer billing meters report

Mon Aug  8 08:47:00 PDT 2016


MX4357765 Xerox WorkCentre 7845

black impressions

SNMPv2-SMI::enterprises. = INTEGER: 29466

Color impressions

SNMPv2-SMI::enterprises. = INTEGER: 50722


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s