[Nagiosplug-devel] [ nagiosplug-Bugs-1985338 ] perl plugins failure when run by embedded perl interpreter

SourceForge.net noreply at sourceforge.net
Thu Jun 5 13:11:43 CEST 2008


Bugs item #1985338, was opened at 2008-06-05 13:11
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=397597&aid=1985338&group_id=29880

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Embedded Perl failure
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Jan Wagner (cyco_dd)
Assigned to: Nobody/Anonymous (nobody)
Summary: perl plugins failure when run by embedded perl interpreter

Initial Comment:
The following Bugreport we got against our debian package:

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.

You can track the bugreport via http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=478906

Thanks and kind regards, Jan.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=397597&aid=1985338&group_id=29880




More information about the Devel mailing list