Ad Widget

Collapse

Macros in remote actions

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jlh
    Junior Member
    • Nov 2006
    • 8

    #1

    Macros in remote actions

    I would like to run external commands directly on the server that generated an event. For example, I want to make sure apache is running, and restart it when it is stopped. So I define a trigger that will run an external command. However, I think it is easier not to define an action for each server I monitor, but only one that will use the {HOSTNAME} macro to know on which server the action will run.
    So it would be nice to be able to put macros in remote commands.
  • hegermi
    Junior Member
    • Dec 2006
    • 19

    #2
    I second this request

    I second this request.

    This would really be usefull.

    Or is there another way to run a script with a hostname parameter when a trigger goes ON?

    Michel
    Last edited by hegermi; 26-03-2007, 07:14.

    Comment

    • James Wells
      Senior Member
      • Jun 2005
      • 664

      #3
      Greetings,
      Originally posted by jlh
      I would like to run external commands directly on the server that generated an event.
      There is a patch for the 1.1.x branch that already provides part of this, though you will have to read the source to fully utilize it. Take a look at PATCH: External scripts. Sarek did a really good job on that patch.

      Also, according to the road map there is supposed to be similar functionality in the 1.4 branch.

      Originally posted by hegermi
      Or is there another way to run a script when a trigger goes ON?
      Certainly. In the Zabbix Configuration, you can create a media type of script, then assign a script to this media type. You then create an alert action that sends notifications to the script. The script needs to be a bit smart, so that it can translate the alerts into actions.

      To get a feel for the arguments that Zabbix passes, you can create a script like the following, and run it for a while;
      Code:
      #!/bin/bash
      #
      #  Simple script to send all Zabbix alerts to Syslog
      #
      /usr/bin/logger -t Zabbix -i "$@"
      This will generate a syslog for each alert, and give you an idea what gets passed.

      Hope it helps.
      Unofficial Zabbix Developer

      Comment

      • Alexei
        Founder, CEO
        Zabbix Certified Trainer
        Zabbix Certified SpecialistZabbix Certified Professional
        • Sep 2004
        • 5654

        #4
        It is implemented in pre-1.3.4.
        Alexei Vladishev
        Creator of Zabbix, Product manager
        New York | Tokyo | Riga
        My Twitter

        Comment

        • hegermi
          Junior Member
          • Dec 2006
          • 19

          #5
          Thanks for the responses,

          I will give this logging a try! If I can pass the hostname to a script then I can do what I want.

          I hope to have a test server some day to evaluate the beta.


          Cheers,

          Michel

          Comment

          • hegermi
            Junior Member
            • Dec 2006
            • 19

            #6
            Any idea what I'm doing wrong?

            013769:20070326:132013 Error executing [/home/zabbix/bin//action1] [Exec format error]

            Script needs a shebang
            Last edited by hegermi; 26-03-2007, 13:27. Reason: got i now

            Comment

            Working...