+ Post New Thread
Page 2 of 2 FirstFirst 12
Results 16 to 26 of 26
Wireless Networks Thread, Monitoring Printers with Nagios in Technical; i've not done that (i dont think) so unless it happens without knowing.........
  1. #16

    Join Date
    Jan 2007
    Location
    Birmingham
    Posts
    807
    Thank Post
    29
    Thanked 36 Times in 24 Posts
    Rep Power
    27
    i've not done that (i dont think) so unless it happens without knowing......

  2. #17

    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,850
    Thank Post
    110
    Thanked 598 Times in 514 Posts
    Blog Entries
    1
    Rep Power
    227
    distro dependant.

  3. #18

    Join Date
    Jan 2007
    Location
    Birmingham
    Posts
    807
    Thank Post
    29
    Thanked 36 Times in 24 Posts
    Rep Power
    27
    Ubuntu 7.04

  4. #19

    Join Date
    Jan 2007
    Location
    Birmingham
    Posts
    807
    Thank Post
    29
    Thanked 36 Times in 24 Posts
    Rep Power
    27
    after a bit more research it seems that expr doesnt like the values that snmpget gets. It seems to think they are not "non-numeric arguments". The values seem to have a space after them. Is there a way to cast to a value? Or atleast trim the trailing space off the value?

    Thanks

  5. #20

    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,850
    Thank Post
    110
    Thanked 598 Times in 514 Posts
    Blog Entries
    1
    Rep Power
    227
    Yes, use the 'cut' command.

  6. #21

    Join Date
    Jan 2007
    Location
    Birmingham
    Posts
    807
    Thank Post
    29
    Thanked 36 Times in 24 Posts
    Rep Power
    27
    It's all sorted. For some reason re-typing the variable assignments and the expr statement fixed it. Not sure if it's because i'd downloaded it off the net and ended up with some hidden chars maybe? I did run tofrodos and that solved some other problems but not that one. Just in the process of upgrading the firmware on some of the older printers now as they dont give the toner levels out via snmp without it.

    Also changed way the original calculated the usage as it gave the amount used rather than amount remaining. The adjusted script is below in case anybody wants to check their HP toner usage in nagios.
    Last edited by Lee_K_81; 15th May 2008 at 10:47 AM.

  7. #22

    Join Date
    Jan 2007
    Location
    Birmingham
    Posts
    807
    Thank Post
    29
    Thanked 36 Times in 24 Posts
    Rep Power
    27
    Here's the modified script. Hope this helps somebody else.
    usage (based on HP LaserJet 2600n retrieving black toner usage):

    ./check_hp_toners -H 10.122.1.10 -OC .1.3.6.1.2.1.43.11.1.1.9.1 -OM .1.3.6.1.2.1.43.11.1.1.8.1.1 -p 2500 -C public

    where:
    -H = host address
    -OC = oid for current toner remaining
    -OM = oid for maximum toner
    -p = approx pages specified by manufacturer
    -C = community string

    Code:
    #! /bin/bash
    #
    # Original Script
    # Nagios-Plugin zum überprüfen von Verbrauchsmaterialien in HP Druckern
    # Last Modified: 20-10-2006
    #
    # Modified by Lee Kilcullen
    # Date: 14-05-2008
    
    # Paths to commands used in this script.  These
    # may have to be modified to match your system setup.
    
    PATH="/usr/local/nagios/"
    SNMPGET="/usr/bin/snmpget"
    EXPR="/usr/bin/expr"
    PROGNAME=`/usr/bin/basename $0`
    
    PROGPATH=`echo $0 | /bin/sed -e 's,[\\/][^\\/][^\\/]*$,,'`
    REVISION=`echo '$Revision: 1.4 $' | /bin/sed -e 's/[^0-9.]//g'`
    
    . $PROGPATH/utils.sh
    
    print_usage() {
        echo "Usage: $PROGNAME -H Host -OM OID-Max -OC OID-Cur -w Warn in % -c Critical in % -t Toner OID -C community string"
        echo "Usage: $PROGNAME --help"
        echo "Usage: $PROGNAME --version"
    }
    
    print_help() {
        print_revision $PROGNAME $REVISION
        echo ""
        print_usage
        echo ""
        echo "Überprüfe Verbrauchsmaterial von HP-Druckern"
        echo ""
        support
    }
    
    # Make sure the correct number of command line
    # arguments have been supplied
    
    if [ $# -lt 1 ]; then
        print_usage
        exit $STATE_UNKNOWN
    fi
    
    # Grab the command line arguments
    
    exitstatus=$STATE_WARNING #default
    while test -n "$1"; do
        case "$1" in
            --help)
                print_help
                exit $STATE_OK
                ;;
            -h)
                print_help
                exit $STATE_OK
                ;;
            --version)
                print_revision $PROGNAME $VERSION
                exit $STATE_OK
                ;;
            -V)
                print_revision $PROGNAME $VERSION
                exit $STATE_OK
                ;;
            --host)
                host=$2
                shift
                ;;
            -H)
                host=$2
                shift
                ;;
            --oidmax)
                oidmax=$2
                shift
                ;;
            -OM)
                oidmax=$2
                shift
                ;;
            --oidcur)
                oidcur=$2
                shift
                ;;
            -OC)
                oidcur=$2
                shift
                ;;
            --warn)
                warn=$2
                shift
                ;;
            -w)
                warn=$2
                shift
                ;;
            --current)
                critical=$2
                shift
                ;;
            -c)
                critical=$2
                shift
                ;;
            -x)
                exitstatus=$2
                shift
                ;;
            --exitstatus)
                exitstatus=$2
                shift
                ;;
    	-p)
    	    pages=$2
    	    shift
       	    ;;
    	-C) 
    	    comm=$2
    	    shift
    	    ;;
            *)
                echo "Unknown argument: $1"
                print_usage
                exit $STATE_UNKNOWN
                ;;
        esac
        shift
    done
    	#get maximum amount of toner
    	max=`/usr/bin/snmpget -O Uvqs -v 1 -c $comm $host $oidmax`
    
    	#get current amount of toner
    	rem=`/usr/bin/snmpget -O Uvbqs -v 1 -c $comm $host $oidcur`
    	
    	hundred=100
    
    	#calculate approximate number of pages remaing based on maximum toner capacity, 
    	#manufacturer advised number of pages and remaing toner. 
    	rempages=`/usr/bin/expr $pages "/" $max "*" $rem`
    
    	#calculate current percentage of toner remaining
    	curpercent=`/usr/bin/expr $rem "*" $hundred "/" $max`
       
    
       if [[ -z $max ]]; then
          echo "CRITICAL - $host seems to be dead"
          exitstatus=2
       elif [[ $curpercent -gt $critical ]]; then
            echo "OK - $host: $curpercent% remaining |Pages remaining=$rempages;"
          exitstatus=0
       elif [[ $curpercent -lt $critical ]]; then
          echo "Critical - $host: $curpercent% remaining |Toner will need replacing soon - approx $rempages pages remaining;"
          exitstatus=2
       elif [[ $curpercent -lt $warn ]]; then
          echo "Warning - $host: $curpercent% remaining |Toner needs ordering - approx $rempages pages remaining;"
          exitstatus=1
       else
          echo "UNKNOWN - I see dead people - Something is wrong"
          exitstatus=3
       fi
    
    exit $exitstatus
    Lee
    Last edited by Lee_K_81; 5th June 2008 at 11:12 AM.

  8. #23

    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,850
    Thank Post
    110
    Thanked 598 Times in 514 Posts
    Blog Entries
    1
    Rep Power
    227
    Doesn't seem to work on my P2015's. Ok on my 5500 though.

  9. #24

    Join Date
    Jan 2007
    Location
    Birmingham
    Posts
    807
    Thank Post
    29
    Thanked 36 Times in 24 Posts
    Rep Power
    27
    Dont know about any other models, i've only tested with 2600n and 2605dn. You might want to try updating the firmware though. Some of my older 2600n's didnt give any data back until they were upgraded.

  10. #25

    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,850
    Thank Post
    110
    Thanked 598 Times in 514 Posts
    Blog Entries
    1
    Rep Power
    227
    There doesn't appear to be a firmware update avalible for the P2015.

  11. #26

    Join Date
    Jan 2007
    Location
    Birmingham
    Posts
    807
    Thank Post
    29
    Thanked 36 Times in 24 Posts
    Rep Power
    27
    Not sure if this will help:

    Hewlett-Packard LaserJet P2015 firmware upgrade 20061010


    Also i'm not entirely sure what the oids may be for any other model. You could try doing an snmp walk of the device to see if it returns the values required.



SHARE:
+ Post New Thread
Page 2 of 2 FirstFirst 12

Similar Threads

  1. Nagios Problem
    By sqdge in forum *nix
    Replies: 12
    Last Post: 13th January 2012, 11:11 AM
  2. Monitoring HP Switches in Nagios
    By Lee_K_81 in forum *nix
    Replies: 16
    Last Post: 15th July 2011, 09:13 AM
  3. Replies: 51
    Last Post: 10th November 2009, 06:23 AM
  4. Nagios Display
    By plexer in forum How do you do....it?
    Replies: 4
    Last Post: 17th July 2007, 08:43 PM
  5. Ubuntu Nagios
    By plexer in forum How do you do....it?
    Replies: 2
    Last Post: 10th May 2007, 10:21 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
  •