Querying printer status via SNMP and PHP

Wednesday 18 October 2017 at 10:02 am

Background - my work (a college) migrated to a centralised printing system using about 15 multi-function Samsung printers.  As a support tech I wanted a single view which reported consumables and error statuses so we could see at a glance where supplies are low (only us technicians are allowed to replenish toner & paper).  Samsung do their own client software but I could never get it to work how I wanted.  This is what my page looks like (I've obliterated the name/location info for privacy):


Here's how I did it...

First I used a program called Frameflow SNMP browser to connect to a printer to find the SNMP OINs I needed.  This was the tricky bit.  There are 100s of OINs, and by trial and error I found the right ones to build my script.  I worked out that paper levels are reported as a figure ouf of 520 (presumably the tray capacity in pages).  When calculated as a percentage they report at 100, 70, 30 and 10%.  Toners are reported out of 30000 and our black high-capacity cartridges are out of 45000.  The PHP in the script calculates these as percentages for reporting.

I had to Google the OINs because Frameflow reported the names differently to what's needed by PHP SNMPGET, so for example ".iso.org.dod.internet.mgmt.mib-" translates to "".  You can see there's a pattern.

In summary, the PHP gets a list of IPs, then queries each one for name/location/serial/toner and paper figures and prints this out on a web page.  Some fancy JQuery stuff (I don't pretend to know anything about this, I roped in our web developer for that) makes the nice progress bars.  The web page auto-refreshes every 60 seconds, and there's a 'last updated' timestamp and a countdown to the next update.  The background colour of each machine changes from green to amber to red depending on the printer's reported status.   I run it on a dedicated old laptop, running it in IE's kiosk mode and starting/stopping it on a scheduled task.  It fires up at 8am, then goes to sleep at 5pm.

I can't seem to display code very effectively on this website, so I've printed the code pages to pdfs if you want to download:

PHP main page
CSS stylesheet
JS countdown script

 webpage  frameflow  ink  paper