invoking custom ncpa script
Posted: Tue Nov 19, 2013 3:40 pm
I have a sample custom script that I want to invoke locally via the NCPA agent. It works from the command line, without the ncpa wrapper, but not with the ncpa invoking wrapper. I assume that I'm doing something stupid in the invocation. Can you please help. Thanks!
root@kchenowe-ubuntu:/usr/local/ncpa/plugins# ps -eaf | grep ncpa
nagios 16644 9623 0 09:09 ? 00:00:16 /usr/local/ncpa/ncpa_posix_listener --start
root@kchenowe-ubuntu:/usr/local/ncpa/plugins# netstat -an | grep 5693
tcp 0 0 0.0.0.0:5693 0.0.0.0:* LISTEN
root@kchenowe-ubuntu:/usr/local/ncpa/plugins# ./random.pl -w 5 -c 10 -v
RANDOM OK - 2.5404582738793 value | random=2.5404582738793;5;10
root@kchenowe-ubuntu:/usr/local/ncpa/plugins# ./check_ncpa.py -H localhost -t mytoken -P 5693 -M 'agent/plugin/random.pl' -w 5 -c 10 -v
Could not complete with SSL, or there was an error in the JSON
<type 'int'>
Code: Select all
#!/usr/bin/perl
use Nagios::Plugin;
$np = Nagios::Plugin->new(
shortname => "RANDOM",
usage => "Usage: %s [-v] [-w] [-c] [-a]",
);
$np->add_arg(
spec => "warning|w=s",
help => "-w, --warning=INTEGER:INTEGER. Warning if value > INTEGER:INTEGER",
);
$np->add_arg(
spec => "critical|c=s",
help => "-c, --critical=INTEGER:INTEGER. Critical if value > INTEGER:INTEGER",
);
$np->add_arg(
spec => "argument|a=s",
help => "-a, --argument=argument. Additional argument",
);
$np->getopts;
$random = rand(10);
$threshold = $np->set_thresholds( warning => $np->opts->warning, critical => $np->opts->critical );
$np->add_perfdata(
label => "random",
value => $random,
threshold => $threshold,
uom => "",
);
$np->nagios_exit(
return_code => $np->check_threshold($random),
message => "$random value ".$argument,
);