Ad Widget

Collapse

Template Macros and running custom scripts

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Hetlwe
    Junior Member
    • Sep 2017
    • 2

    #1

    Template Macros and running custom scripts

    Hi,

    I'm facing a issue with custom script getting wrong macro from different template than which is triggering the script to run.

    Not sure if this kind of scenario is even supported, but it makes life a lot easier when configuring simple restart for services. If there are better ways of doing this. I'm free to suggestions.

    How to reproduce this / configure this (Example):
    * Setup different 3 templates
    * Add macro called {$SERVICE.NAME} with value nginx to template 1
    * Add macro called {$SERVICE.NAME} with value php-fpm to template 2
    * Add macto called {$SERVICE.NAME} with value mysql to template 3
    * Configure needed monitoring with triggers.
    * Create following custom script being execute on agent: sudo /usr/bin/systemctl restart {$SERVICE.NAME}
    * Configure action which calls this script when trigger triggers.

    What I'm currently getting is that it only uses service name from template 2 although execution of that script is being initiated from template 1 or 3.
    What i'm expecting is that Action passes correct macro from template 1 to custom script.

    Everything is working fine when i remove macros from template 2 and 3.

    Should this kind of scenario be supported or is there reason why its not?

    Zabbix Server version is 3.4.1
    Last edited by Hetlwe; 26-09-2017, 08:24. Reason: Zabbix version added
  • volter
    Member
    Zabbix Certified Specialist
    • Dec 2011
    • 85

    #2
    If you define a user macro with a given name in several templates and apply them all to one host, one of them will succeed. There is no affinity between the template it came from and triggers to that template, if that is what you expect to happen.

    Comment

    • Hetlwe
      Junior Member
      • Sep 2017
      • 2

      #3
      Yes that's exactly what i was expecting. This would be really handy so that you can avoid having specific actions for every running service.

      Comment

      Working...