[Pkg-nagios-devel] Bug#478906: nagios-plugins: perl plugins failure when run by embedded perl interpreter

Stephane Chazelas stephane at artesyncp.com
Thu May 1 17:25:47 UTC 2008


Package: nagios-plugins
Version: 1.4.11-2
Severity: normal


When perl plugin scripts are run with the embedded perl
interpreter in nagios3, the "shift" perl command doesn't shift
@ARGV, but @_ (which happens to contain the same thing as @ARGV
at the time the script was started).

So, if we take the example of:

/usr/lib/nagios/plugins/check_disk_smb

we have:

Getopt::Long::Configure('bundling');
GetOptions
        ("v"   => \$verbose, "verbose"    => \$verbose,
[...]
($opt_H) || ($opt_H = shift) || usage("Host name not specified\n");
my $host = $1 if ($opt_H =~ /^([-_.A-Za-z0-9 ]+\$?)$/);

The "GetOptions" will process the option part of @ARGV (not @_)
and shift the processed arguments from there but will leave @_
untouched, so the "shift" above will return the first option,
not the first argument after the options.

with a /etc/nagios3/conf.d/local.cfg file containing:

define service{
        use                             generic-service         ; Name of service template to use
        host_name                       localhost
        service_description             SMB
        check_command                   check_disk_smb_user!host!share!me!mypasswd
        }

You end up getting the status result of the check being:

Invalid warning threshold: -H

This is because the perl script is called with:

-H host -s share -u me -p mypasswd

The -w option is not provided, so:

($opt_w) || ($opt_w = shift) || ($opt_w = 85);
my $warn = $1 if ($opt_w =~ /^([0-9]{1,2}\%?|100\%?|[0-9]+[kMG])$/);
($warn) || usage("Invalid warning threshold: $opt_w\n");


sets $opt_w to the first item in @_ (instead of @ARGV), that is
"-H" instead of "85" (as @ARGV is empty at that point).

A fix is to replace all the instances of "shift" with "shift
@ARGV".

Other perl plugins are affected by that.

-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)

Kernel: Linux 2.6.24.2
Locale: LANG=en_GB.ISO-8859-15, LC_CTYPE=en_GB.ISO-8859-15 (charmap=ISO-8859-15)
Shell: /bin/sh linked to /bin/bash

Versions of packages nagios-plugins depends on:
ii  nagios-plugins-basic          1.4.11-2   Plugins for the nagios network mon
ii  nagios-plugins-standard       1.4.11-2   Plugins for the nagios network mon

nagios-plugins recommends no packages.

-- no debconf information





More information about the Pkg-nagios-devel mailing list