Nagios external commands

Translation of the original in Catalan. Read it in: CatalàCastellano

So long using nagios and I had never had the need to resort to Nagios External Commands. Essentially it is a named-pipe that Nagios uses to receive commands via shell.

  • Syntax to inject the commands. To support this functionality you previously have to have enabled it in the nagios configuration file, you will also find that in the previous link.

  • Supported commands, the list is quite large and we can find things such as forcing a check per host or even disabling the checks on a service or a host.

Below I attach the command you can launch from the prompt to send an order to nagios after ten seconds. In this case we force all the services of a host to be checked.

# des del directori on hi ha la 'named-pipe' sovint anomenada 'nagios.cmd'
now=$(date +%s); next=$(expr $now + 10); echo "[$now] SCHEDULE_FORCED_HOST_SVC_CHECKS;nom_host;$next" > nagios.cmd

To see the result of the command and whether it has been received by nagios we only have to look at the nagios.log file. The log output will be something like this:

data host_server nagios: EXTERNAL COMMAND: SCHEDULE_FORCED_HOST_SVC_CHECKS;nom_host;unix_ts