[Nagiosplug-help] Help with passing Nagios variables to custom plugin

Zembower, Kevin kzembowe at jhuccp.org
Fri Sep 28 21:12:56 CEST 2007


Following advice from a user here, I used this code to dump the contents
of the NAGIOS_* variables to a file when the perl plugin I wrote was
called:

# Use this line below to dump the environment variables for debugging
system "env|sort >/tmp/plugins_env.$$";

This seems to work correctly, and I end up with:
...
NAGIOS_HOSTADDRESS=10.253.192.204
NAGIOS_HOSTALIAS=www.jhuccp.org
...

which is exactly what I expected. Then I tried to use this value with:
my %NAGIOS_ENV = map { $_ => $ENV{$_} } grep /^NAGIOS_/, keys %ENV;
...
   } elsif (defined($NAGIOS_ENV{NAGIOS_HOSTADDRESS})) {
   $hostaddress = $NAGIOS_ENV{NAGIOS_HOSTADDRESS};
...
print DMP "hostaddress is $hostaddress.\n";

This outputs:
hostaddress is $HOSTADDRES$.

and the plugin fails. 

Any suggestions on what I'm doing wrong or overlooking?

Thanks for you advice and suggestions.

-Kevin

Kevin Zembower
Internet Services Group manager
Center for Communication Programs
Bloomberg School of Public Health
Johns Hopkins University
111 Market Place, Suite 310
Baltimore, Maryland  21202
410-659-6139 




More information about the Help mailing list