How to Have An Action Run On Hosts Where A Given Trigger Is Already “True?”

zabbixzabbix-agent

Setup: Zabbix 2.4 | RHEL 6.4

I'm configuring a method to allow Zabbix Agentd services to automatically update their own binaries when a trigger is thrown (using Git as the vessel). Two triggers are in place:

  1. Trigger 1: "Git repo doesn't exist" – Make sure there is a git repository in place where the Zabbix Agentd's binaries are stored.
    a. {Template App Zabbix Agent:vfs.file.exists[/opt/zabbix/.git/config].last()}=0
  2. Trigger 2: "Zabbix Agent version is incorrect." – Trigger if the agent isn't the expected, compiled version. This is set as a user macro.
    a. {Template App Zabbix Agent:vfs.file.cksum[/opt/zabbix/sbin/zabbix_agentd].last()}<>{$LATESTAGENT}
    b. $LATESTAGENT is the cksum() value of the compiled zabbix_agentd binary.
    c. Dependent on Trigger 1

Trigger 1 just ensures if Trigger 2 fires, the agent will be able to run a remote command to perform a git pull and fetch the latest binaries.


Current Situation

The triggers run fine and show my systems where the agent versions don't align. Since then, I've configured a couple actions to go with them to do the dirty work.

  1. Trigger 1 > Run git init in the Zabbix Agentd install path.
  2. Trigger 2 > Run git pull origin master to get the latest bins.

These are just Global Scripts I've created, so I've been able to manually test that they work by clicking any host and selecting the appropriate script for the host.


The Problem

Since I created the triggers first, they are already "triggered;" however, now that I have actions to go with those triggers, I'd like those triggers to "re-trigger" (or reinitialize or re-fire or whatever) to allow the actions to do their thing. Unfortunately, I can't really find a way to do this. Focusing on Trigger 1 (git repo exists), I tried clearing the history on that vfs.file.cksum[/opt/zabbix/sbin/zabbix_agentd] key, but that didn't affect the trigger's state. I've seen some folks mention some SQL or API work to manually modify the trigger state, but it feels like there should be something so much simpler than that!


Summary

  • Created triggers to deploy updated Zabbix Agentd binaries.
  • Created actions to go with triggers.
  • Can't get actions to run on triggers which are already "True"

Anyone have any idea of how I could get my triggers to "trigger again" in order to let the actions do their thing? Thanks for any help on this!

Caveats

  • System CM tools (e.g. Puppet) aren't an option. I need to do this within Zabbix and Git.
  • Cron solutions are out. Tons of servers are in play, so managing those cron jobs and changes (again, no sysCM tool) would be a manual nightmare.

Best Answer

As a workaround, you can temporarily change the trigger to "Multiple PROBLEM events generation", wait until all actions you need are executed, and then switch back.