Page 1 of 1
Help with NCPA service check to Warning status.
Posted: Tue Aug 04, 2020 10:26 am
by hbouma
Right now, all the NCPA service checks we have to Linux/Windows are returning as a Critical alert if they are not running. Is there a way to make the service a Warning level if it is not running?
For example:
check_ncpa.py -H SOMEHOST -t 'AGENTTOKEN' -P 5693 -M 'services' -q 'service=SERVICENAME,status=running'
And get a Warning level alert if SERVICENAME isn't running?
We are on Nagios XI 5.6.14 on RHEL 7.6 servers. NCPA version 2.1.5
Re: Help with NCPA service check to Warning status.
Posted: Wed Aug 05, 2020 6:56 am
by hbouma
Any suggestions for this?
Re: Help with NCPA service check to Warning status.
Posted: Wed Aug 05, 2020 3:10 pm
by benjaminsmith
Hi Henry,
If you explicitly define a warning threshold with the
-w option in the command arguments, it should return a warning state instead of critical. For example, the following check command would return a warning if 0 or more than once cron process is running.
Code: Select all
./check_ncpa.py -H 192.168.23.142 -t 'welcome=' -P 5693 -M 'processes' -q 'name=crond' -w '1:1'
For less than run process running, the threshold would be:
Code: Select all
./check_ncpa.py -H 192.168.23.142 -t 'welcome=' -P 5693 -M 'processes' -q 'name=crond' -w '1:'
Services are little different than hosts since they have two 'non-ok' states and it will default to the critical state if there is no warning condition set. See the following page for documentation on the threshold ranges.
https://nagios-plugins.org/doc/guidelines.html
Re: Help with NCPA service check to Warning status.
Posted: Wed Aug 05, 2020 3:19 pm
by hbouma
Unfortunately, that doesn't work for me with the services. It returnes a Critical either way.
./check_ncpa.py -H SOMESERVER -t 'token' -P 5693 -M 'services' -q 'service=SomeService,status=running' -w '0:0'
Still returns a Critical result.
Re: Help with NCPA service check to Warning status.
Posted: Thu Aug 06, 2020 10:18 am
by benjaminsmith
Hi Henry,
After testing this again, It looks like the services module in NCPA is either on (OK) or off (critical) since a service is a continuously running program.
https://www.nagios.org/ncpa/help.php#ap ... s-services
You could probably achieve similar results using the process module and setting the critical and warning thresholds based on the number of processes running.
https://www.nagios.org/ncpa/help.php#ap ... -processes
Re: Help with NCPA service check to Warning status.
Posted: Thu Aug 06, 2020 12:06 pm
by hbouma
Thanks, but priocess monitoring doesn't quite fit our need as we have some security features that we are told have to be monitored as a service (Java programs where the command parameters change based on various things). They are important enough to need monitored, but Management wants them as a warning since they are not critical to our applications and too much red on the dashboards just worries them.
If there really is no way to do this, can a feature request be put in for this functionality?
Thanks
Henry
Re: Help with NCPA service check to Warning status.
Posted: Thu Aug 06, 2020 12:48 pm
by hbouma
In the meantime, I did write up a small script to do what I want. When added as a command in Nagios, it will intercept any exit codes of 2 and exit with a 1 instead.
Code: Select all
#!/bin/sh
MESSAGE=$(/usr/local/nagios/libexec/check_ncpa.py $1 $2 $3 $4 $5 $6 $7 $8 $9 "${10}")
RESULT=$?
if [[ $RESULT == "2" ]]; then
MESSAGE=$(echo $MESSAGE | sed 's/CRITICAL/WARNING/g')
echo $MESSAGE
exit 1
elif [[ $RESULT == "0" ]]; then
echo $MESSAGE
exit $RESULT
else
echo $MESSAGE
exit 3
fi
Re: Help with NCPA service check to Warning status.
Posted: Thu Aug 06, 2020 4:02 pm
by benjaminsmith
Hi Henry,
Thanks for sharing your script! That's a good solution.