how does nagios call service

Rob Moss robmossrm at aol.com
Thu Oct 13 14:04:30 CEST 2005


Tao Yaoning wrote:

> Hi, all
>
> I use nagios 1.x to monitor my network, it works greatly. Now I want 
> to upgrade nagios to 2.0b4. So I just set up a new nagios server with 
> nagios 2.0b4 package, and copy all configuration files from old nagios 
> server to new server and edit all configuration files to make them 
> have correct syntax for nagios 2.
>
> Every thing is fine except one problem.
>
> I use check_snmp_apcups plugin to monitor my ups. It works very fine 
> in nagios 1.x, but in nagios 2.0b4, it always tell me an error "**ePN 
> failed to compile /usr/lib/nagios/plugins/check_snmp_apcups: "Global 
> symbol "$script" requires explicit package name at (eval 5) line 
> 23,Global symbol "$script_version" requires explicit package name at 
> (eval 5) line 31." I checked the file, it's OK, it looks like this
> $script     = "check_snmp_apcups";
> $script_version = "2.1.0";
> and these global symbol are useless in the check_snmp_apcups. The 
> script only call them when display the help messages.


Is this your own Perl script?
Does this perl script use warnings, and load the 'strict' module?
ie:

#!/usr/bin/perl -w
use strict;
..rest of script..

I suspect that you have not enabled Strict mode in your script, and have 
not given the -w (warning) flag to perl..

What if you run 'perl -w -c <scriptname>' does it warn you about the 
same errors?

You should be defining your variables with 'my' or 'our' functions at 
the beginning of your script.

The embedded perl interpereter in Nagios probably is using the good 
coding practices of using warnings and strict code checking, which is 
why you are seeing these errors.

Review your script, change the lines

$script     = "check_snmp_apcups";
$script_version = "2.1.0";

to

my $script     = "check_snmp_apcups";
my $script_version = "2.1.0";

And all subsequent variables, and you shouldn't receive any warnings.  
The warnings are telling you that you aren't defining your variables.  
Define the variables and there will be no warnings.

Cheers
rob

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-lists.org/archive/users/attachments/20051013/89a2452e/attachment.html>


More information about the Users mailing list