check_ncpa.py parsing -a argument

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

check_ncpa.py parsing -a argument

Post by kendallchenoweth »

I'm using Nagios XI 2012R2.5 on a Centos VM provided by Nagios and have created a NRDS config which passively runs a command on the client server.

The following command works from the command on the client directly.

Code: Select all

nagios@kchenowe-ubuntu:/usr/local/ncpa/plugins$ ./random.pl -w 5 -c 7 -a LOOK_AT_THIS
RANDOM CRITICAL - whatever r=8.78410694495873 a=LOOK_AT_THIS value | random=8.78410694495873;5;7
This is the contents of the nrds.cfg file.

Code: Select all

CONFIG_VERSION="3.4"
CONFIG_OS="Linux"
CONFIG_NAME="sample_config"
URL="http://172.28.154.55/nrdp/"
TOKEN="mytoken"
PLUGIN_DIR="/usr/local/ncpa/plugins"
SEND_NRDP="/usr/local/nrdp/clients/send_nrdp.sh"
TMPDIR="/usr/local/nrdp/clients/tmp"
COMMAND_PREFIX=""
LOG_FILE=""
UPDATE_CONFIG="1"
UPDATE_PLUGINS="1"

command[ncpa-random]=/usr/local/ncpa/plugins/check_ncpa.py  -H `hostname -A` -t 'mytoken'  -P 5693 -M  'agent/plugin/random.pl' -w 5 -c 7  -a LOOK_AT_THIS
Here is the output when I manually run the command.

Code: Select all

nagios@kchenowe-ubuntu:/usr/local/ncpa/plugins$ /usr/local/ncpa/plugins/check_ncpa.py  -H `hostname -A` -t 'mytoken'  -P 5693 -M  'agent/plugin/random.pl' -w 5 -c 7  -a LOOK_AT_THIS
RANDOM OK - whatever r=4.82139144166471 a= value | random=4.82139144166471;;
When this command is run with the check_ncpa.py plugin, my -a argument is ignored. I presume I'm doing something stupid, can you please help? Thanks!

-Kendall Chenoweth
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: check_ncpa.py parsing -a argument

Post by tmcdonald »

Can you run it a few more times and confirm that it's respecting your warn/crit levels? Could be that the random result would return as OK regardless of what -w and -c are set to, indicating that none of the flags are being used.
Former Nagios employee
kendallchenoweth
Posts: 195
Joined: Fri Sep 13, 2013 10:43 am

Re: check_ncpa.py parsing -a argument

Post by kendallchenoweth »

You're right. I should have seen this myself (duh!). Whenever I run my check through the check_ncpa.py wrapper, the -w and -c flags are being ignored. These flags are not being ignored when I run the command without the check_ncpa.py wrapper. So how am I using the ncpa.py wrapper incorrectly? I've shown the both commands below.

This test check script generates a random number and compares it to the -w and -c argument and should produce an error accordingly...

nagios@kchenowe-ubuntu:/usr/local/ncpa/plugins$ /usr/local/ncpa/plugins/check_ncpa.py -H `hostname -A` -t mytoken -P 5693 -M 'agent/plugin/random.pl' -w 1 -c 7 -a kendall
RANDOM OK - whatever r=9.18640158911334 a= value | random=9.18640158911334;;

nagios@kchenowe-ubuntu:/usr/local/ncpa/plugins$ ./random.pl -w 1 -c 7 -a kendall
RANDOM CRITICAL - whatever r=7.84066409179108 a=kendall value | random=7.84066409179108;1;7

Thanks
kendallchenoweth
Posts: 195
Joined: Fri Sep 13, 2013 10:43 am

Re: check_ncpa.py parsing -a argument

Post by kendallchenoweth »

I validated that the built in agent metrics do follow the recommended severities.

nagios@kchenowe-ubuntu:/usr/local/ncpa/plugins$ /usr/local/ncpa/plugins/check_ncpa.py -H `hostname -A` -t mytoken -P 5693 -M 'cpu/percent' -c 0
CRITICAL: Percent was 2.0%,0.0%|'percent_0'=2.0%;;0 'percent_1'=0.0%;;0

I'm guessing that my issue is related to using a custom check script and passing arguments to that custom script. Can you send me an example of using a custom check script with check_ncpa.py; I'll also try to find one on the internet.

I think you found the problem. Thanks for your help!

-Kendall Chenoweth
kendallchenoweth
Posts: 195
Joined: Fri Sep 13, 2013 10:43 am

Re: check_ncpa.py parsing -a argument

Post by kendallchenoweth »

I found a working syntax.

nagios@kchenowe-ubuntu:/usr/local/ncpa/plugins$ /usr/local/ncpa/plugins/check_ncpa.py -H `hostname -A` -t mytoken -P 5693 -M agent/plugin/random.pl/-w\ 0\ -c\ 7\ -a\ kendall
RANDOM WARNING - whatever r=0.327776312633468 a=kendall value | random=0.327776312633468;0;7

Thanks for helping me see the problem!
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: check_ncpa.py parsing -a argument

Post by tmcdonald »

Glad I could get you on the right track. Looks like you beat us to it by about half an hour =)

Gonna close this up now.
Former Nagios employee
Locked