Plugin Event Command not working (Exit Code 4)

Hi,

i tried to execute a command via event handling in icinga2.

But when it should trigger the event i always get the following error:

warning/PluginEventTask: Event command for object ‘mon-agent1’ (PID: 27929, arguments: ‘/usr/bin/systemctl’ ‘restart’ ‘memcached’) terminated with exit code 4, output: Failed to restart memcached.service: Access denied

I tried:

add line to visudo:

nagios ALL=NOPASSWD: /usr/bin/systemctl restart memcached

and made the script executable with the proper rights.

what do i miss here?

Thanks

Ghost

Did you add “sudo” to the command being executed by Icinga?

Antony.

Hi @Pooh

Thanks for the Reply, i tried with sudo but now i get:

Wir gehen davon aus, dass der lokale Systemadministrator Ihnen die
Regeln erklärt hat. Normalerweise läuft es auf drei Regeln hinaus:

#1) Respektieren Sie die Privatsphäre anderer.
#2) Denken Sie nach, bevor Sie tippen.
#3) Mit großer Macht kommt große Verantwortung.

sudo: Zum Lesen des Passworts ist ein Terminal erforderlich; verwenden Sie entweder die Option -S, um aus der Standardeingabe zu lesen oder richten Sie das

It asks me for a password for the nagios user even after i told not to ask for password when execute the command …

I actually solvedit, dont know if its the best or most “secure” way, but what i did was the following:

i added in visudo:

%sudo ALL=(ALL:ALL) NOPASSWD:ALL

Thank you for leading me to the right direction @Pooh

  1. Can you log in as the nagios user and run that command with sudo?

  2. Does /var/log/auth.log confirm that it really is the nagios user which is
    trying to use sudo?

Antony.