Skip to content

Printer Monitoring Project

jclyons edited this page Apr 9, 2012 · 9 revisions

Now that Dashboard is up and running, we need a way to get more data into our Dashboard "Recently" feed. One important area in which we need real-time data is campus printing. We need a way to periodically check the state of toner levels and tray empty (no paper) statuses on the printers.

All the SNMP commands that will extract the toner information from the printers are at the following link: http://mwiki.yyovkov.net/index.php/SNMPHelp:SNMP_Mibs_for_(HP)_Printers

The script needs to do the following:

  1. Check a printer for these values by using the commands listed in the link above, substituting the printer's IP for our IP.

  2. Convert the value for toner to a percentage. The percentage is the ratio of the remaining number of pages over the max number of pages.

  3. Put toner percentage into a single json array along with the id of the printer(we'll use the printer's domain name, for example QAC-HP4015-BW.class.wesleyan.edu

  4. Post it as a JSON document to a couchdb database. I will work on getting Dashboard to listen to this database and pull changes into its feed instantly.

It should take no more than three days to write this script in bash, ruby, python, or (preferably) in JavaScript using Node.js. It should be no more than 50 lines of code.

Also, don't worry about the tray empty status for now. We can work on that afterwards.

If you do choose to do it in Javascript you need to learn how to use Node.js. Node.js is an Asynchronous server-side javascript platform based on Google's lightning-fast V8 engine. You can use the Node.js 'exec' function as demonstrated in http://snippets.dzone.com/posts/show/12069' to execute the snmpget command. You can use the "felix-couchdb" module to the post the resulting Javascript hash to CouchDB. (Remember: JSON is really just a Javascript object expressed in string form, which is why it makes sense to write this in Javascript.)

However, if you feel that Javascript would take too long, please write it in whatever language is fastest for you. I'm going to be presenting Dashboard to ITS next week and I would really like to be able to say that I have this feature working.

Due Date: 10 days from now.