Page 1 of 1

log_service_retries=0 to suppress SOFT Alerts

Posted: Thu Apr 24, 2014 6:56 pm
by barathia
Good Afternoon

I set log_service_retries=0 in the main config file "nagios.cfg", so that it won't the execute event handlers for SOFT State as per the following Document

http://nagios.sourceforge.net/docs/3_0/statetypes.html

But I noticed that the email Notifications for SOFT state is now suppressed but the execution of event handler is still present.

Below command is my event handler which is a 3rd Party tool.

/usr/ISS/iiNagios/bin/ppi -w /usr/ISS/iiNagios/bin -c /usr/ISS/iiNagios/cfg/ppi.cfg -d -e ' Domain = dom2 | OriginSeverity = SERVICE | Host = $HOSTNAME$ | Service = $SERVICEDESC$ | HostAlias = $HOSTALIAS$ | ServiceState = $SERVICESTATE$ | Hostgroupnames = $HOSTGROUPNAMES$ | ContactGroup = $_SERVICECONTACTGROUP$ | AdditionalInfo = $SERVICEOUTPUT$ | DateTime = $LONGDATETIME$ | Address = $HOSTADDRESS$ '

My event handler registers a ticket for each alert so you can imagine how flooded we are with all of these SOFT status Alerts generating a ticket.

How do I stop my event handler from not executing for a SOFT state ?

Regards.

Re: log_service_retries=0 to suppress SOFT Alerts

Posted: Fri Apr 25, 2014 10:39 am
by sreinhardt
That option will only disable logging, not the other actions like event handlers that are performed. What I would suggest doing is either writing a wrapper script or modifying the tool you are using as the event handler. You would want make your handler accept the $SERVICESTATETYPE$ macro and only react when it has a value of HARD not SOFT. Your command might look like:

/usr/ISS/iiNagios/bin/ppi -w /usr/ISS/iiNagios/bin -c /usr/ISS/iiNagios/cfg/ppi.cfg -d -e ' Domain = dom2 | OriginSeverity = SERVICE | Host = $HOSTNAME$ | Service = $SERVICEDESC$ | HostAlias = $HOSTALIAS$ | ServiceState = $SERVICESTATE$ | Hostgroupnames = $HOSTGROUPNAMES$ | ContactGroup = $_SERVICECONTACTGROUP$ | AdditionalInfo = $SERVICEOUTPUT$ | DateTime = $LONGDATETIME$ | Address = $HOSTADDRESS$ | StateType = $SERVICESTATETYPE$'

But again I doubt the event handler right now is set to use that, so you will need to make other changes for this to actually effect anything most likely.

Re: log_service_retries=0 to suppress SOFT Alerts

Posted: Wed Apr 30, 2014 9:11 am
by barathia
Hurray! thanks a lot. I worked it out for events handlers in Hosts and services.

Here is my wrapper script for service event handlers.


First I declared them in the commands

service_wrapper_event_handler $USER1$/service_wrapper_event_handler.sh $HOSTNAME$ "$SERVICEDESC$" "$HOSTALIAS$" $SERVICESTATE$ $SERVICESTATETYPE$ $HOSTGROUPNAMES$ "$_SERVICECONTACTGROUP$" "$SERVICEOUTPUT$" "$LONGDATETIME$" $HOSTADDRESS$

-rwxr-xr-x nagios nagios /usr/local/nagios/libexec/service_wrapper_event_handler.sh

#!/bin/bash

HOSTNAME=$1
SERVICEDESC="$2"
HOSTALIAS="$3"
SERVICESTATE=$4
SERVICESTATETYPE=$5
HOSTGROUPNAMES=$6
SERVICECONTACTGROUP="$7"
SERVICEOUTPUT="$8"
LONGDATETIME="$9"
HOSTADDRESS=${10}


if [ $SERVICESTATETYPE == 'SOFT' ]
then exit
fi
case "$SERVICESTATE" in
OK)
exit 0
;;
WARNING)
/usr/ISS/iiNagios/bin/ppi -w /usr/ISS/iiNagios/bin -c /usr/ISS/iiNagios/cfg/ppi.cfg -d -e " Domain = dom2 | OriginSeverity = SERVICE | Host = $HOSTNAME | Service = $SERVICEDESC | HostAlias = $HOSTALIAS | ServiceState = WARNING | Hostgroupnames = $HOSTGROUPNAMES | ContactGroup = $SERVICECONTACTGROUP | AdditionalInfo = $SERVICEOUTPUT | DateTime = $LONGDATETIME | Address = $HOSTADDRESS "
exit 0
;;
CRITICAL)
/usr/ISS/iiNagios/bin/ppi -w /usr/ISS/iiNagios/bin -c /usr/ISS/iiNagios/cfg/ppi.cfg -d -e " Domain = dom2 | OriginSeverity = SERVICE | Host = $HOSTNAME | Service = $SERVICEDESC | HostAlias = $HOSTALIAS | ServiceState = CRITICAL | Hostgroupnames = $HOSTGROUPNAMES | ContactGroup = $SERVICECONTACTGROUP | AdditionalInfo = $SERVICEOUTPUT | DateTime = $LONGDATETIME | Address = $HOSTADDRESS "
exit 0
;;
UNKNOWN)
exit 2
;;
esac

Then declared this on the Nagios Core main config file.

global_service_event_handler=service_wrapper_event_handler

That all.

Similar logic was used for Hosts.

Re: log_service_retries=0 to suppress SOFT Alerts

Posted: Wed Apr 30, 2014 10:08 am
by tmcdonald
That looks about right. Can we close this up?

Re: log_service_retries=0 to suppress SOFT Alerts

Posted: Thu May 01, 2014 1:33 pm
by barathia
yes please close this. Many thanks.