utils.pm and check_breeze.pl

Jamie Baddeley jamie.baddeley at vpc.co.nz
Fri Aug 8 10:38:57 CEST 2003


Mr Hopcroft,

Thank you for your prompt response.

I have tried what you suggested to no avail.

The thing is that I'm now basically (at this stage, to troubleshoot) changing 
the target OID on the CVS supplied check_breeze i.e:

[root at Nagios plugins]# diff check_breeze.pl check_cpus 
1c1
< #!/usr/bin/perl -wT
---
> #!/usr/bin/perl -w
4c4,5
< use strict;
---
> use lib '/usr/lib/nagios/plugins';
> #use strict;
5a7
> use utils;
7d8
< use lib utils.pm ;
50c51
< $sig = `/usr/bin/snmpget $host $opt_C .1.3.6.1.4.1.710.3.2.3.1.3.0`;
---
> $sig = `/usr/bin/snmpget $host $opt_C .1.3.6.1.2.1.25.3.3.1.2.41`;
[root at Nagios plugins]# 

and still I have the problem after your suggestions.

My point is the utils.pm contains this:

#use vars($TIMEOUT %ERRORS);
- not my hacked script. i.e it may be a problem with utils.pm?

If I remove the # in utils.pm, running check_cpus (my hacked code) speweth 
the complaints mentioned in the earlier email.

Therefore one can safely say that check_breeze in CVS suffers the same 
problem as my script, yet I am ill equipped to solve the problem.

sigh.
:-)

jamie 
(it's not something to do with exporter is it?)

On Fri, 08 Aug 2003 17:50, Stanley Hopcroft wrote:
> Dear Sir,
>
> I am writing to thank you for your letter and say,
>
> > From: "Jamie Baddeley" <jamie.baddeley at vpc.co.nz>
> > Subject: [Nagios-users] Utils.pm & Check Breeze.pl
> >
> > Hi,
> >
> > I'm hacking around with Check_breeze.pl to use it for an alternative
> > smnpwalk based check.
> >
> > I've made the changes, and it's bascially working but for some reason
> > it's not using the %ERRORS part of the utils.pm module. I tried
> > uncommenting "use vars($TIMEOUT %ERRORS);" from utils.pm in an effort to
> > fix it, but this just produces:
> >
> > Unquoted string "utils" may clash with future reserved word at
> > ./check_cpus line 8.
> > Unquoted string "pm" may clash with future reserved word at ./check_cpus
> > line 8.
>
> Sounds like the script contains 'use utils.pm;'.
> Should be 'use utils;'
>
> > Operator or semicolon missing before %ERRORS at
> > /usr/lib/nagios/plugins/utils.pm line 28.
> > Ambiguous use of % resolved as operator % at
> > /usr/lib/nagios/plugins/utils.pm line 28.
> > Argument "ERRORS" isn't numeric in modulus (%) at
> > /usr/lib/nagios/plugins/utils.pm line 28.
> > Use of uninitialized value in modulus (%) at
> > /usr/lib/nagios/plugins/utils.pm line 28.
> > Illegal modulus zero at /usr/lib/nagios/plugins/utils.pm line 28.
> > BEGIN failed--compilation aborted at /usr/lib/nagios/plugins/utils.pm
> > line 28.
> > Compilation failed in require at ./check_cpus line 9.
> > BEGIN failed--compilation aborted at ./check_cpus line 9.
> >
> > when I run my hacked script.
> >
> >
> > Is there a good reason why "use vars..." line is commented out?
> >
> > How does one make it so the %ERRORS part of utils.pm can be called by
> > another perl script?
>
> 1 Tell Perl where to load utils.pm from if it's not in the standard
> paths (eg perl -e 'print "@INC\n"' will let you know where it will
> look).
>
> This is what the 'use lib' pragma is for.
>
> 2 Tell Perl what to import into your script with use util qw (%ERRORS
> usage).
>
> Here's a working example
>
> use strict ;
>
> use Getopt::Long ;
> use Samba ;
> use utils ;
>
> use vars qw($opt_H $opt_s $opt_W $opt_u $opt_p $opt_w $opt_c $debug);
> use vars '$AUTOLOAD' ;
> use utils qw($TIMEOUT %ERRORS &print_revision &support &usage);
>
> my $PROGNAME = 'check_ms_spooler' ;
>
> The 'use vars' pragma is only used where you want global variables (ie
> not lexicals/those declared with my or our) _and_ you want 'use strict'
> to have the compiler complain before you apply chainsaw to flesh and
> blood.
>
> In the example above, I would/have replaced the 'use vars' with
>
> my ($opt_H $opt_s $opt_W $opt_u $opt_p $opt_w $opt_c $debug);
>
> HTH
>
> Yours sincerely.


-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list