Ad Widget

Collapse

Action on discovery to run script on zabbix server not remote host

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • r0k5t4r
    Member
    • Jun 2009
    • 91

    #1

    Action on discovery to run script on zabbix server not remote host

    Hi,

    I have created a shell script to deploy zabbix agent remotely on windows (solaris and linux work is in progress). The script works just fine now I wanted to include this script in the zabbix discovery process.

    I have created a discovery rule for a small test network which checks for ICMP Ping.

    Furthermore I created an action for that discovery rule.

    Discovery status = "Up"
    Service type = "ICMP Ping"
    Host IP = "192.168.1.1-10"

    Link to template "Windows_Workstation"
    Add to group "Windows Workstations"
    Run remote commands
    Send message to User "deploy"

    The action works, I get an email. The only thing that is missing is to run the script on the zabbix server. Is there a way to tell "Run remote commands" to run the script on the zabbix server and not on the discovered remote machine? Maybe create a macro for the hostname of zabbix server?

    If I can get this working would be great, since I'm also planning to deploy puppet client using this method on a large environment (200+ hosts).

    Of course I will share my ideas and provide a howto.

    Regards,
    r0k5t4r
  • r0k5t4r
    Member
    • Jun 2009
    • 91

    #2
    Ok, managed to get this working by simply substituting:

    {HOSTNAME}:sudo /home/zabbix/scripts/deploy.sh {HOSTNAME}

    with

    Zabbix Server:sudo /home/zabbix/scripts/deploy.sh {HOSTNAME}

    but the {HOSTNAME} macro is not resolved on the zabbix server for the remote command:

    Dec 30 14:17:11 zabbix sudo: zabbix : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/home/zabbix/scripts/deploy.sh {HOSTNAME}
    Dec 30 14:17:35 zabbix sudo: zabbix : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/home/zabbix/scripts/deploy.sh {HOSTNAME}
    Dec 30 14:17:59 zabbix sudo: zabbix : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/home/zabbix/scripts/deploy.sh {HOSTNAME}

    Is this not possible? I noticed that in all the discovery notifications macros are not resolved as well.

    Any ideas?

    Comment

    • r0k5t4r
      Member
      • Jun 2009
      • 91

      #3
      The script is now executed!

      i replaced {HOSTNAME} with {DISCOVERY.DEVICE.IPADDRESS}.

      Now I need to find a way to only run the action when there is no Zabbix agent detected...

      Comment

      • r0k5t4r
        Member
        • Jun 2009
        • 91

        #4
        Finally got it all working.

        Automated agent deploying on discovered hosts. WUHU

        I will write a howto next week.

        Comment

        • grlindsay
          Junior Member
          • Aug 2010
          • 2

          #5
          I'm curious on how you were able to make this work. Please post what you ended up doing.

          Thanks!

          Comment

          • r0k5t4r
            Member
            • Jun 2009
            • 91

            #6
            Currently I have this working for Windows only. I didn't have much time yet to implement it for Linux / Solaris. Maybe I have some time tomorrow to write a howto on this.

            Regards,
            r0k5t4r

            Comment

            • niceguy
              Junior Member
              • Aug 2011
              • 4

              #7
              its taking a looooong looong time to write this howto
              maybe it will be a big book of howto's

              Comment

              • defghanistan
                Junior Member
                • Oct 2011
                • 2

                #8
                Would love more info on this

                Any follow up? People still want info on this!

                Comment

                Working...