define check_xi_ncpa output status using regex

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
meganwilliford
Posts: 101
Joined: Tue Aug 06, 2019 7:49 am

define check_xi_ncpa output status using regex

Post 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']
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: define check_xi_ncpa output status using regex

Post 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
meganwilliford
Posts: 101
Joined: Tue Aug 06, 2019 7:49 am

Re: define check_xi_ncpa output status using regex

Post 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.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: define check_xi_ncpa output status using regex

Post 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
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked