New NagVis Gadget - Printer Supplies

This forum was archived to /woltlab and is now in read-only mode.
  • Hey folks,


    I've written another NagVis plugin, this time to help monitor printer supply levels. It goes in-hand with a Nagios plugin I wrote to query SNMP-enabled printers. All you need to use this is a network-enabled printer, the check_printer plugin from my site (below), and PHP with GD installed. This is 100% dynamically generated.


    This image will auto-detect toner cartridges and size itself accordingly. Also, color order is defined by the printer SNMP order. Not all colors or features are supported on all printers. Color is determined by SNMP string. If you have problems, please contact me so I can update the gadget for your SNMP strings!


    You can download the files here:
    * NagVis Print Supply Gadget
    * Nagios Printer Supply Check


    To install, simply place the print_supply.php file in your nagvis/nagvis/gadgets folder and enjoy!

    Images

    • Picture 21.png
    • Picture 20.png
  • Running into problems with the plugin:


    Code
    1. ./check_printer 10.xxx.xxx.xxx public 10 5
    2. Use of uninitialized value in division (/) at ./check_printer line 92.
    3. Illegal division by zero at ./check_printer line 92.


    replacing (Line 92)
    my $current = round(($value->{"curr"} / $maximum) * 100);
    by
    my $current = round(($value->{"curr"} / 90) * 100);
    follows to

    Code
    1. ./check_printer 10.81.80.27 public 10 5
    2. Use of uninitialized value in division (/) at ./check_printer line 92.
    3. Waste Toner, Fusing Unit CRITICAL. See http://10.xxx.xxx.xxx | 'Cyan Toner'=111%;10;5;0;100 'Black Photoconductive Drum'=48%;10;5;0;100 'Magenta Toner'=111%;10;5;0;100 'Black Toner'=83%;10;5;0;100 'Black Developer'=48%;10;5;0;100 'Cyan Photoconductive Drum'=74%;10;5;0;100 'Magenta Developer'=74%;10;5;0;100 'Magenta Photoconductive Drum'=74%;10;5;0;100 'Waste Toner'=0%;10;5;0;100 'Yellow Toner'=28%;10;5;0;100 'Yellow Developer'=74%;10;5;0;100 'Cyan Developer'=74%;10;5;0;100 'Fusing Unit'=0%;10;5;0;100 'Yellow Photoconductive Drum'=74%;10;5;0;100


    My snmpwlk looks fine..


    Maybe because there are negative values in the snmpwalk?!


    Thanks for your help

  • Can you tell me what manufacturer and model your printer is? The SNMP doesn't really meet the standards, as defined. It would appear as though your printer is outputting current percentage, rather than an actual value, as my HP did in testing (and the standard). The math error, as you suggested, comes from the negative values in the Max OID table.

  • Quote

    Can you tell me what manufacturer and model your printer is?


    Sure, sorry, how could I forget :wacko:
    Its a Sharp MX-2300N.


    Its the only printer that is actual interesting for me (as I sometimes have to refill it).
    But I will try some other modells as soon as time comes..


    Quote

    The math error, as you suggested, comes from the negative values in the Max OID table.


    Hm, looks like some work is comming up for one of us... :rolleyes:

  • I've got a prelim patch for the nagios check which assumes percentages when max data is output as a negative number. Still need manufacturer and model information so I can check my work.


    Edit: the patch is available vis SVN (the link above will get latest version

  • I've done a bit more research. The value, -2, specifies the printer in your example doesn't know the max capacity of a given supply.


    After doing some reading in the Printer MIB RFC, I'm going to re-code some things. Namely, anything with a max value of -2 and a current value of < 100 is going to be assumed as a percentage. x.43.11.1.1.7.x is the UofM, which I will start to process accordingly.


    I'll make some changes and get another prelim patch committed, which will function. Some new logic will need to be added, which I'll get to later today, or more likely, tomorrow.

  • I've just committed a patch which should solve your issue. The new code ignore unknown max values which are not determined to be of UOM % (which we can conjecture a max value). Please test and let me know.


    I am working on a patch with the NagVis plugin to accommodate your data.

  • I think I've got this fixed. I've updated both the printer nagios check as well as the NagVis plugin which seems to work with your perfdata.


    I've attached a screencap here showing the output of the plugin with your data.


    Main Modifications:
    1) Any 'WASTE' tagged fields will have an inverse warning/critical state.
    2) Adjusted for output from MX-2300
    3) Sorting elements alphabetically so same-color components appear near to eachother in output graph.

  • Hello ecrist,


    thanks alot for your work! :thumbsup:


    The checkcommand works almost fine.


    Only from some printers I receive no perfdata.


    Trying it from the cli I get the following output:


    Code
    1. Mon01:/usr/local/nagios/libexec # ./printer_supply 192.168.135.29 public 10 5
    2. Use of uninitialized value in string at ./printer_supply line 123.
    3. Use of uninitialized value in string at ./printer_supply line 123.
    4. Use of uninitialized value in string at ./printer_supply line 123.
    5. Use of uninitialized value in string at ./printer_supply line 123.
    6. Printer Supplies OK | Mon01:/usr/local/nagios/libexec #


    These are the lines 118 to 124of the file.

    PHP
    1. my %finvalues;
    2. foreach(@values){
    3. # matching the following line
    4. # .1.3.6.1.2.1.43.11.1.1.6.1.1 = STRING: "Black Cartridge"
    5. $_ =~ m/^([\.\d]+).*:[\s\"]+([\-\d\w\s]+)\"*$/;
    6. $finvalues{"$1"} = $2;
    7. }


    I don´t know how I can solve this ;(


    Any advise for me? Please :)


    Thanks in advance!


    Kind Regards,
    Sven

  • Hello,



    unforgtunatly i get always result :


    Printer Supplies OK |


    without any perfdata. Maybe it depends on the language settings our printers are used with (german and swedish)?



    the snmpwalk on diffent printers looks like this:


    german BW - Printer


    # snmpwalk -Os -c public -v 1 xxx.xxx.xxx.xxx .1.3.6.1.2.1.43.11.1.1
    mib-2.43.11.1.1.2.1.1 = INTEGER: 1
    mib-2.43.11.1.1.3.1.1 = INTEGER: 1
    mib-2.43.11.1.1.4.1.1 = INTEGER: 3
    mib-2.43.11.1.1.5.1.1 = INTEGER: 3
    mib-2.43.11.1.1.6.1.1 = STRING: "Toner"
    mib-2.43.11.1.1.7.1.1 = INTEGER: 13
    mib-2.43.11.1.1.8.1.1 = INTEGER: -2
    mib-2.43.11.1.1.9.1.1 = INTEGER: -3


    german MFC


    # snmpwalk -Os -c public -v 1 xxx.xxx.xxx.xxx .1.3.6.1.2.1.43.11.1.1
    mib-2.43.11.1.1.2.1.1 = INTEGER: 1
    mib-2.43.11.1.1.2.1.2 = INTEGER: 1
    mib-2.43.11.1.1.2.1.3 = INTEGER: 1
    mib-2.43.11.1.1.2.1.4 = INTEGER: 1
    mib-2.43.11.1.1.2.1.5 = INTEGER: 1
    mib-2.43.11.1.1.3.1.1 = INTEGER: 1
    mib-2.43.11.1.1.3.1.2 = INTEGER: 2
    mib-2.43.11.1.1.3.1.3 = INTEGER: 3
    mib-2.43.11.1.1.3.1.4 = INTEGER: 4
    mib-2.43.11.1.1.3.1.5 = INTEGER: 5
    mib-2.43.11.1.1.4.1.1 = INTEGER: 3
    mib-2.43.11.1.1.4.1.2 = INTEGER: 4
    mib-2.43.11.1.1.4.1.3 = INTEGER: 3
    mib-2.43.11.1.1.4.1.4 = INTEGER: 3
    mib-2.43.11.1.1.4.1.5 = INTEGER: 3
    mib-2.43.11.1.1.5.1.1 = INTEGER: 3
    mib-2.43.11.1.1.5.1.2 = INTEGER: 4
    mib-2.43.11.1.1.5.1.3 = INTEGER: 3
    mib-2.43.11.1.1.5.1.4 = INTEGER: 3
    mib-2.43.11.1.1.5.1.5 = INTEGER: 3
    mib-2.43.11.1.1.6.1.1 = STRING: "Toner Schwarz"
    mib-2.43.11.1.1.6.1.2 = STRING: "Resttoner 1"
    mib-2.43.11.1.1.6.1.3 = STRING: "Toner Cyan"
    mib-2.43.11.1.1.6.1.4 = STRING: "Toner Magenta"
    mib-2.43.11.1.1.6.1.5 = STRING: "Toner Gelb"
    mib-2.43.11.1.1.7.1.1 = INTEGER: 13
    mib-2.43.11.1.1.7.1.2 = INTEGER: 13
    mib-2.43.11.1.1.7.1.3 = INTEGER: 13
    mib-2.43.11.1.1.7.1.4 = INTEGER: 13
    mib-2.43.11.1.1.7.1.5 = INTEGER: 13
    mib-2.43.11.1.1.8.1.1 = INTEGER: -2
    mib-2.43.11.1.1.8.1.2 = INTEGER: -2
    mib-2.43.11.1.1.8.1.3 = INTEGER: -2
    mib-2.43.11.1.1.8.1.4 = INTEGER: -2
    mib-2.43.11.1.1.8.1.5 = INTEGER: -2
    mib-2.43.11.1.1.9.1.1 = INTEGER: -3
    mib-2.43.11.1.1.9.1.2 = INTEGER: -3
    mib-2.43.11.1.1.9.1.3 = INTEGER: -3
    mib-2.43.11.1.1.9.1.4 = INTEGER: -3
    mib-2.43.11.1.1.9.1.5 = INTEGER: -3


    swedish


    # snmpwalk -Os -c public -v 1 172.26.4.2 .1.3.6.1.2.1.43.11.1.1
    mib-2.43.11.1.1.2.1.1 = INTEGER: 1
    mib-2.43.11.1.1.2.1.2 = INTEGER: 1
    mib-2.43.11.1.1.2.1.3 = INTEGER: 1
    mib-2.43.11.1.1.2.1.4 = INTEGER: 1
    mib-2.43.11.1.1.2.1.5 = INTEGER: 1
    mib-2.43.11.1.1.3.1.1 = INTEGER: 1
    mib-2.43.11.1.1.3.1.2 = INTEGER: 2
    mib-2.43.11.1.1.3.1.3 = INTEGER: 3
    mib-2.43.11.1.1.3.1.4 = INTEGER: 4
    mib-2.43.11.1.1.3.1.5 = INTEGER: 5
    mib-2.43.11.1.1.4.1.1 = INTEGER: 3
    mib-2.43.11.1.1.4.1.2 = INTEGER: 4
    mib-2.43.11.1.1.4.1.3 = INTEGER: 3
    mib-2.43.11.1.1.4.1.4 = INTEGER: 3
    mib-2.43.11.1.1.4.1.5 = INTEGER: 3
    mib-2.43.11.1.1.5.1.1 = INTEGER: 3
    mib-2.43.11.1.1.5.1.2 = INTEGER: 4
    mib-2.43.11.1.1.5.1.3 = INTEGER: 3
    mib-2.43.11.1.1.5.1.4 = INTEGER: 3
    mib-2.43.11.1.1.5.1.5 = INTEGER: 3
    mib-2.43.11.1.1.6.1.1 = STRING: "Svart toner"
    mib-2.43.11.1.1.6.1.2 = STRING: "Toneruppsamlare 1"
    mib-2.43.11.1.1.6.1.3 = STRING: "Cyan-toner"
    mib-2.43.11.1.1.6.1.4 = STRING: "Magenta-toner"
    mib-2.43.11.1.1.6.1.5 = STRING: "Gul toner"
    mib-2.43.11.1.1.7.1.1 = INTEGER: 13
    mib-2.43.11.1.1.7.1.2 = INTEGER: 13
    mib-2.43.11.1.1.7.1.3 = INTEGER: 13
    mib-2.43.11.1.1.7.1.4 = INTEGER: 13
    mib-2.43.11.1.1.7.1.5 = INTEGER: 13
    mib-2.43.11.1.1.8.1.1 = INTEGER: -2
    mib-2.43.11.1.1.8.1.2 = INTEGER: -2
    mib-2.43.11.1.1.8.1.3 = INTEGER: -2
    mib-2.43.11.1.1.8.1.4 = INTEGER: -2
    mib-2.43.11.1.1.8.1.5 = INTEGER: -2
    mib-2.43.11.1.1.9.1.1 = INTEGER: -3
    mib-2.43.11.1.1.9.1.2 = INTEGER: -3
    mib-2.43.11.1.1.9.1.3 = INTEGER: -3
    mib-2.43.11.1.1.9.1.4 = INTEGER: -3
    mib-2.43.11.1.1.9.1.5 = INTEGER: -3




    i cahnged the values to the check_printer script - only with bad luck.



    how can i change it for using it to our printers?



    regards

  • I will look into both these issues over the weekend (10:45am on Friday here, now).


    Sven, I need SNMP output from your printer for testing.

  • Hi ecrist,


    sorry for the late reply, over the weekend I managed the growing agecounter of my life ;-)


    Please find attached the output of an snmpwalk to the Kyocera FS-C 5025 NKyocera-SNMP.txt


    Thx!
    Best Regards,
    Sven

  • J.Hummer,


    Looking at your data, the OID .1.3.6.1.2.1.43.11.1.1.9.1 is supply table 1 for current-level. In all of your examples, the current level shows as -3, not a real number. According to RFC 1759,


    Quote

    A value of (-3) means that the printer knows that there is some supply/remaining space, respectively.


    This means the printer check plugin will only be able to determine if there is supply available or not, not the actual level of supply available. The graphing plugin will either display 100% or 0%, and there can be no provision for warning.


    I'm working on patching for this now.

  • Hi ecrist,


    sorry but the patch didn't work for me.
    From the nagios cli I get perfdata, from my centreon I get critical and no perfdata!
    The rights are the same as from the first check-command.


    The gadget didn't draw anything at all (with and without perfdata).


    I'll check again the centreon behaviour with the check-command (maybe I'll find the tree in the forest :D ).


    Cheers
    Sven

  • the same here...


    I get

    Code
    1. ./check_printer xxx.xxx.xxx.xxx public 10 20
    2. TONERPATRONE HP C8061X CRITICAL | 'TONERPATRONE HP C8061X'=11%;10;20;0;100


    that looks fine,


    BUT on the Nagios-GUI i get only "CRITICAL" and 'Status Information' of (null)
    (see screenshot)

  • Hello ecrist,


    thank you for the running check, i'm all little sorry for not seeing the percentage of toner of our mfc's. This would be a great enhencement. At least the values are shown on the webinterface of the printers. Therefor i did a look at the mibs and found the values, with the .5.x integer values of the toners fillment.


    ns01:/usr/local/nagios/libexec # snmpwalk -Os -c public -v 1 172.17.4.62 .1.3.6.1.4.1.367.3.2.1.2.24.1.1
    enterprises.367.3.2.1.2.24.1.1.2.1 = STRING: "Black Toner"
    enterprises.367.3.2.1.2.24.1.1.2.2 = STRING: "Cyan Toner"
    enterprises.367.3.2.1.2.24.1.1.2.3 = STRING: "Magenta Toner"
    enterprises.367.3.2.1.2.24.1.1.2.4 = STRING: "Yellow Toner"
    enterprises.367.3.2.1.2.24.1.1.3.1 = STRING: "Toner Schwarz"
    enterprises.367.3.2.1.2.24.1.1.3.2 = STRING: "Toner Cyan"
    enterprises.367.3.2.1.2.24.1.1.3.3 = STRING: "Toner Magenta"
    enterprises.367.3.2.1.2.24.1.1.3.4 = STRING: "Toner Gelb"
    enterprises.367.3.2.1.2.24.1.1.4.1 = INTEGER: 13
    enterprises.367.3.2.1.2.24.1.1.4.2 = INTEGER: 10
    enterprises.367.3.2.1.2.24.1.1.4.3 = INTEGER: 11
    enterprises.367.3.2.1.2.24.1.1.4.4 = INTEGER: 12
    enterprises.367.3.2.1.2.24.1.1.5.1 = INTEGER: 80
    enterprises.367.3.2.1.2.24.1.1.5.2 = INTEGER: 90
    enterprises.367.3.2.1.2.24.1.1.5.3 = INTEGER: 20
    enterprises.367.3.2.1.2.24.1.1.5.4 = INTEGER: 80


    and


    ns01:/usr/local/nagios/libexec # snmpwalk -Os -c public -v 1 172.26.4.3 .1.3.6.1.4.1.367.3.2.1.2.24.1.1
    enterprises.367.3.2.1.2.24.1.1.2.1 = STRING: "Black Toner"
    enterprises.367.3.2.1.2.24.1.1.2.2 = STRING: "Cyan Toner"
    enterprises.367.3.2.1.2.24.1.1.2.3 = STRING: "Magenta Toner"
    enterprises.367.3.2.1.2.24.1.1.2.4 = STRING: "Yellow Toner"
    enterprises.367.3.2.1.2.24.1.1.3.1 = STRING: "Svart toner"
    enterprises.367.3.2.1.2.24.1.1.3.2 = STRING: "Cyan-toner"
    enterprises.367.3.2.1.2.24.1.1.3.3 = STRING: "Magenta-toner"
    enterprises.367.3.2.1.2.24.1.1.3.4 = STRING: "Gul toner"
    enterprises.367.3.2.1.2.24.1.1.4.1 = INTEGER: 13
    enterprises.367.3.2.1.2.24.1.1.4.2 = INTEGER: 10
    enterprises.367.3.2.1.2.24.1.1.4.3 = INTEGER: 11
    enterprises.367.3.2.1.2.24.1.1.4.4 = INTEGER: 12
    enterprises.367.3.2.1.2.24.1.1.5.1 = INTEGER: -100
    enterprises.367.3.2.1.2.24.1.1.5.2 = INTEGER: 50
    enterprises.367.3.2.1.2.24.1.1.5.3 = INTEGER: 60
    enterprises.367.3.2.1.2.24.1.1.5.4 = INTEGER: 50


    with the value -100 means "toner low" . How can this OID's be used to show the values in the printer_supply.php gadget?


    regards
    j.hummer

  • To all three of you:


    Thanks for the great debug data. If you're running the latest version, and you can run the check command manually from your nagios host, add a 1 as the fifth argument to the command and post the data here. It will output a bunch of debug for me (the OID array) and allow me to fix this.


    I will work on this tomorrow (16:10 here now, CDT).