We are trying to monitor a VPN using a plug-in called “check_vpn.pl” downloaded from the nagios exchange. We are encountering difficulties with the script. When we run the script in the terminal it works however it brings up an error with the nagios core meaning that when nagios calls the script there is an error. The error seems to be in this section of the script:
# Create SNMP Session
($session, $error) = Net::SNMP->session(-hostname=>$host,-community=>$community,-port=>161);
#die "session error: $error" unless ($session);
if (! defined $session){
print "session error: $error";
exit($STATUSCODE{'UNKNOWN'});
}
# Walk sonicSAStatPeerGateway for list of active session OIDs
$result = $session->get_table(-baseoid => $sonicSAStatPeerGateway);
#die "request error: ".$session->error unless (defined $result);
if (! defined $result){
print "request error: ".$session->error;
exit($STATUSCODE{'UNKNOWN'});
}
We can run the script in the terminal using the command
nagios@nagios-virtual-machine:~$/usr/local/nagios/libexec/xxx.x.xxx -C xxxxx -V xxxxx
Which gives the output:
Use of uninitialized value in print at /usr/local/nagios/libexec/check_vpn.pl line 59.
index of oids 8
splits 2
data index .439300970
getdata HASH(0x2020d88)
datatable 195.11.xxx.xxx
splits 2
data index .636748606
getdata HASH(0x2020680)
datatable 213.123.xxx.xxx
splits 2
data index .1197858815
getdata HASH(0x2020bc0)
datatable 83.100.xxx.xxx
splits 2
data index .3221980697
getdata HASH(0x2025118)
datatable 87.102.xxx.xxx
splits 2
data index .3331040650
getdata HASH(0x201abf8)
datatable 213.249.xxx.xxx
splits 2
data index .3381330750
getdata HASH(0x20205f0)
datatable 213.123.xxx.xxx
splits 2
data index .3427044043
getdata HASH(0x2020e30)
datatable 94.72.xxx.xxx
splits 2
data index .3741549102
getdata HASH(0x201ac70)
datatable 87.102.xxx.xxx
namedata HASH(0x2020740)
name !xxxxxxxxxx!
passed VPN Name !xxxxxxxxx!
namedata HASH(0x2020cb0)
name !xxxxxxxxxxx!
passed VPN Name !xxxxxxxxx!
namedata HASH(0x201abf8)
name !Batty!
passed VPN Name !xxxxxxxxxx!
Can anyone help!??
Perl Script runs in terminal but not when called by nagios
-
wormfishin
- Posts: 31
- Joined: Tue Apr 10, 2012 8:11 am
Re: Perl Script runs in terminal but not when called by nagi
What error do you get when nagios tries to run it?