invoking custom ncpa script

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
kendallchenoweth
Posts: 195
Joined: Fri Sep 13, 2013 10:43 am

invoking custom ncpa script

Post 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,
	);
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: invoking custom ncpa script

Post 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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
nscott
Posts: 1040
Joined: Wed May 11, 2011 8:54 am

Re: invoking custom ncpa script

Post 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.
Nicholas Scott
Former Nagios employee
kendallchenoweth
Posts: 195
Joined: Fri Sep 13, 2013 10:43 am

Re: invoking custom ncpa script

Post 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!
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: invoking custom ncpa script

Post by slansing »

I believe it should have been 1.1? Unless the version number was not changed for some reason.
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: invoking custom ncpa script

Post 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.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
Locked