Icinga 2 Director - Event handler

Would like to seek for some help and advice. I’m a newbie on the Icinga Director and I am creating an event handler that would start a service (postfix) in an NRPE remote client (RHEL 6). I’ve been reading in the documentation and cross reference it to some forums. However I couldn’t get it to work.

Icinga server version:
icinga2 - The Icinga 2 network monitoring daemon (version: 2.12.3)

NRPE version (on a RHEL 6)
NRPE v4.0.0

Here is my command in the Icinga Director:


object EventCommand “postfix_restart” {
import "[plugin-event-command]
command = [ “/usr/local/nagios/libexec/restart_postfix.sh”, “$SERVICESTATE$”,

Also I have the script both in the Icinga Director server and in the NRPE client server:


case “$1” in
# The service just came back up, so don’t do anything…
# We don’t really care about warning states, since the service is probably still running…


case “$2” in


case “$3” in

3 )
echo -n “Restarting postfix service (3rd soft critical state)…”
# Call the init script to restart the Postfix server
/etc/rc.d/init.d/postfix restart

echo -n “Restarting postfix service…”
# Call the init script to restart the Postfix server
/etc/rc.d/init.d/postfix restart
exit 0

The sudoer is also configured both in Icinga Director server and NRPE client server:
Cmnd_Alias CHECKS = /usr/local/nagios/libexec/, /sbin/, /etc/init.d/, /usr/bin/, /etc/rc.d/init.d/*
nagios ALL=(root) NOPASSWD: CHECKS

I tested first in manual from the Icinga Server, I stop the postfix service in the SMTP server and I got this error.

[root@snbx-icinga libexec]# ./check_nrpe -H -p 5666 -c postfix_restart -a ‘$SERVICESTATE$ $SERVICESTATETYPE$ $SERVICEATTEMPT$ $HOSTADDRESS$’
NRPE: Unable to read output

Could someone guide me through please on the proper way of having an event handler for restarting a service?

Hoping for your kind advice and help.

Thanks in advance!

Hi and welcome,

First of all it would be very kind to format your text for better reading. Look at here: Create topics and master Markdown formatting

Now to your question: First step is to create “Event Plugin Command”. It is the same menue like you create a “Plugin Check Command”:

The fields are the same.

In your service (template) you have to choose the defined event command from the list from “event command” field