check_printer plugin's for Nagvis error

This forum was archived to /woltlab and is now in read-only mode.
  • Hello,
    I have configured the check_printer plugin for Nagvis gadet. I can run the plugin, but it doesn't exit correctly so I have the following error (unknown status):


    Plugin output:

    Code
    1. **ePN /usr/lib/nagios/plugins/check_printer: plugin did not call exit()


    Plugin long output:

    Code
    1. **ePN /usr/lib/nagios/plugins/check_printer: "Use of uninitialized value $revision in concatenation (.) or string at (eval 9) line 61,".


    I have noticed that line 61 contains the following code:

    Code
    1. print "check_printer Revision $revision\n$src_url\n\n";


    I have read that the problem can be fixed using "# icinga -epn" and I have added the line. When the plugin is executed I got the following error (status OK):
    Plugin output:

    Code
    1. Use of uninitialized value $revision in concatenation (.) or string at /usr/lib/nagios/plugins/check_printer line 61.


    Plugin long output

    Code
    1. Use of uninitialized value $src_url in concatenation (.) or string at /usr/lib/nagios/plugins/check_printer line 61.check_printer Revision


    and Perfdata

    Code
    1. yes|true|0|no|false) excludeRequested (1|yes|true|0|no|false) printStatistics (1|yes|true|0|no|false) dontCheckOrdering (1|yes|true|0|no|false) timeResults (1|yes|true|0|no|false) In snmp.conf and snmp.local.conf: doDebugging (1|0) debugTokens token[,token...] logTimestamp .........


    Where can be the problem?
    Thanks!

    The post was edited 1 time, last by rakaris ().

  • I think, that the problem is not in incorrect syntax.

    I guess the plugin call is incorrect so it tries do show the help.

    When I execute the script from server (it does not matter if the string "# icinga: -epn" exists on the beginning of the script) the following output is generated (no correct exit or new line):


    Code
    1. admin@MON-1:/usr/lib/nagios/plugins$ ./check_printer 172.20.10.210 nms-riga-print-get 5 10
    2. Printer Supplies OK | 'Black Cartridge '=40%;5;10;0;100 'Maintenance Kit '=56%;5;10;0;100 admin@MON-1:/usr/lib/nagios/plugins$


    But the output must be in the following format

    :

    Code
    1. admin@MON-1:/usr/lib/nagios/plugins$ ./check_printer 172.20.10.210 nms-riga-print-get 5 10 Printer Supplies OK | 'Black Cartridge '=40%;5;10;0;100 'Maintenance Kit '=56%;5;10;0;100


    without "admin@MON-1:/usr/lib/nagios/plugins$"


    From my point of view the script execution is not finished (I'm not developer). Has anyone knows how to solve this?

    The post was edited 2 times, last by rakaris ().

  • Adding a linefeed here might be sufficient

    Code
    1. $perf_str = "$perf_str '$key'=$current%;$warning;$critical;0;100\n";


    Looking at the code there are at least two lines resulting in the error messages you showed

    Code
    1. '$Revision$' =~ m/Revision: (\d+)/;
    2. '$HeadURL$' =~ m/HeadURL: ([\w\:\/\-\.\_]+) /;

    I guess there might be an installation script replacing the variables with proper values like "Revision: 123" and "HeadURL: www.no-idea.what".

  • I have changed the line from:

    Code
    1. $perf_str = "$perf_str '$key'=$current%;$warning;$critical;0;100 ";


    to

    Code
    1. $perf_str = "$perf_str '$key'=$current%;$warning;$critical;0;100\n";


    Edit: The results are following:


    • when I enter at commandline the output is ok



    • when the script is executed by Icinga, the same error (61 line) is generated.



    Do I need to change something at '$HeadURL$', too?

    Adding a linefeed here might be sufficient

    Code
    1. $perf_str = "$perf_str '$key'=$current%;$warning;$critical;0;100\n";


    Looking at the code there are at least two lines resulting in the error messages you showed

    Code
    1. '$Revision$' =~ m/Revision: (\d+)/;
    2. '$HeadURL$' =~ m/HeadURL: ([\w\:\/\-\.\_]+) /;

    I guess there might be an installation script replacing the variables with proper values like "Revision: 123" and "HeadURL: www.no-idea.what".

    The post was edited 4 times, last by rakaris ().

  • Well, that was the intention of the hint regarding these two variables...

    I saw the lines but as I'm not the developer it's hard too understand the cause.

  • I am the developer of the plugin. It's a generic Nagios plugin originally written to work with the associated NagVis check_printer plugin. The error here is that the original user simply downloaded the file directly out of my developer trac as a source file, and didn't export the file from SVN. The check out or export process sets those variables (or when I create a release package.)


    The following command sequence on a unix terminal shows the proper work flow, and demonstrates the values set:



    Here's an execution of the properly checked-out script:

    Code
    1. ecrist@swordfish:~/work-> ./check_printer 192.168.5.100 public 2 1
    2. Printer Supplies OK | 'Black Cartridge HP CB436A'=7%;2;1;0;100
  • Thanks about so quickly response! I'm new in Linux environment so this is one of my hard lessons!
    I have done the svn export. When I run Icinga (with check_mk legacy checks mode), I get Plugin output "check_printer Revision 344" no Performance data and the following Long plugin output:


    Code
    1. https://secure-computing.net/svn/trunk/nagios/check_printer
    2. $VAR1 = [];$VAR1 = {};
    3. ############ ATTENTION ############You have debug enabled. If asked to enable debug by the developer,please send all of the output, including your command line toecrist@secure-computing.net with the subject line 'check_printer DEBUG' alongwith a description of the problem you're experiencing.###################################Printer Supplies OK


    I have no debugging enabled.
    The output is correct when I run the plugin from command line

    Code
    1. Printer Supplies OK | 'Black Cartridge '=40%;5;10;0;100 'Maintenance Kit '=56%;5;10;0;100 admin@MON-1:/usr/lib/nagios/plugins$

    .


    Is this correct? If not where can be the problem?


    Thanks!

  • Check your plugin definition. You are passing more than the required parameters which enables debugging.

    Edited: Here is my main.mk code. This is correct (I have tested the commented version , too):


    extra_nagios_conf += r"""
    define command {
    command_name check_printer
    #command_line $USER1$/check_printer -H $HOSTADDRESS$ public $ARG1$ $ARG2$
    command_line /usr/bin/perl $USER1$/check_printer -H $HOSTADDRESS$ public 2 1
    }



    """
    legacy_checks = []
    legacy_checks = legacy_checks + [
    ( ( "check_printer", "Printer statistics", True),["NetPrinters"],ALL_HOSTS),
    #( ( "check_printer!2!1", "Printer statistics", True),["NetPrinters"],ALL_HOSTS),
    ]

  • check_printer is a Nagios plugin, written to provide output for a NagVis plugin (though PNP and others can use it, as it's standard per data.) I have not tried to integrate this with Icinga, yet. We're just this week and next, rolling out Icinga to replace Nagios. At that time, I can provide more input as to your error. In the mean time, I suggest you run it best you can as a regular Nagios plugin.


    Cheers