Page 1 of 1

define check_xi_ncpa output status using regex

Posted: Mon Jun 08, 2020 3:10 pm
by meganwilliford
I am attempting to use the check_xi_ncpa command to verify if a string exists when I query the api and then define what the output status should be if it does exist.

Current Check:
-t 'token' -P 5693 -M 'disk/logical/|data/opts'

Current Output:
OK: Opts was ['rw,nosuid,nodev,relatime,attr2,inode64,sunit=16,swidth=8192,noquota']

Is it possible to set the check options to return a Critical status if "nosuid" exists in the output? I am attempting to do some sort of match regex but no luck so far. Ideally if "nosuid" exists when running the check this is what the output would look like:

CRITICAL: Opts was ['rw,nosuid,nodev,relatime,attr2,inode64,sunit=16,swidth=8192,noquota']

Re: define check_xi_ncpa output status using regex

Posted: Mon Jun 08, 2020 5:00 pm
by ssax
The functionality to do that doesn't currently exist. Your only options would be to find a plugin that checks for nosuid and call that plugin, write your own plugin and call that, or write a wrapper script on the XI side that would run the NCPA command, parse it to do what you'd like, then adjust the exit code/output accordingly.

If you would like that functionality added, you can submit a feature request here:

https://github.com/NagiosEnterprises/ncpa/issues

Re: define check_xi_ncpa output status using regex

Posted: Wed Jul 15, 2020 4:10 pm
by meganwilliford
Thanks for the response! I was actually able to figure out another way:

/usr/local/nagios/libexec/check_http -H <hostname> -p 5693 -S -u '/api/disk/logical/|data/opts?token=<token>&check=1' -r .*nosuid.* --invert-regex

You can close this thread.

Re: define check_xi_ncpa output status using regex

Posted: Wed Jul 15, 2020 4:21 pm
by scottwilkerson
meganwilliford wrote:Thanks for the response! I was actually able to figure out another way:

/usr/local/nagios/libexec/check_http -H <hostname> -p 5693 -S -u '/api/disk/logical/|data/opts?token=<token>&check=1' -r .*nosuid.* --invert-regex

You can close this thread.
Great

Locking thread