Ad Widget

Collapse

Installing/compiling zabbix agent on openSUSE/SLES15

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nprdev
    Junior Member
    • Jul 2023
    • 9

    #1

    Installing/compiling zabbix agent on openSUSE/SLES15

    I wanted to share the result of a couple hours of work trying to get zabbix-agent to compile on SUSE (which doesn't provide packages on its installation media).

    I tried to be as thorough as possible in naming all the lib packages it needs, but I may have missed some as I haven't tried this on a clean machine yet. Worst named lib: No idea why SUSE decided to name it prce-devel and not libpcre-devel.

    Code:
    zypper install -y gcc git make makeinfo autoconf automake glibc-devel-static gettext-tools gcc-c++ libevent libevent-devel libresolv libresolv-devel pcre-devel
    
    cd /usr/src/
    wget https://cdn.zabbix.com/zabbix/sources/stable/6.4/zabbix-6.4.4.tar.gz
    tar -xvf zabbix-6.4.4.tar.gz
    rm zabbix-6.4.4.tar.gz
    cd zabbix-6.4.4/
    
    aclocal && autoreconf -f && automake --add-missing
    
    ./configure --enable-agent --disable-server --enable-ipv6
    
    sed -i "s/^\(LIBPCRE_LIBS.*\)/\1 -lresolve/g" Makefile
    
    CORES=$(nproc)
    env LDFLAGS=-lresolve make -j$CORES 2>&1 | tee log


    Then, to install the binary to the system:

    Code:
    make install​
    The online instructions about compiling zabbix are out of date as zabbix now uses autotools. I had to experiment to find out that "autoreconf" and "automake --add-missing" are needed. It's really hard to find out how to use automake if you're not familiar. Please update the instructions so those compiling will not either waste hours of time figuring this out or, for less patient/experienced sysadmins: give up entirely.

    This may be due to autotools only being v2.69 on SUSE, and not the newer 2.70/2.71; but by default the makefile it makes will not compile with a bunch of cryptic errors about unresolved symbols, due to the fact that it's missing "-lresolve" so the linker won't see DNS functions in glibc.

    I tried to fix this by appending this to "LIBS".

    This also would not work for two reasons:

    1. The makefile, if modified, won't actually re-compile. Something with automake/autotools/make is causing make to think the file was not modified. So in that case I did the nuclear option:

    Code:
    rm -rf /usr/src/zabbix-6.4.4/*
    (do everything again from the beginning).

    2. After a few tries I found out that "LIBS" actually isn't appended to the command line.

    So I hacked it and added "-lresolve" to LIBPCRE_LIBS (which is required by default), before trying to run make.


    .
  • tim.mooney
    Senior Member
    • Dec 2012
    • 1427

    #2
    I'm really confused by your post.

    Aren't the packages you need downloadable here, after selecting "SUSE Linux Enterprise Server" for "OS Distribution": https://www.zabbix.com/download

    Also, going back as far as I can remember, the "Compiling from Source" section of the documentation has mentioned "configure". For example, the 3.0 section of the documentation is very old, but it mentions configure: https://www.zabbix.com/documentation...lation/install

    Comment

    • nzahar
      Junior Member
      • Feb 2024
      • 1

      #3
      Hi nprdev ,

      I am about to start the same exiting journey as you described previously.
      Could you please confirm if it actually compiled at the end ?
      Did you actually create an rpm at last ?
      Since I have a contract to do babysitting for more than 200 LPars on Suse (mainly) and RHEL, perhaps we could work together to maintain a repo as well
      (Yes you guest correctly ... SAP apps... :-)
      Thanks in advance,

      Nikos​

      Comment

      • nprdev
        Junior Member
        • Jul 2023
        • 9

        #4
        In the end I compiled it with the option as indicated.

        When installing SLES, you will want to make sure you've selected the 'development tools' repository (module in SLES parlance) to get access to compiler tools. It's possible to add it later on after you've already installed the machine, but I believe you do have to get the 'name' and 'alias' correct in zypper for things to work properly if you later activate the OS.

        For completion's sake if anyone stumbles upon this in the future, here's my actual solution. Change the agent version as appropriate:

        Code:
        # Makefile IS BROKEN. option/library -lresolve is missing.
        
        zypper install -y gcc git make makeinfo autoconf automake glibc-devel-static gettext-tools gcc-c++ libevent libevent-devel libresolv libresolv-devel pcre-devel
        
        ZBXMVER=6.4
        ZBXVER=6.4.21
        
        cd /usr/src/
        wget https://cdn.zabbix.com/zabbix/sources/oldstable/$ZBXMVER/zabbix-$ZBXVER.tar.gz
        tar -xvf zabbix-$ZBXVER.tar.gz
        rm zabbix-$ZBXVER.tar.gz
        
        cd /usr/src/zabbix-$ZBXVER/
        
        aclocal && autoreconf -f && automake --add-missing
        
        ./configure --enable-agent --disable-server --enable-ipv6
        
        sed -i "s/^\(LIBPCRE_LIBS.*\)/\1 -lresolve/g" Makefile
        
        CORES=$(nproc)
        env LDFLAGS=-lresolve make -j$CORES 2>&1 | tee log
        
        make install​
        
        useradd zabbix
        groupadd zabbix
        usermod -a -G zabbix zabbix
        
        mkdir /var/log/zabbix
        chown root.zabbix /var/log/zabbix
        
        chmod g+w /var/log/zabbix​
        
        
        cat << EOF > zabbix-agent.service
        
        [Unit]
        Description=Zabbix Monitor Agent
        After=syslog.target network.target
        
        [Service]
        Type=forking
        ExecStart=/usr/sbin/zabbix_agentd
        User=zabbix
        Group=zabbix
        PrivateTmp=yes
        RuntimeDirectory=zabbix
        PIDFile=/run/zabbix/zabbix_agentd.pid
        
        [Install]
        WantedBy=multi-user.target
        EOF​
        
        mv zabbix-agent.service /etc/systemd/system​
        ​
        cat << EOF > /etc/logrotate.d/zabbix-agent
        /var/log/zabbix/zabbix_agentd.log {
            weekly
            rotate 7
            compress
            delaycompress
            missingok
            notifempty
            create 0640 zabbix zabbix
            sharedscripts
            size 10M
            sharedscripts
            postrotate
             systemctl restart zabbix-agent.service
             sleep 4
            endscript
        }
        EOF​
        Then, in the config file, the minimum set of options needed:

        Code:
        PidFile=/run/zabbix/zabbix_agentd.pid
        LogFile=/var/log/zabbix/zabbix_agentd.log
        Server=<zabbix server or proxy IP>
        ServerActive=<zabbix server or proxy IP>
        Hostname=<full hostname>​
        Note: if Zabbix does start and systemd reports it down, or systemd ends up killing it, there's a problem with the PIDfile. Both systemd and zabbix need to know where it is, systemd needs to control the /run/zabbix/ directory (as /run is wiped upon boot), and the ownership of said file and folder need to be correct for everything to integrate properly. (Systemd will use that file to see if zabbix is running).

        The log file rotation by default keeps 7 weeks of logs, or 80MB, whichever happens first. You can increase or decrease it if you need to.

        To activate the agent run:

        Code:
        systemctl daemon-reload
        systemctl enable zabbix-agent
        systemctl start zabbix-agent

        Comment

        • Markku
          Senior Member
          Zabbix Certified SpecialistZabbix Certified ProfessionalZabbix Certified Expert
          • Sep 2018
          • 1781

          #5
          Curious: why don't you use the Zabbix-provided SLES 15 packages?

          Markku

          Comment

          Working...