Page 1 of 2

ncpa_passive checks

Posted: Tue Apr 03, 2018 2:56 pm
by nag4csec42
Hello,

I recently implemented ncpa passive checks, and am having a hard time understanding exactly how to add additional passive checks outside the defaults.

I need to accomplish a few different types of passive checks:
- check apt status
- disk health using either megacli or storcli
- disk IO
- quantity of logged in users

I have copied many of the nagios plugins to the servers, (including check_apt), so I could easily use that or any other plugins, but am unsure of how to send the output data to the passive plugin to relay to the nagios server.

thanks in advance!

Re: ncpa_passive checks

Posted: Wed Apr 04, 2018 11:40 am
by npolovenko
Hello, @nag4csec42. This should be fairly simple.

First, put the plugins that you want to use into the plugins folder within the NCPA directory.

Next, in the web browser type in the IP address of the NCPA server:5663. In my example it's:

Code: Select all

https://172.16.153.1:5693
Go to the API menu.
Untitled.png
In the API endpoint select "Plugins"

On the next line select the plugin that you want to use for passive checks

Insert the required arguments in the arguments field

Click on: View in an alternative format -> As an active check, and make sure that:

Code: Select all

Would result in the following output:.... 
Produces the correct output for this plugin.

Next, click on View in an alternative format -> As a passive check.
Copy the command and insert it with all the other standard passive check commands in the cfg file.
Done!

Re: ncpa_passive checks

Posted: Thu Apr 05, 2018 11:08 am
by nag4csec42
Thanks for the detailed info!

check_apt plugin:
The NCPA API generated this and Nagios reported an UNKNOWN status:

Code: Select all

%HOSTNAME%|<service name> = plugins/check_apt/-U/-t 20
I added a space after the -U and this check started working correctly.

Code: Select all

%HOSTNAME%|APT Updates = plugins/check_apt/-U /-t 20

check_uptime plugin:
Same type of deal, I had to add a space after the slash in 'check_uptime/'

NCPA API generated:

Code: Select all

%HOSTNAME%|Uptime = plugins/check_uptime/-t 60
modified & working:

Code: Select all

%HOSTNAME%|Uptime = plugins/check_uptime/ -t 60
---------------------------------------------------

One issue I have is with the disk IO check.
I am able to run command as sudo from command line:

Code: Select all

user@host1:/usr/local/ncpa/etc/ncpa.cfg.d$ sudo ../../plugins/check_diskstat.sh -d sda -W 10 -C 20
summary: 1 io/s, read 824 sectors (15kB/s), write 96 sectors (1kB/s), queue size 0 in 26 seconds | tps=1io/s;;; read=16226b/s;;; write=1890b/s;;; avgrq-sz=20;;; avgqu-sz=0;10;20; await=0ms;;;
Disk IO check in nrdp.cfg file:

Code: Select all

%HOSTNAME%|Disk IO sda = plugins/check_diskstat.sh/-d sda /-W 10 /-C 20
Our nagios user is a member of the sudo group.

Permissions for plugin are: 
-r-xr-xr-x 1 nagios nagios 11687 Mar 29 19:00 check_diskstat.sh*

But, I receive this error in Nagios from the ncpa_passive plugin and when trying to run this command in the NCPA API:

Code: Select all

{ 
"returncode": 2, "stdout": "/usr/local/ncpa/plugins/check_diskstat.sh: 77: /usr/local/ncpa/plugins/check_diskstat.sh: Bad substitution" }
I have attempted to add spaces to the command in the nrdp.cfg file, but cannot figure out how to make this passive check work.

Re: ncpa_passive checks

Posted: Thu Apr 05, 2018 12:02 pm
by npolovenko
@nag4csec42 , Not sure why all your commands have slashes. I'd try to remove them but keep spaces between the arguments:

Code: Select all

%HOSTNAME%|Disk IO sda = plugins/check_diskstat.sh -d sda -W 10 -C 20

Re: ncpa_passive checks

Posted: Fri Apr 06, 2018 9:18 am
by nag4csec42
Untitled 1.docx

Re: ncpa_passive checks

Posted: Fri Apr 06, 2018 9:30 am
by nag4csec42
I removed all the slashes, now Nagios reports "Need device name, ex: sda" for the check_diskstat.sh command, but the command line check works with the same command.

output from command line:

Code: Select all

user@host1:/usr/local/ncpa/etc/ncpa.cfg.d$ sudo ../../plugins/check_diskstat.sh -d sda -W 10 -C 20
summary: 0 io/s, read 916928 sectors (5kB/s), write 654080 sectors (3kB/s), queue size 0 in 82337 seconds | tps=0io/s;;; read=5701b/s;;; write=4067b/s;;; avgrq-sz=39;;; avgqu-sz=0;10;20; await=0ms;;;
nrdp.cfg file config:

Code: Select all

%HOSTNAME%|Disk IO sda = plugins/check_diskstat.sh -d sda -W 10 -C 20
From Nagios:
Untitled 1.docx

Re: ncpa_passive checks

Posted: Fri Apr 06, 2018 9:53 am
by nag4csec42
For the check_users passive check, the command line works:

Code: Select all

user1@host:/usr/local/ncpa/etc/ncpa.cfg.d$ sudo ../../plugins/check_users -w 5 -c 10
USERS OK - 1 users currently logged in |users=1;5;10;0
But the same check in nrdp.cfg does not:

Code: Select all

%HOSTNAME%|Current Users = plugins/check_users -w 5 -c 10
Untitled.png

Re: ncpa_passive checks

Posted: Fri Apr 06, 2018 10:04 am
by lmiltchev
Try the following service definition instead:

Code: Select all

%HOSTNAME%|Disk IO sda = plugins/check_diskstat.sh?args=-d sda&args=-W 10&args=-C 20
Let us know if this helped. Thank you!

Re: ncpa_passive checks

Posted: Fri Apr 06, 2018 10:08 am
by lmiltchev
Just saw your second post. For Current Users, you can try:

Code: Select all

%HOSTNAME%|Current Users = plugins/check_users?args=-w 5&args=-c 10

Re: ncpa_passive checks

Posted: Fri Apr 06, 2018 10:31 am
by nag4csec42
Bummer, I still get these results in Nagios:
Untitled 2.png

Settings in nrdp.cfg:
%HOSTNAME%|Disk IO sda = plugins/check_diskstat.sh?args=-d sda&args=-W 10&args=-C 20
%HOSTNAME%|Disk IO sdb = plugins/check_diskstat.sh?args=-d sdb&args=-W 10&args=-C 20
%HOSTNAME%|Current Users = plugins/check_users?args=-w 5&args=-c 10