Event_command troubleshooting

Hello,

I’m not able to run a simple script through event_command and I don’t find any way to figure out how to fix it.
When I write an event command to run a simple command:

object EventCommand "tomcat-restart" {
    import "plugin-event-command"
    command = [ "/usr/bin/wget", "http://ftp.gnu.org/gnu/wget/wget-1.5.3.tar.gz" ,"-P", "/tmp/" ]
    arguments = {}
}

I don’t have any problem to execute it, however if I try to use a script:

object EventCommand "tomcat-restart" {
    import "plugin-event-command"
    command = [ "/tmp/tomcat-restart.sh" ]
    arguments = {}
}

where /tmp/tomcat-restart.sh is:

#!/bin/bash
/usr/bin/wget http://ftp.gnu.org/gnu/wget/wget-1.5.3.tar.gz  -P /tmp/

there’s no way:

I will be very thankful for any clue.

I share our services.conf applied:

apply Service "idle-cpu" {
  import "servicio-base"
  check_period = "24x7-CPU"
  check_command = "nrpe"
  vars.nrpe_command = "amz_idle_cpu"
  # command_endpoint = host.vars.endpoint_name
  event_command = "tomcat-restart"
  assign where ( host.vars.os == "Linux" && host.vars.lugar == "amz" && host.vars.kind == "sxp")
}

I share the output I get when we run in debug mode:

[2019-12-09 17:20:35 +0100] notice/Checkable: Executing event handler 'tomcat-restart' for service 'sxp04!idle-cpu'
[2019-12-09 17:20:35 +0100] notice/Process: Running command '/tmp/tomcat-restart.sh': PID 30777
[2019-12-09 17:20:35 +0100] notice/Process: PID 30777 ('/tmp/tomcat-restart.sh') terminated with exit code 128
[2019-12-09 17:20:35 +0100] notice/PluginEventTask: Event command for object 'sxp04!idle-cpu' (PID: 30777, arguments: '/tmp/tomcat-restart.sh') terminated with exit code 128, output: execvpe(/tmp/tomcat-restart2.sh) failed: No such file or directory

Thanks and kind regards.

Hi,

first of all I’m missing this option in your service defination “enable_event_handler = true”. At least this for example is rendering our director installation:
image .
But I don’t find this option in the docs: https://icinga.com/docs/icinga2/latest/doc/03-monitoring-basics/#event-commands. But in our case the EventCommand is working what the director is rendering.

The other thing from your log output is following:
You should check why your script is terminating with exit code 128. Is it possible to run your script /tmp/tomcat-restart.sh in your shell manually with success (with the icinga and root user)?
Also if your permsission are correct because icinga don’t find the script.

Thanks Stevie for your reply.

You’re right. I forgot mentioning we were using a template: servicio-base where we note some base features as enable_event_handler = true.

I’m going to check icinga permissions deeper as you suggest and I will comment any news about.

Kind regards

1 Like