Page 1 of 1

invoking custom ncpa script

Posted: Tue Nov 19, 2013 3:40 pm
by kendallchenoweth
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,
	);

Re: invoking custom ncpa script

Posted: Wed Nov 20, 2013 1:31 pm
by lmiltchev
Just wanted to give you heads up. We are still working on the issue, but we need a little bit more time for testing.

Re: invoking custom ncpa script

Posted: Wed Nov 20, 2013 3:45 pm
by nscott
kendall

I found the bug that was causing this. Under certain condition, the agent would add erroneous quotes around a plugin, and this was hitting one of those cases. I'm going to fix it, and roll a few other fixes into the next release, should be tomorrow or the next day.

Re: invoking custom ncpa script

Posted: Thu Dec 05, 2013 2:25 pm
by kendallchenoweth
Thanks for the fix. What is the version of the release? Feel free to close this thread when you post this information. I really appreciate your help!

Re: invoking custom ncpa script

Posted: Thu Dec 05, 2013 5:47 pm
by slansing
I believe it should have been 1.1? Unless the version number was not changed for some reason.

Re: invoking custom ncpa script

Posted: Thu Dec 05, 2013 5:48 pm
by sreinhardt
Just a heads up that Nick is still working on this as of last time I spoke with him, and is pushing to get it out shortly! Sorry I forgot to ask about the revision number, but it should be a small increment from the current version, not a major revision.