Ad Widget

Collapse

Run script as Action Operation?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • CeeEss
    Senior Member
    Zabbix Certified Specialist
    • Nov 2007
    • 103

    #1

    Run script as Action Operation?

    Finally upgraded to 2.0.7 all the way from 1.8.10 to get some v2 goodness, particularly (so i thought) the ability to execute a script as an Action Operation. After finally tracking down the fact that the script was erroring (the old AlertScriptsPath chestnut - found that out in the Actions auditlog - nothing in zabbix_server.log ... grrrr), i checked a couple of forum posts and discovered in the 2.0 documentation that alertscripts only pass 3 variables suitable for forming something like an SMS gateway email message. I need to pass {HOST.CONN} to a script that runs traceroute and mtr against the {HOST.CONN) to collect and email me some real-world connectivity data - functionality which Zabbix can't (right?) provide.

    Questions: Why are alertscripts passed-variables so limited? Is there some other way to execute a script at the time selected host(s) become unreachable?
  • eskytthe
    Senior Member
    Zabbix Certified Specialist
    • May 2011
    • 363

    #2
    The variables are not limited to 3 values - if that is your problem (?).You can put a lot of informations / Macros info into the variables and just let your script phase out the information.

    https://www.zabbix.com/documentation...s/media/script.
    BR
    Erik

    Comment

    • CeeEss
      Senior Member
      Zabbix Certified Specialist
      • Nov 2007
      • 103

      #3
      Yes, i was referring to that page when i wrote the post. It says:

      "When alert script is executed it gets 3 command-line variables (as $1, $2 and $3 respectively):"

      To
      Subject
      Message

      I see no mention of {HOST.CONN} or any other var/macro being passed

      thanks

      Comment

      • eskytthe
        Senior Member
        Zabbix Certified Specialist
        • May 2011
        • 363

        #4
        The magic is hidden in your action configuration:
        When you configuring an operation (under actions) for your script you just put {HOST.CONN} in your subject or message field (and maybe others macros and text):

        Hope this make it more clear.

        Comment

        • CeeEss
          Senior Member
          Zabbix Certified Specialist
          • Nov 2007
          • 103

          #5
          Exactly, but i was wanting to execute a script as part of the action that would perform a series of tests (mtr, traceroute, etc) using the passed {HOST.CONN} macro, which would then email me the diagnostics from the script. HOST.CONN and a load of other macros are already presented throught the basic email notification. It seems that all I can do with this is format a message to send to an SMS/pager gateway. Not what i was looking to do at all.

          Originally posted by eskytthe
          The magic is hidden in your action configuration:
          When you configuring an operation (under actions) for your script you just put {HOST.CONN} in your subject or message field (and maybe others macros and text):

          Hope this make it more clear.

          Comment

          • eskytthe
            Senior Member
            Zabbix Certified Specialist
            • May 2011
            • 363

            #6
            No, you can also send the values from the macros to a script of your own.
            In the script you can do your ping, traceroute etc. as you like, and email the results to who ever you want.
            Again look at this page and the script:

            Comment

            • CeeEss
              Senior Member
              Zabbix Certified Specialist
              • Nov 2007
              • 103

              #7
              that page (which i have read) states:

              "When alert script is executed it gets 3 command-line variables (as $1, $2 and $3 respectively):

              To
              Subject
              Message
              "
              where does {HOST.CONN} come into play? Would it be the sole contents of $3 == "message"?

              Originally posted by eskytthe
              No, you can also send the values from the macros to a script of your own.
              In the script you can do your ping, traceroute etc. as you like, and email the results to who ever you want.
              Again look at this page and the script:
              https://www.zabbix.com/documentation...s/media/script

              Comment

              Working...