Ad Widget

Collapse

Zabbix client install script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • just2blue4u
    Senior Member
    • Apr 2006
    • 347

    #1

    Zabbix client install script

    I just made a small script which helps me to install and upgrade zabbix agents on our servers.

    It was written for DELL PowerEdge servers running CentOS 5.0 OS, but it works on other hard- and software (tested on Fedora Core) as well.
    The script is configurable, so not-RedHat-based linux distros might also work.

    Top features:
    - compiles and installs the desired zabbix agent on the local system
    - also installs required software like gcc via yum or apt
    - installs the net-snmp and DELL OpenManage (Server Admin) software if desired

    All of you who still are interested, here's the Script and further information:
    - German Version: http://www.heiwu.de/myfiles/install_...603_release.sh
    - English Version: http://www.heiwu.de/myfiles/install_...603_release.sh

    I post this code because i want to share it with all who are interested.
    Because it's poorly tested, please read through my code, evtl. run it and share your experience here! If i get enough feedback, i'll debug and improve the script.

    Here is a detailed description what the script does:
    1.) Configuration
    The configuration is done in the first few lines of the script. Open it with your favourite Text editor, i suggest one with syntax highlighting, and view/change the variables as desired.

    a) Files:
    The script needs 3 files:
    - The zabbix sources in tar.gz format (like zabbix-1.4.5.tar.gz)
    - zabbix_agentd.conf file (this may already be modified (Server, UserParameter, ...) and will be copied into /etc/zabbix/ by the script)
    - An initscript (will be copied into /etc/init.d/)
    It doesn't matter where these files are, but i suggest to put them into the same directory where this script is.
    If so, you may set "srcpath" to "here". The script will change it to its working directory then.
    If you placed the files somewhere else, set "srcpath" to the path where the zabbix sources are located.
    then set "cfgfile" and "initfile" so they match the location of the zabbix_agentd.conf and initscript. You may use "$srcpath" if the are located in the same directory as the sources are.

    b) Zabbix Version to install:
    set "version" to the Zabbix version you want to install. together with the content of "srcpath" the script makes the path- and filename for the sourcefile. If you set it to "latest", the script expects a file "zabbix-latest.tar.gz" which contains the sources. That file may be a symlink pointing to the source file.

    c) Dependencies:
    A fresh installed system doesn't always have a compiler installed. This script has 2 variables containing lists of all desired software packets. "deps" is for software that's installed if zabbix is installed without snmp, "deps_snmp" if it's installed with snmp and dell omsa. You may add all software packets you want to, never mind if needed for zabbix/gcc or other software.

    d) Options for ./configure:
    The content of this variables will be passed to the ./configure script.

    e) snmpd.conf
    It SNMP will be installed, this script needs to know where the snmpd.conf file will be, so it can modify the file with the Data needed for DELL OMSA. Default is for RedHat systems.

    f) Packet Manager:
    RedHat systems use yum to install needed packets. If you want to use this script on a debian based OS, set it to use APT. The Script will put the content of this variable together with the content of the $deps, so watch out that it fits. The Default values as example:
    cmd_pktmgr="yum -y install"; and deps="gcc"
    Line 103 in the script: "$cmd_pktmgr $deps_snmp" will result in:
    "yum -y install gcc". Line 125: "$cmd_pktmgr srvadmin-base" -> "yum -y install srvadmin-base". last call is Line 133 "$cmd_pktmgr $deps".

    2) Script
    a) Preparing the script
    First, the wildcards "here" and "scrpath" are checked and changed into usable values. srcpath becomes the absolute path of the script. WATCH OUT, DOESN'T WORK IF SCRIPT IS CALLED WITH ../ !!! Version becomes the zabbix version number of the release that is stored in the given tar.gz file.

    b) unpacking sources
    the sources are unpacked into the homedir of the currend user.

    c) checking/preparing system
    if cfgfile and initfile are readable, you will be asked if you want to install zabbix with or without snmp and dell omsa.
    if snmp desired, the packets listed in deps_snmp are installed. Then each is checked via "rpm -q $packet-name". Option for dpkg is missing at the moment, maybe one can tell and test how you check the packets with dpkg? Then the SNMP Software and Dell OMSA packets are installed.
    If no snmp is wished, only the software in deps is installed.

    d) configure and install Zabbix Agent
    Now the system should be ready to configure and install zabbix.
    For both, logfiles are written and all output gets in there, so the screen keeps tidy. When the configuration is done, the tail of the log is displayed so you can check if everything was ok. after 10 seconds "./make install" is called.

    e) System configuration
    When Zabbix is installed, the user account "zabbix" is created if it doesn't already exist. Then then directories are created for log, config and PID-File and owned to zabbix.
    Initscript and Configfile configured at the beginning of the script are copied into their proper locations. Does the path /etc/init.d/ work for debian systems, too?
    Nest, chkconfig is told to run zabbix in level 3,4 and 5. here someone rumming debian might get problems. Solution is needed for debian systems...
    Last step is to add zabbix port 10050 to /etc/services.

    f) Testing and start
    several tests are made and the server is started if all are ok.


    That's it!

    Please give me feedback about this script! I spent many hours on it, so i hope someon is interested in this...


    We all know nobody's perfect, and more than ever software.
    Here's the first known bug:
    - Calling the Script relative, beginning with "../" doesn't work
    Workaround: Please call it absolute (or relative begin path with "./")

    Known Problems:
    - Debian Users might run into trouble when installed packets are checked, as most systems don't have rmp installed...
    6
    Yes
    66.67%
    4
    No
    33.33%
    2

    The poll is expired.

    Big ZABBIX is watching you!
    (... and my 48 hosts, 4513 items, 1280 triggers via zabbix v1.6 on CentOS 5.0)
  • antani
    Member
    • Apr 2008
    • 50

    #2
    i suggest to use global variables on top instead to search for text to replace in all the code.

    You may moreover consider to wget source code from inside the script and wget some page from zabbix.com grep-ing the latest version.

    Good script. thanks.

    Comment

    • just2blue4u
      Senior Member
      • Apr 2006
      • 347

      #3
      use global variables on top instead to search for text to replace in all the code
      Sorry, i don't quite understand what you mean...
      I use variables in the top which contain text...

      As this script needs the config and initscript anyway, i don't see any advantage in wgetting the sources except in the case there is a new release that isn't downloaded jet. But i don't think it's a good idea to install a client version without checking its fixes, features and already known bugs first.
      In short: it's a security and performance thing.

      To wget the zabbix website for the latest stable release is a really fine thing, thanks!
      I'll modify the script to ask the user if he wants to download that version instead of using his outdated "latest" version!

      Thanks for your feedback!
      Big ZABBIX is watching you!
      (... and my 48 hosts, 4513 items, 1280 triggers via zabbix v1.6 on CentOS 5.0)

      Comment

      • OneLoveAmaru
        Member
        • Jan 2008
        • 41

        #4
        Debian is much different than any red hat based distro's. The first half of your script isn't really needed with Debian, as zabbix server and agent are in it's repositories. Debian Etch has version 1.1.4, which is quite old. All of our systems run Debian Etch but I created 2 VM's at different locations running Ubuntu 8.04 Jeos distro. It's customized to run as a VM and in it's repositories it has zabbix server and agent 1.4.4. There is no need to compile anything in Debian or Ubuntu.

        In any Debian based distro, you can type in "aptitude install zabbix-server zabbix-agent" and it will list all dependencies and ask you if you want to install them. Apt-get also does the same thing but i've noticed aptitude is a little bit better with dependencies. Anyways, with the aptitude install zabbix-server zabbix-agent, it will list mysql server, apache, etc. I can't remember if snmpd is a dependency for zabbix-server or not. I'm pretty sure it is though.

        Yes, you can search for packages in Debian just like Red Hat. You can use aptitude to just search all packages and hit Shift and + at the same time and it'll tell it to install AND it will pick up all dependencies. There is also some dpkg commands to search but I never use them with the nice aptitude gui.

        So pretty much the first half of your script could be replaced with one command for zabbix and it's dependencies. Then you could do a wget on the Dell OMSA package from Sara.nl's ftp site and then do a dpkg -i on it. The only problem with dpkg is it doesn't install the dependencies for you automatically like apt-get or aptitude. You would need to run a dpkg -i then an apt-get install -f, then it will go out and get the dependencies and install.

        One of these days when I am not busy.. which isn't a lot, I'll just write up a new script to install the Dell OMSA packages and zabbix agent on Debian distro's and post it here.

        Comment

        • just2blue4u
          Senior Member
          • Apr 2006
          • 347

          #5
          Yes, i know there are precompiled Zabbix packets for debian, but i experienced problems with support of outdated (meaning "not the latest") version of zabbix, because this forum is the knowledge- and helpbase #1, and most of this threads are about the latest versions. So i recommend self-compiled zabbix version.

          Thanks for your suggestion with the install of the OpenManage binarys.

          So far to the installation of the Tools, but what about the rest of the script?
          I think, configuring the system is also a bit different.


          If you find the time to write a script for debian, feel free to use parts of mine if you want to.
          Big ZABBIX is watching you!
          (... and my 48 hosts, 4513 items, 1280 triggers via zabbix v1.6 on CentOS 5.0)

          Comment

          • bbrendon
            Senior Member
            • Sep 2005
            • 870

            #6
            I'm reading this thread and wondering.... Why are you making your life so difficult?

            Unix has a bazillion toys that do what you're trying to do in a very clean way.

            1. Create a package for your agent. This is essential if you're planning to deploy software on unix. Even sun.

            2. Install and configure puppet on all of the servers you run zabbix on. Now, all you have to do is edit two lines (approx.) on your puppet server and whammo! -- Your server has a zabbix agent installed, configured, and running.

            Q&A
            How long did it take to install and configure the agent? < 5 seconds
            How easy is it to uninstall? < 5 seconds
            Do you have to login to the server you're installing on? No
            Is there a learning curve for puppet? Probably yes for most people.
            Is it worth the time/effort to deploy puppet? Depends on how good you are and how many servers you have.

            Unofficial Zabbix Expert
            Blog, Corporate Site

            Comment

            • just2blue4u
              Senior Member
              • Apr 2006
              • 347

              #7
              So i went to http://reductivelabs.com/trac/puppet and went through the descriptions and information about puppet.

              I don't think this is what i searched for, as puppet seems to be a really big and mighty tool. It doesn't make sense to install it just for distributing zabbix on our hosts. I don't want to install a software and configure it before i can install zabbix. That's why i made the script.

              If i see this wrong, you're welcome to give me a short summary what puppet really is. Else i'll take a look at it when i have much time to try and test new tools...

              Thanks anyway for your feedback and opinion!
              Big ZABBIX is watching you!
              (... and my 48 hosts, 4513 items, 1280 triggers via zabbix v1.6 on CentOS 5.0)

              Comment

              • xs-
                Senior Member
                Zabbix Certified Specialist
                • Dec 2007
                • 393

                #8
                Well, a configuration distribution tool makes sense to use in any environment with +10 hosts.
                We use cfengine for this, but its basically the same as puppet.

                You really dont want to manually change configs on a large number of machines (time, user errors, etc)

                Comment

                • just2blue4u
                  Senior Member
                  • Apr 2006
                  • 347

                  #9
                  i understand the advantages of such a tool.
                  When i have finished optimizing zabbix, i'll have a look!
                  Thanks for the hints!
                  Big ZABBIX is watching you!
                  (... and my 48 hosts, 4513 items, 1280 triggers via zabbix v1.6 on CentOS 5.0)

                  Comment

                  • luckystar09
                    Junior Member
                    • Aug 2009
                    • 1

                    #10
                    Interesting thought, i completely agree with your perspective...
                    script install

                    Comment

                    Working...