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.
log_service_retries=0 to suppress SOFT Alerts
-
sreinhardt
- -fno-stack-protector
- Posts: 4366
- Joined: Mon Nov 19, 2012 12:10 pm
Re: log_service_retries=0 to suppress SOFT Alerts
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.
/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.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
Re: log_service_retries=0 to suppress SOFT Alerts
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.
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
That looks about right. Can we close this up?
Former Nagios employee
Re: log_service_retries=0 to suppress SOFT Alerts
yes please close this. Many thanks.