passive check not working

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Pratapa
Posts: 150
Joined: Tue Oct 01, 2019 1:33 am

passive check not working

Post by Pratapa »

Hi,

We have configured a passive check on one server in Nagios but it is now showing correct results.

Status information is showing as "WARNING: Nagios has not received an alert from host1 for at least 5 minutes"

host1 is a Linux server.

Following is the service definition.

define service {
use oracle-service-passive-template
service_description Oracle Active Sessions: step
host_name host1
check_freshness 1
freshness_threshold 300 ; Service is deemed stale after 5 minutes
check_command check_passive_warning!"Nagios has not received an alert from $HOSTNAME$ for at least 5 minutes"
contact_groups oracle-admins
}

Following is the script placed in crontab of oracle user on host1 server.

##Check DB active sessions
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /home/oracle/DBA_SCRIPTS/check_active_sessions.sh /home/oracle/DBA_SCRIPTS/step_prd.env > /dev/null


We are using the following function.

nagios_notify () {
if [ -z "$NSCA_CODE" ]
then
NSCA_CODE=$RETVAL
fi

$NSCABIN/send_nsca -H $NSCAHOST -p $NSCAPORT -d "," -c $NSCACFG/send_nsca.cfg <<EOF > /dev/null
$HOST,$NSCA_SERVICE_NAME,$NSCA_CODE,$NSCA_MSG
EOF
}


NSCABIN=/usr/local/nagios/bin
NSCACFG=/usr/local/nagios/etc
NSCAHOST=nagios.server
NSCAPORT=5667
HOST=host1
NSCA_SERVICE_NAME="Oracle Active Sessions: ${ORACLE_SID}"
NSCA_MSG="There are ${COUNT} active session(s) in $ORACLE_SID database | activesessions=${COUNT}"

NSCA_CODE based on certain conditions, it can be 0 or 1 or 2.

Please help me in fixing this.



When we are executing the script at command prompt it is working fine.

$sh -x /home/oracle/DBA_SCRIPTS/check_active_sessions.sh /home/oracle/DBA_SCRIPTS/step_prd.env

+ RESULT=1
+ '[' 1 -gt 0 ']'
+ NSCA_CODE=0
+ NSCA_MSG='There are .22 active session(s) in step database | activesessions=.22'
+ nagios_notify
+ '[' -z 0 ']'
+ /usr/local/nagios/bin/send_nsca -H nagios.server -p 5667 -d , -c /usr/local/nagios/etc/send_nsca.cfg
+ rm -f /tmp/tmp.62847.1
+ exit 0
Pratapa
Posts: 150
Joined: Tue Oct 01, 2019 1:33 am

Re: passive check not working

Post by Pratapa »

This is resolved.
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: passive check not working

Post by benjaminsmith »

This is resolved.
Excellent! Good to hear.
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