Jump to content

REQUEST: Does anyone have a script that can pull through Toner Levels?


Recommended Posts

Posted (edited)

We currently have a page with all our network printers, reporting whether they are up/down etc:

 

http://i45.tinypic.com/30ksk8i.jpg

 

I was wondering if anyone had ever seen a script that could pull through the toner levels via SNMP?

 

Spiceworks, Nagios and Print Limit pro manage it, but i would love to add it to our printer page, Print Limit Pro gives us:

 

http://i47.tinypic.com/64p841.jpg

 

So if I could code the script into our status page to look like this it would be awesome:

 

http://i49.tinypic.com/9atg85.jpg

 

Many thanks in advance :)

Edited by burgemaster
Posted (edited)

I have found this script for Nagios? Could it work or be converted for IIS somehow? Looks like a BASH script?

 

:)

 

 

#!/bin/bash

#

#check_toner version 0.3

#

#01-26-2009, Henry Franco

#

# This plugin will check the black toner level on a printer via SNMP.

# The plugin returns warning and critical status when the toner

# drops below $CRIT AND $WARN.

 

 

if [ $# -lt 1 ]; then

echo "Usage: ./check_toner PRINTER_NAME"

exit 127

fi

 

HOST=$1

INK="Black ink available:"

CRIT=5

WARN=10

STATUS=0

 

# GET THE MAXIMUN CAPACITY VALUE FROM SNMP

max_level=`snmpwalk -O qv -v 2c -c public $HOST mib-2.43.11.1.1.8.1.1`

RES=$?

 

# GET CURRENT SUPPLY LEVEL FROM SNMP

current_level=`snmpwalk -O qv -v 2c -c public $HOST mib-2.43.11.1.1.9.1.1`

RES=$?

 

#BAIL OUT IF ANYTHING WENT WRONG

if [ $RES != 0 ]; then

INK="Toner Unknown - SNMP problem. No data received from host.";

echo $INK;

STATUS=3;

exit $STATUS;

fi

 

#CALCULATE TONER LEVEL

result=$(echo "scale=2; $current_level / $max_level;" | bc)

 

#ACTUAL VALUE OF TONER SUPPLY

percent=`echo "$result"*"100"/"1"|bc`

 

#CHECK WARNING AND CRITICAL LEVELS

if [ $percent -le $CRIT ]; then

echo "Toner Critical - "$INK $percent"%";

STATUS=2

elif [ $percent -le $WARN ]; then

echo "Toner Warning - "$INK $percent"%";

STATUS=1

else

echo "Toner OK - "$INK $percent"%";

fi

 

exit $STATUS

Edited by burgemaster
Posted

With SNMPWALK.exe I can pull through the max capacity and then the Supply level from the printers:

 

(Browse net-snmp Files on SourceForge.net)

 

really simple batch script:

snmpwalk -O qv -v 2c -c public PRINTER_IP mib-2.43.11.1.1.8.1.1

snmpwalk -O qv -v 2c -c public PRINTER_IP mib-2.43.11.1.1.9.1.1

pause

 

This gives me on this printer:

max = 700 and level = 686

which = 98% (which is correct in the printers webmin)

 

 

I dont have the coding/scripting skills to take this any further :(

Posted
Interesting, you should have a look to see if papercut can do this as printlimit pro is just papercut rebranded and a few versions behind papercuts releases (to date 9 minor releases and 1 major i think) so perhaps the added funtionality is available. Something to look at anyway. I'm not sure (as i have not looked at it) but perhaps advanced scripting will do what you want Chapter 17. Advanced Scripting
Posted
Interesting, you should have a look to see if papercut can do this as printlimit pro is just papercut rebranded and a few versions behind papercuts releases (to date 9 minor releases and 1 major i think) so perhaps the added funtionality is available. Something to look at anyway. I'm not sure (as i have not looked at it) but perhaps advanced scripting will do what you want Chapter*17.*Advanced Scripting

 

Hi,

thanks for this, yes papercut and PLP are the same, and do both do this. Im being lazy and would like to pull the data pulled into my network status pages instead of having to log in to PLP and check etc.

Posted
If you could see your way to installing perl on the IIS system... plexer and I have had a go at this in the past :) Could probably be done in ASP or some such but I don't likee.
Posted
If you could see your way to installing perl on the IIS system... plexer and I have had a go at this in the past :) Could probably be done in ASP or some such but I don't likee.

 

Must add that to my todo list, release the perl that we created. :)

  • 1 year later...
Posted
Did anyone manage to do this?

 

Write some kind of add-on for Print Limit Pro you mean? If you have the documentation, what form does it expect add-ons to take? Executables of some sort that return formatted text via STDOUT?

Posted

Just wondered if anyone had managed to get the toner levels to show via a web interface like how the original poster wanted. We have PCounter which we can see individual toner levels but I cant seem to get a report for all toner levels.

 

Michael

Posted
Just wondered if anyone had managed to get the toner levels to show via a web interface like how the original poster wanted.

 

The above script should cover pretty much everything you need - it simply parses the output from snmpwalk (which, if I Google correctly, is available as part of the Net-SNMP package in Linux or simply as an .EXE under Windows), so you could write a script to output to a simple HTML page easily enough. You wouldn't even really need a web server, you could just dump the HTML file on a file share somewhere, have it update every hour or so.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...