Ad Widget

Collapse

Passing info to remote commands

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ad@kbc-clearing.com
    Member
    • Sep 2005
    • 77

    #1

    Passing info to remote commands

    We are running on zabbix 1.1.2 and doing some experiments with remote commands on a group of windows machines.

    I found out that it is possible to pass a parameter to the remote command, like
    WORKSTATIONS.WIN32#"c:\zabagent\test.bat" test123
    But this only works with a "static" parameter (like test123).

    But wouldn't it be nice if you could pass on parameters to the remote command i.c. the macro's that can be used in a message body of an email (like {HOSTNAME}, {{HOSTNAME}:{TRIGGER.KEY}.last(0)}, {TRIGGER.NAME} and so on ?

    That would make this feature a lot more powerful to use in groups of hosts.

    For example: I have a CPU measurement running on a group of WIN32 workstations, through a template. If CPU on a workstation exceeds 75%, I want to execute a remote command on this specific workstation.
  • James Wells
    Senior Member
    • Jun 2005
    • 664

    #2
    Greetings,

    Acutally, you can already do this via the script media type and zabbix_get. Basically you create a script media type on the zabbix server that passes the alert information to a script. The script then parses the information and calls zabbix_get with the specific remote commands you want executed.

    To get an idea what the script media type passes, create a simple script that logs the alert information. I use the following;
    Code:
    #!/bin/bash
    #
    #  Simple script to pass Zabbix alerts to Syslog
    /usr/bin/logger "$@"
    With this, I can see all of the information that Zabbix sends and can then build a custom script to support it and pass custom remote commands.
    Unofficial Zabbix Developer

    Comment

    • ad@kbc-clearing.com
      Member
      • Sep 2005
      • 77

      #3
      That's an interesting workaround.
      I just made a test script on my zabbix server and found out which params are passed to the script. That works !

      Now the next step is zabbix_get.
      I find very little documentation on this function.
      I thought it was only to retreive values from agents.
      How can I execute a remote command with zabbix_get ?

      Comment

      • ad@kbc-clearing.com
        Member
        • Sep 2005
        • 77

        #4
        After taking a closer look, I noticed that the hostname of the host where the trigger has become active, is not passed to the script.
        That makes it impossible to launch a remote command on that host.

        Comment

        • James Wells
          Senior Member
          • Jun 2005
          • 664

          #5
          Originally posted by [email protected]
          After taking a closer look, I noticed that the hostname of the host where the trigger has become active, is not passed to the script.
          That makes it impossible to launch a remote command on that host.
          Grrr. Forgot that. One of the things I do with all of my triggers is set them to use [{HOSTNAME}] as part of the trigger name. This way when I get the alert, it shows immediately which host had the issue. For example, on a ping check failure it would show;
          Code:
          Ping Check Failure -- [zabbix01.zabbixtest.org]
          Unofficial Zabbix Developer

          Comment

          • ad@kbc-clearing.com
            Member
            • Sep 2005
            • 77

            #6
            That's a good workaround for the hostname.
            But do you know how to execute a remote command with zabbix_get ??

            Comment

            • James Wells
              Senior Member
              • Jun 2005
              • 664

              #7
              Originally posted by [email protected]
              That's a good workaround for the hostname.
              But do you know how to execute a remote command with zabbix_get ??
              You simply call the zabbix get with something like the following;
              Code:
              zabbix_get -h <Hostname to send to> -p <Port That Agent is Listening on> -k <Key you want to send>
              There are a couple of ways of doing the key, personally I prefer to use the method I describe in UserParameter Blues
              Unofficial Zabbix Developer

              Comment

              Working...