Using utils.pl

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
brent_weaver
Posts: 10
Joined: Mon Mar 04, 2013 3:53 pm

Using utils.pl

Post by brent_weaver »

Hello all!!!

Code: Select all

#!/usr/bin/perl -w

#use strict;
use lib "/opt/openitc/nagios/libexec";
use utils;


print "$ERRORS{'OK'}\n";

Code: Select all

# ls /opt/openitc/nagios/libexec/utils.pm
/opt/openitc/nagios/libexec/utils.pm
I would expect that my little sample script would print 0 but this is what happens:

Code: Select all

[06:52]root@OWMaster~/bjw# ./test
Name "main::ERRORS" used only once: possible typo at ./test line 8.
Use of uninitialized value $ERRORS{"OK"} in concatenation (.) or string at ./test line 8.
Any help is much appreciated because this has me at a stand still! Thanks!
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Using utils.pl

Post by tmcdonald »

I was able to get it working on my system like so:

Code: Select all

#!/usr/bin/perl -w

use strict;
use lib "/usr/local/nagios/libexec";
use utils;

print "$utils::ERRORS{'OK'}\n";
Just need to reference the namespace properly.
Former Nagios employee
Locked