2

I am using Icinga (Nagios fork) to also monitor uptime of external hosts and services. Currently when looking at the "Critical" count I find it difficult to decide if an internal service is affected (I should take immediate action) or an external service (I just acknowledge the problem).

Is there a way to keep a problem acknowledgement for future down-times of the checked host/service? Is there some way to auto-acknowledge the state change of external hosts/services?

blerontin
  • 364
  • 1
  • 3
  • 13

2 Answers2

3

Have found out how to do auto-acknowledges for external hosts.

First define an event handler for the external host:

define host {
        name            some-external-server
        # ...
        event_handler   handle_external_host
        # ...
}

Then define the command to be used as the event handler:

define command {
        command_name    handle_external_host
        command_line    $USER1$/eventhandlers/acknowledge_host_problem $HOSTNAME$ icingaadmin "Handled by external user"
}

Finally put the event handler script into file /usr/local/icinga/libexec/eventhandlers/acknowledge_host_problem (or where your event handers are installed):

#!/bin/sh

printf_cmd="/usr/bin/printf"
command_file="/usr/local/icinga/var/rw/icinga.cmd"

hostname="$1"
author="$2"
comment="$3"

# get the current date/time in seconds since UNIX epoch
now=`date +%s`

# pipe the command to the command file
$printf_cmd "[%lu] ACKNOWLEDGE_HOST_PROBLEM;%s;1;1;0;%s;%s\n" $now "$hostname" "$author" "$comment" >> $command_file

Don't forget to make the script executable using command "chmod +x" or similar. For details on ACKNOWLEDGE_HOST_PROBLEM see the Icinga documentation.

blerontin
  • 364
  • 1
  • 3
  • 13
0

Thank you! Make script for nagios.

#!/bin/sh

### use "acknowledge hostname" or "acknowledge hostname service" ###
#Example ./acknowledge GPON-Maerchaka-65-D1D2-SPD "1/6 10562_SosinCV_Kot.21_194.226.63.253"
# a list of external commands here: http://www.nagios.org/development/apis/externalcommands/
printf_cmd="/usr/bin/printf"
command_file="/var/lib/nagios3/rw/nagios.cmd"

hostname="$1"
servicename="$2"

#type of comments (Постоянный, т.е. не удаляется после снятия подтверждения)
persistent=0

#Send notification
notification=0

author="script"
comment="auto ack by $0"

# get the current date/time in seconds since UNIX epoch
now=`date +%s`

if [ -n "$servicename" ]; then
    $printf_cmd "[%lu] ACKNOWLEDGE_SVC_PROBLEM;%s;%s;1;%s;%s;%s;%s\n" $now "$hostname" "$servicename" "$notification" "$persistent" "$author" "$comment" >> $command_file
    else
    $printf_cmd "[%lu] ACKNOWLEDGE_HOST_PROBLEM;%s;1;%s;%s;%s;%s\n" $now "$hostname" "$notification" "$persistent" "$author" "$comment" >> $command_file
fi

#Host Name
#Service (if service)
#Sticky Acknowledgement
#Send Notification
#Persistent Comment
#Author
#Comment
Paul
  • 2,755
  • 6
  • 24
  • 35
Denis
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 30 '21 at 18:27