Ad Widget

Collapse

Automatic Agent Deployment on discovery (Windows / Linux / Solaris)

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

    #1

    Automatic Agent Deployment on discovery (Windows / Linux / Solaris)

    Hi,

    I have worked out a way how to deploy Zabbix Agent on discovered hosts and wanted to share my idea. Of course this could also be done using Group Policies at least for Windows, but my solution is integrated with Zabbix. Please don't try this on a production network. Setup a small subnet for this and test carefully! You will need an administrator account on the windows machine. If you have a Windows Domain it's probably best to use an account with domain admin privileges. I don't know if you can setup an account under windows that is no administrator but can install software. If yes please let me know.

    First my setup:

    Zabbix 1.8.3 / MySQL / Ubuntu 10.04.4 LTS


    Prerequisites:

    General on Zabbix Server

    Nmap - to detect / guess host operating system
    Samba Server - to serve agent installer files to Windows clients


    Windows Agent deployment

    winexe - to run remote commands from Linux (Zabbix Server) on Windows clients
    Administrator account on the machine where the agent will be deployed. This can be a Domain or Local Administrator Account.


    1. Login or su to zabbix user on your zabbix server.
    Create the following directories under the home of zabbix:

    mkdir -p scripts/logs
    mkdir agents

    Download the attached deploy_agents.tar.gz to the zabbix server /home/zabbix/scripts and extract it.
    Download the windows zabbix agent installer to the zabbix server /home/zabbix/agents. (http://www.google.de)
    Download the winexe static binary to /home/zabbix/scripts and extract it:
    wget http://eol.ovh.org/winexe/winexe-static-081123.bz2
    bunzip winexe-static-081123.bz2


    2. Add an entry to /etc/sudoers for zabbix in order to run deploy.sh as root
    As user root on the zabbix server:

    visudo

    Now add the following lines:

    Cmnd_Alias ZABBIX = /home/zabbix/scripts/deploy.sh, /usr/bin/nmap *

    zabbix ALL = (ALL) NOPASSWD: ZABBIX (make sure this is the last line!)

    3. Edit deploy_zabbag_windows.sh
    The following lines need to edited:

    ZABBIXSERVER=yourzabbiserver.domainname
    DOMAINUSER=DOMAIN/Administrator
    PASSWORD=yourpassword

    if your are using a local admin account remove the DOMAIN in front!


    4. Setup Samba Server

    Install Samba Server via your OS package management system. Edit /etc/samba/smb.conf:

    [zabbix]
    comment = Zabbix Installer Share
    read only = yes
    locking = no
    path = /home/zabbix/agents
    guest ok = yes
    browseable = yes
    public = yes

    Restart the samba server.

    Test deploy.sh

    Before configuring Zabbix to make use of the deploy.sh script I recommend to test it.

    First, check if the sudo command is visible for the zabbix user:

    sudo -l

    The output should look similar to this:

    zabbix@zabbix:~$ sudo -l
    Matching Defaults entries for zabbix on this host:
    env_reset

    User zabbix may run the following commands on this host:
    (ALL) NOPASSWD: /home/zabbix/scripts/deploy.sh, /usr/bin/nmap *

    Now try to run the deploy command using sudo:

    sudo /home/zabbix/scripts/deploy.sh hostname

    The script will try to detect the OS running on 'hostname' and if it is Windows it will trigger the deploy_zabbag_windows.sh script to install the Zabbix Agent. The script will check if the credentials provided are sufficient if not it will exit with an error message indicating this. Once the script has finished verify that the zabbix agent has been installed on the target 'hostname'. If that is the case proceed to configure zabbix.


    5. Create a discovery rule
    Configuration --> Discovery
    Name: Deploy testing
    Checks: Zabbix agent "system.uname"
    IP range: 192.168.0.1-254 (I recommend to test this on a small subnet first!!!)


    6. Add a script
    Administration --> Scripts
    Name: Deploy Agent (or whatever you want)
    Command: sudo /home/zabbix/scripts/deploy.sh {HOST.CONN}


    7. Create Action Rule

    Name=Host discovered, deploy agent (can be any name)
    Discovery status = "Down"
    Service type = "Zabbix agent"
    Host IP = "192.168.0.1-254" (optional, to limit rule on specific subnet(s))

    Run remote commands = Zabbix Server: sudo /home/zabbix/scripts/deploy.sh {DISCOVERY.DEVICE.IPADDRESS}
    Send message to User "admin" (optional, for notification)

    Make sure to use the correct name of your Zabbix Server. It's not the hostname it's the name of the Zabbix server in Zabbix!

    I strongly recommend to test this on a small subnet before using in production. I cannot guarantee it will work, but I'm happy to help if it is not. It works fine in our environment and yes it saved me a lot of time. I'm currently extending the script to allow deploying on Linux and Solaris clients.
    Attached Files
    Last edited by r0k5t4r; 13-01-2011, 15:49.
  • qix
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Oct 2006
    • 423

    #2
    This is a very cool idea. It think could even be extended (via triggers) to automatically upgrade the agents after a Zabbix upgrade
    With kind regards,

    Raymond

    Comment

    • r0k5t4r
      Member
      • Jun 2009
      • 91

      #3
      Yes, this is possible. I already have an item that checks the current version and a trigger severity information showing all the outdated hosts.

      Comment

      • vlam
        Senior Member
        Zabbix Certified Specialist
        • Jun 2009
        • 166

        #4
        Hi

        Has anyone looked into this again and also for deploying agents through the Proxies or Node based setup from the master server. I am also looking for something similar that can be used for upgrading the agents.

        Any help would be really appreciated
        4 Zabbix Frontend Servers (Load balanced)
        2 Zabbix App Servers (HA)
        2 Zabbix Database Servers (HA)
        18 Zabbix Proxy Servers (HA)
        3897 Deployed Zabbix Agents
        6161 Values per second
        X-Layer Integration
        Jaspersoft report Servers (HA)

        Comment

        • kollyka83
          Junior Member
          • Feb 2017
          • 2

          #5
          Bad talloc magic

          Hello

          I've managed to amend the script for our prod. env. and it almost works.

          One things does not. When I run the script: ./deploy.sh A.B.C.D (example production IP address) it runs and shows:

          2017-02-15,13:01 Detected Windows Operating System on 172.16.55.112
          Checking if we have sufficient privilegs on 172.16.55.112...
          Access granted, deploying Zabbix Agent 3.2.3 for Windows...

          I am waiting....and nothing. After I cancel with Ctrl + C

          and it shows the below message:

          "Bad talloc magic value - unknown value"

          I have searched for it and I have found that ones


          Hello world !!! Since today I cannot access the shares on my ubuntu server. First it was one directory which had problems, after a few hours I (and others in the network) were not able to connect to any of them. One of the stacktraces I got : https://launchpad.net/ubuntu/+source/samba/+filebug [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". 0x00007f59e04e5b4c in __libc_waitpid (pid=11175, stat_loc=stat_loc@entry=0x7f...



          I have Samba version 3.6.23-36.el6_8

          Do I need to update it to veriosn 4?

          Or anoy other solution?

          Thank you very much
          Best regards
          Kollyka83

          Comment

          • saiful.islam201428.maix@b
            Junior Member
            • Feb 2017
            • 1

            #6
            How to add wiindows host in ZABBIX

            GOTO congratulatin/hosts click "Creat Host" at the top right side.

            Type your windows host name, , type visible name &your IP address.

            Comment

            • kloczek
              Senior Member
              • Jun 2006
              • 1771

              #7
              To be honest I'm looking on your approach to zabbix agent installation as kind of wheel reinvention.
              Why? Because on Linux and Solaris zabbix agent should be installed using standard standard install technologies like KickStart on Linux or AI (Automated Installer) on Solaris.
              In case of Debian and Debian derivs it is possible to embed zabbix package installation and setup in FAI profile.

              So in case of using KS all what is necessary is provide in such file:
              - repository in which zabbix agent package is available in KS profile preamble
              - mark zabbix agent service as enabled on boot stage
              - list zabbix-agentd package in list of installed packages
              - make base setup of zabbix package.

              So some relevant parts of KS profile may look like:
              Code:
              repo          --name=<repo_name>  --baseurl=<URL_to_repo>
              services      --enabled zabbix-agentd
              
              # Package Selection
              %packages --nobase
              .
              .
              zabbix-agentd
              
              %post --log=/root/install-post.log
              export PATH=/bin:/sbin:/usr/sbin:/usr/sbin
              .
              .
              # ------ Setup: zabbix-agent
              echo "EnableRemoteCommands=1"                > /etc/zabbix/zabbix_agentd/EnableRemoteCommands
              echo "StartAgents=0"                         > /etc/zabbix/zabbix_agentd/StartAgents
              echo "ServerActive=<zabbix_srv_or_prx_addr>" > /etc/zabbix/zabbix_agentd/ServerActive
              On Solaris all what you need is packaged zabbix agent software in form of IPS package with SMF manifest file describing zabbix agent SMF service.
              So in case Solaris installation using AI xml profile all what you in this profile is:
              - add IPS repo which provides zabbix agent IPS package in SC manifest
              - list zabbix agent package in list of packages to install in SC manifest
              - if you have SMF manifest with mapped zabbix setup variables to SMF service variables you can add in SC profile setup changes which should be applied on exact host.

              On Windows you can use single command to do agent setup during installation if you will be using msi package.
              http://uk.linkedin.com/pub/tomasz-k%...zko/6/940/430/
              https://kloczek.wordpress.com/
              zapish - Zabbix API SHell binding https://github.com/kloczek/zapish
              My zabbix templates https://github.com/kloczek/zabbix-templates

              Comment

              • mourya7989
                Junior Member
                • Feb 2017
                • 1

                #8
                Adding windows host

                guys, Just go to the link that I provide now, It's very useful for the Zabbix forum members.. https://www.youtube.com/watch?v=MKO-BwMo4Nw

                this link will guide you on how to add new templates and How to add windows host to your zabbix forum. I really like this video.

                Comment

                Working...