Hello
I am having an issue with a plugin I just wrote where the Nagios says
the return code is 9. If I do the following:
lnm@PR-LNM-CR-NAG01:/usr/local/nagios/libexec$ sudo -u nagios
./check_snmp_mw_local_rx_power.pl --hostname 192.168.27.140
--rocommunity EMSOLUTIONS --snmp-version 1
CHECK_RX_POWER OK - Local RX Power OK (-47.5dBm),
|'local_RX_Power'=-47.5;-67;-100;;
lnm@PR-LNM-CR-NAG01:/usr/local/nagios/libexec$ echo $?
0
It suggests the return code is 0.
I have disabled the embedded perl interpreter.
Can anyone tell what is going wrong?
Plugin source code below:
#!/usr/bin/perl
=pod
=head1 NAME
Name of plugin and a sentence explaining function
-head2 SYNOPSIS
Detailed explanation of what the check does, any caveats, etc.
=cut
sub check_snmp_mw_rx_power {
use strict;
use FindBin;
use RRDs;
use lib "$FindBin::Bin/lib";
use lib "/usr/local/nagios/perl/lib";
use Nagios::Plugin::SNMP;
use Nenm::Utils;
my $USAGE = <<EOF;
EOF
my $LABEL = 'CHECK_RX_POWER';
my $plugin = Nagios::Plugin::SNMP->new(
'shortname' => $LABEL,
'usage' => $USAGE
);
$plugin->add_arg(
spec => 'warning|w=s',
help => "-w, --warning=INTEGER:INTEGER\n" .
"Minimum and maximum number of allowable result, outside of
which a warning will be generated.\n",
default => -67
);
$plugin->add_arg(
spec => 'critical|c=s',
help => "-c, --critical=INTEGER:INTEGER\n" .
"Minimum and maximum number of allowable result, outside of
which a critical will be generated.\n",
default => -100
);
$plugin->add_arg(
spec => 'host|H=s',
help => "-H, --host=STRING\n" .
"IP address of Host to check\n"
);
#example add_arg
# $plugin->add_arg(
# 'spec' => 'interface|i=s',
# 'help' => "--interface, -i: Name of the interface to use; use
the\n" .
# " description as returned by
ifDescr.\n",
# 'required' => 0,
# 'default' = 'eth0/0'
# );
#add arguments here
$plugin->getopts;
my $critical = $plugin->opts->critical;
my $warning = $plugin->opts->warning;
my $message;
my $perfdata;
my $LocalRXPower_OID = '.1.3.6.1.4.1.10132.9.1.4.12.0';
my $LocalRXPower;
my $local_return;
my $result = $plugin->get($LocalRXPower_OID);
$LocalRXPower = $result->{$LocalRXPower_OID} / 10;
if ($LocalRXPower < $critical)
{
$message = "CRITICAL: Local RX Power to low to maintain link.
(${LocalRXPower}dBm), ";
$local_return = 2;
}
elsif ($LocalRXPower < $warning)
{
$message = "WARNING: Local RX Power to low to maintain 32-QAM
Modulation. (${LocalRXPower}dBm), ";
$local_return = 1;
}
else
{
$message = "Local RX Power OK (${LocalRXPower}dBm), ";
$local_return = 0;
}
$perfdata = "'local_RX_Power'=$LocalRXPower;$warning;$critical;;";
$plugin->nagios_exit($local_return, $message . "|" . $perfdata);
}
exit check_snmp_mw_rx_power();
Sam Kidman
IT Support Officer
--------------------------
T: 08 9225 0944
<<image001.jpg>>
------------------------------------------------------------------------------ Doing More with Less: The Next Generation Virtual Desktop What are the key obstacles that have prevented many mid-market businesses from deploying virtual desktops? How do next-generation virtual desktops provide companies an easier-to-deploy, easier-to-manage and more affordable virtual desktop model.http://www.accelacomm.com/jaw/sfnl/114/51426474/
_______________________________________________ Nagios-users mailing list [email protected] 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
