Help with NCPA service check to Warning status.

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
hbouma
Posts: 483
Joined: Tue Feb 27, 2018 9:31 am

Help with NCPA service check to Warning status.

Post 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
hbouma
Posts: 483
Joined: Tue Feb 27, 2018 9:31 am

Re: Help with NCPA service check to Warning status.

Post by hbouma »

Any suggestions for this?
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: Help with NCPA service check to Warning status.

Post 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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
hbouma
Posts: 483
Joined: Tue Feb 27, 2018 9:31 am

Re: Help with NCPA service check to Warning status.

Post 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.
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: Help with NCPA service check to Warning status.

Post 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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
hbouma
Posts: 483
Joined: Tue Feb 27, 2018 9:31 am

Re: Help with NCPA service check to Warning status.

Post 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
hbouma
Posts: 483
Joined: Tue Feb 27, 2018 9:31 am

Re: Help with NCPA service check to Warning status.

Post 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
Last edited by hbouma on Mon Aug 10, 2020 7:04 am, edited 1 time in total.
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: Help with NCPA service check to Warning status.

Post by benjaminsmith »

Hi Henry,

Thanks for sharing your script! That's a good solution.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked