+ Post New Thread
Results 1 to 13 of 13
Scripts Thread, REQUEST: Does anyone have a script that can pull through Toner Levels? in Coding and Web Development; We currently have a page with all our network printers, reporting whether they are up/down etc: I was wondering if ...
  1. #1

    Join Date
    Aug 2007
    Posts
    827
    Thank Post
    101
    Thanked 65 Times in 47 Posts
    Rep Power
    26

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

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



    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:



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



    Many thanks in advance
    Last edited by burgemaster; 25th February 2010 at 11:50 AM.

  2. #2

    Join Date
    Aug 2007
    Posts
    827
    Thank Post
    101
    Thanked 65 Times in 47 Posts
    Rep Power
    26
    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
    Last edited by burgemaster; 25th February 2010 at 12:26 PM.

  3. #3

    Join Date
    Aug 2007
    Posts
    827
    Thank Post
    101
    Thanked 65 Times in 47 Posts
    Rep Power
    26
    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

  4. #4

    Join Date
    Feb 2010
    Location
    Hampshire
    Posts
    31
    Thank Post
    0
    Thanked 1 Time in 1 Post
    Rep Power
    0
    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 Chapter17.Advanced Scripting

  5. #5

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,906
    Thank Post
    3,433
    Thanked 1,084 Times in 1,000 Posts
    Rep Power
    370
    a web page I found with a bunch of possibly useful info

    Hacking Network Printers (Mostly HP JetDirects, but a little info on the Ricoh Savins)

  6. Thanks to mac_shinobi from:

    burgemaster (27th February 2010)

  7. #6

    Join Date
    Aug 2007
    Posts
    827
    Thank Post
    101
    Thanked 65 Times in 47 Posts
    Rep Power
    26
    Quote Originally Posted by fiona_b View Post
    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.

  8. #7


    tom_newton's Avatar
    Join Date
    Sep 2006
    Location
    Leeds
    Posts
    4,485
    Thank Post
    867
    Thanked 854 Times in 675 Posts
    Rep Power
    197
    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.

  9. #8

    plexer's Avatar
    Join Date
    Dec 2005
    Location
    Norfolk
    Posts
    13,609
    Thank Post
    729
    Thanked 1,688 Times in 1,502 Posts
    Rep Power
    433
    Quote Originally Posted by tom_newton View Post
    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.

  10. #9

    Join Date
    Aug 2007
    Posts
    827
    Thank Post
    101
    Thanked 65 Times in 47 Posts
    Rep Power
    26
    Great news !

    Never used Pearl but im sure I could install no problemo !!

    Thanks all

  11. #10
    linkazoid's Avatar
    Join Date
    May 2007
    Location
    London
    Posts
    655
    Thank Post
    121
    Thanked 90 Times in 74 Posts
    Rep Power
    79
    Bit of a revival!

    Did anyone manage to do this?

    Michael

  12. #11

    dhicks's Avatar
    Join Date
    Aug 2005
    Location
    Knightsbridge
    Posts
    5,683
    Thank Post
    1,268
    Thanked 789 Times in 686 Posts
    Rep Power
    237
    Quote Originally Posted by linkazoid View Post
    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?

  13. #12
    linkazoid's Avatar
    Join Date
    May 2007
    Location
    London
    Posts
    655
    Thank Post
    121
    Thanked 90 Times in 74 Posts
    Rep Power
    79
    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

  14. #13

    dhicks's Avatar
    Join Date
    Aug 2005
    Location
    Knightsbridge
    Posts
    5,683
    Thank Post
    1,268
    Thanked 789 Times in 686 Posts
    Rep Power
    237
    Quote Originally Posted by linkazoid View Post
    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.

SHARE:
+ Post New Thread

Similar Threads

  1. [Video] Crane Pull Ups Anyone ?
    By mattx in forum Jokes/Interweb Things
    Replies: 8
    Last Post: 5th October 2009, 07:05 PM
  2. [Video] How not to pull a car out of the snow.
    By mattx in forum Jokes/Interweb Things
    Replies: 6
    Last Post: 10th February 2009, 06:59 PM
  3. Replies: 3
    Last Post: 25th September 2006, 12:27 PM
  4. Replies: 5
    Last Post: 5th March 2006, 01:22 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •