# Event Command runs on Master and Satellite

**URL:** <https://community.icinga.com/t/event-command-runs-on-master-and-satellite/6466>\
**Category:** Icinga 2\
**Created:** [January 14, 2021, 1:08pm UTC](https://community.icinga.com/t/event-command-runs-on-master-and-satellite/6466 "2021-01-14T13:08:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheCry](https://community.icinga.com/user_avatar/community.icinga.com/thecry/32/3747_2.png) [@TheCry](https://community.icinga.com/u/TheCry)\
**Post date:** [January 14, 2021, 1:08pm UTC](https://community.icinga.com/t/event-command-runs-on-master-and-satellite/6466/1 "2021-01-14T13:08:17Z")

</div>

Hi togehter,  
after checking the log i will find out that an event command runs on the master and the satellite.  
But i need this event commad only on the master.  
The log on the satellite shows me this line:

> [2021-01-14 13:56:37 +0100] warning/PluginEventTask: Event command for object ‘[xxxx-server.de](http://xxxx-server.de)!GENESYS\_SERVER\_ALARM’ (PID: 10880, arguments: ‘/usr/lib/nagios/plugins/eventhandler/notification\_flagfile.pl’ ‘-h’ ‘[xxxx-server.de](http://xxxx-server.de)’ ‘-n’ ‘GENESYS\_SERVER\_ALARM’ ‘-s’ ‘CRITICAL’) terminated with exit code 128, output: execvpe(/usr/lib/nagios/plugins/eventhandler/notification\_flagfile.pl) failed: No such file or directory

I’d created the eventhandler in director:

 ![eventhandler](https://community.icinga.com/uploads/default/original/2X/0/0e3d67475b2c19b423cce9d6d60d0a94a7100cd6.png)

> ```
> object EventCommand "set-notification-flag" {
> import "plugin-event-command"
> command = [
> "/usr/lib/nagios/plugins/eventhandler/notification_flagfile.pl"
> ]
> arguments += {
> "-h" = "$host.name$"
> "-n" = "$service.name$"
> "-s" = "$service.state$"
> }
> vars.rpc_service_name = "$service.vars.rpc_service_name$"
> vars.rpc_service_state_id = "$service.state_id$"
> }
> 
> ```

Then i added the new eventhandler to the service template:  
 ![template_passive](https://community.icinga.com/uploads/default/original/2X/a/a7aa14390283b54e371a4a110615c2c7ade3a557.png)

> ```
> template Service "Passive Service Volatile mit Notification Flag Template" {
> check_command = "trap-passive"
> max_check_attempts = "1"
> check_period = "timeperiod-24x7"
> check_interval = 1d
> enable_notifications = true
> enable_active_checks = true
> enable_passive_checks = true
> enable_event_handler = true
> enable_flapping = false
> enable_perfdata = false
> event_command = "set-notification-flag"
> volatile = true
> vars.enable_trap_notification = true
> }
> 
> ```

At last the service:  
 ![service](https://community.icinga.com/uploads/default/original/2X/c/c5aa6d646db72692b5751f7a27264dd90f3cd5b3.png)

How can i configure the eventhandler that the script will only run on ther master zone?

ICINGA is running on Debian 9:

- ICINGA Web: 2.8.2
- director: master
- Icinga: r2.12.3-1

Regards  
Sascha

---

<div class="post-metadata">

**Author:** ![dgoetz](https://community.icinga.com/user_avatar/community.icinga.com/dgoetz/32/917_2.png) [@dgoetz](https://community.icinga.com/u/dgoetz)\
**Post date:** [January 14, 2021, 2:33pm UTC](https://community.icinga.com/t/event-command-runs-on-master-and-satellite/6466/2 "2021-01-14T14:33:09Z")

</div>

This is impossible at the moment, eventhandler will always be executed where the check is executed.

> <https://github.com/Icinga/icinga2/issues/5658>
>
> Hello,
> According to the documentation, an event handler is always launched on the location where the check command has been launched:
> https://www.icinga.com/docs/icinga2/latest/doc/03-monitoring-basics/#event-commands
> If the...

---

<div class="post-metadata">

**Author:** ![TheCry](https://community.icinga.com/user_avatar/community.icinga.com/thecry/32/3747_2.png) [@TheCry](https://community.icinga.com/u/TheCry)\
**Post date:** [January 14, 2021, 3:10pm UTC](https://community.icinga.com/t/event-command-runs-on-master-and-satellite/6466/3 "2021-01-14T15:10:33Z")

</div>

Hi Dirk  
Thanks for you reply and the links.  
The documentation is clear, but i do not understand why the master node run the same eventhandler.  
I‘m using the eventhandler since last year and the master works like i want. Today i‘d checked the logs on the satelite and found the error messages.  
Regards  
Sascha

---

<div class="post-metadata">

**Author:** ![dgoetz](https://community.icinga.com/user_avatar/community.icinga.com/dgoetz/32/917_2.png) [@dgoetz](https://community.icinga.com/u/dgoetz)\
**Post date:** [January 14, 2021, 4:20pm UTC](https://community.icinga.com/t/event-command-runs-on-master-and-satellite/6466/4 "2021-01-14T16:20:01Z")

</div>

Unfortunately it is a simple run on the agent endpoint if the check\_endpoint is set and run on parents if not. It should be at least run in the zone the service is part of for consistent behaviour which would exactly not what you want, but it is not implemented like this. ☹ It also runs on all of them perhaps resulting in multiple restarts of a service or even more bad things, so we can only hope the developers will find a proper solution in the future. So it is totally on Icinga and not you or your configuration.

---

<div class="post-metadata">

**Author:** ![TheCry](https://community.icinga.com/user_avatar/community.icinga.com/thecry/32/3747_2.png) [@TheCry](https://community.icinga.com/u/TheCry)\
**Post date:** [January 15, 2021, 6:08am UTC](https://community.icinga.com/t/event-command-runs-on-master-and-satellite/6466/5 "2021-01-15T06:08:52Z")

</div>

Hi Dirk,  
ok - then I hope that the developers will soon process the open ticket. I believe that an ICINGA setup with multiple zones is not uncommon. Thanks again for the clarification

---

<div class="post-metadata">

**Author:** ![MarcusCaepio](https://community.icinga.com/user_avatar/community.icinga.com/marcuscaepio/32/287_2.png) [@MarcusCaepio](https://community.icinga.com/u/MarcusCaepio)\
**Post date:** [March 15, 2023, 2:19pm UTC](https://community.icinga.com/t/event-command-runs-on-master-and-satellite/6466/6 "2023-03-15T14:19:11Z")

</div>

I also have this problem right now with an event handler, which is configured in the global-templates zone. The check I am running is executed by an satellite. It is a check by\_ssh, so there is no check\_endpoint defined. The satellite connects to the client via SSH and executes a plugin there.  
My thought based on the docs was, the event\_command is only running on the satellite, because the satellite executes the check. But unfortunately both the master and satellite execute the event\_command, what leads to a double launch of a recovery job in AWX (triggered by the AWX API). My dirty workaround is only having the event\_command script on the master. The satellite throws an error in the logs with “file not found”.  
Are there any plans to give the event commands a little bit love? 🙂

Cheers,  
Marcus
