Ad Widget

Collapse

Zabbix Agent RPM

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jojo
    Member
    • Jul 2006
    • 57

    #1

    Zabbix Agent RPM

    Hey all, just figured i'd share my zabbix agent rpm with ya'll.



    The 1.1.2 agent is NOW AVAILABLE!! scroll towards the bottom for the link!!!




    Heres the overview:

    All files installed under /opt/zabbix
    able to be service start|stop|restart etc
    ie:
    service zabbix_agentd start

    After it installs it automatically starts well. We had a version of this rpm which automatically set the server IP which made distributing and installing the zabbix agent across a few hundred machines very easy.. just copy the rpm to the machine... rpm -ivh zabbix-agentd-1.1-1.i386.rpm and then move on to the next machine knowing that it is installed and already working.

    directory structure:

    /opt/zabbix
    /opt/zabbix/bin <--- exec's obviously
    /opt/zabbix/doc <--- Documentation
    /opt/zabbix/etc <--- Configuration files
    /opt/zabbix/log <--- log files
    /opt/zabbix/scripts <--- useful place to store custom scripts

    rpm able to be downloaded from http://www.northmeadaquafit.com.au/f...1.1-1.i386.rpm

    I'll post up the .spec file etc later on. It's been tested on FC3, 4 and 5 and also centos.

    I tried creating the server RPM but it wont compile properly with static bins and it wouldn't give me the libs directory either.. Long story short i had too many problems getting it to install properly on other systems. Hence me wanted to build with --enable-static
    It was good, once you installed it, the server was completely configured and ready to go. database and all.
    Last edited by jojo; 11-10-2006, 15:55.
  • jojo
    Member
    • Jul 2006
    • 57

    #2
    HTML Code:
    %define debug_package %{nil}
    
    Name:		zabbix-agentd
    Version:	1.1
    Release:	1
    Group:		System Environment/Daemons
    License:	GPL
    Summary:	ZABBIX network monitor agent
    Vendor:		ZABBIX SIA
    URL:		[url]http://www.zabbix.org[/url]
    Packager:	Sol Tutaki <[email protected]>
    Source:		zabbix-1.1.tar.gz
    
    Autoreq:	no
    Buildroot: 	%{_tmppath}/%{name}-%{version}-buildroot
    
    %define _prefix         /opt/zabbix
    %define zabbix_bindir	%{_prefix}/bin
    %define zabbix_confdir	%{_prefix}/etc
    %define zabbix_initdir	%{_sysconfdir}/init.d
    %define zabbix_docdir	%{_prefix}/doc
    %define zabbix_piddir	/var/tmp
    %define zabbix_logdir	%{_prefix}/log
    %define zabbix_scriptsdir %{_prefix}/scripts
    
    %description
    The ZABBIX agent is a network monitor
    
    %prep
    %setup -q -n zabbix-1.1
    
    %build
    %configure --prefix=%{_prefix} --enable-agent
    make
    
    %clean
    rm -fr $RPM_BUILD_ROOT
    
    %pre
    # create ZABBIX group
    if [ -z "`grep zabbix /etc/group`" ]; then
      /usr/sbin/groupadd zabbix >/dev/null 2>&1
    fi
    
    # create ZABBIX user
    if [ -z "`grep zabbix /etc/passwd`" ]; then
      /usr/sbin/useradd -g zabbix -c "Zabbix user account" -s /bin/false zabbix >/dev/null 2>&1
    fi
    
    %install
    rm -fr $RPM_BUILD_ROOT
    
    # copy documentation
    install -d %{buildroot}%{zabbix_docdir}
    install -m 644 AUTHORS %{buildroot}%{zabbix_docdir}/AUTHORS
    install -m 644 COPYING %{buildroot}%{zabbix_docdir}/COPYING
    install -m 644 NEWS %{buildroot}%{zabbix_docdir}/NEWS
    install -m 644 README %{buildroot}%{zabbix_docdir}/README
    
    # copy binaries
    install -d %{buildroot}%{zabbix_bindir}
    install -s -m 755 src/zabbix_agent/zabbix_agentd %{buildroot}%{zabbix_bindir}/zabbix_agentd
    
    # copy config files
    install -d %{buildroot}%{zabbix_confdir}
    install -m 755 misc/conf/zabbix_agentd.conf %{buildroot}%{zabbix_confdir}/zabbix_agentd.conf
    
    # copy startup script
    install -d %{buildroot}%{zabbix_initdir}
    install -m 755 misc/init.d/nighthawk/zabbix_agentd %{buildroot}%{zabbix_initdir}/zabbix_agentd
    
    # Log folder
    install -d %{buildroot}%{zabbix_logdir}
    
    # Custom user scripts folder
    install -d %{buildroot}%{zabbix_scriptsdir}
    
    %post
    # configure ZABBIX agent daemon
    sed  -i -e "s#Hostname=localhost#Hostname=`uname -n`#g" \
    	-e "s#PidFile=/var/tmp/zabbix_agentd.pid#PidFile=%{zabbix_piddir}/zabbix_agentd.pid#g" \
    	-e "s#LogFile=/tmp/zabbix_agentd.log#LogFile=%{zabbix_logdir}/zabbix_agentd.log#g" \
    	%{zabbix_confdir}/zabbix_agentd.conf
    
    # Make sure the zabbix server is added into chkconfig
    chkconfig --add zabbix_agentd
    chkconfig zabbix_agentd on
    
    # Add the zabbix agentd into /etc/services
    # useful when doing a netstat -at
    if [ -z "`grep -i "Zabbix agent" /etc/services`" ]; then
      cat >>etc/services <<EOF
    zabbix_agentd   10050/tcp                       # Zabbix agent
    EOF
    fi
    
    # Finally, start the agentd up
    /sbin/service zabbix_agentd start
    /sbin/service zabbix_agentd status
    
    %preun
    /sbin/service zabbix_agentd stop || true
    rm -f %{zabbix_piddir}/zabbix_agentd.pid
    if [ $1 -eq 0 ] ; then
            chkconfig --del zabbix_agentd
    fi
    
    %postun
    rm -f %{zabbix_piddir}/zabbix_agentd.pid
    rm -f %{zabbix_logdir}/zabbix_agentd.log
    
    %files
    %defattr(0755,zabbix,zabbix)
    
    %dir %{zabbix_docdir}
    %attr(0644,zabbix,zabbix) %{zabbix_docdir}/AUTHORS
    %attr(0644,zabbix,zabbix) %{zabbix_docdir}/COPYING
    %attr(0644,zabbix,zabbix) %{zabbix_docdir}/NEWS
    %attr(0644,zabbix,zabbix) %{zabbix_docdir}/README
    
    %dir %{zabbix_logdir}
    
    %dir %{zabbix_scriptsdir}
    
    %dir %{zabbix_confdir}
    %attr(0644,zabbix,zabbix) %config(noreplace) %{zabbix_confdir}/zabbix_agentd.conf
    
    %dir %{zabbix_bindir}
    %{zabbix_bindir}/zabbix_agentd
    
    %{zabbix_initdir}/zabbix_agentd
    
    %changelog
    * Fri Aug 18 2006 Sol Tutaki <[email protected]>
    - 1.1
    - All files installed under /opt/zabbix
    - Autoconfiguration scripts done and configured
    
    * Thu Dec 01 2005 Eugene Grigorjev <[email protected]>
    - 1.1beta2
    - initial packaging

    Comment

    • jojo
      Member
      • Jul 2006
      • 57

      #3
      i also added another few lines to the %post section just before it starts the service up:

      # Add the scripts folder to the PATH variable
      # This will make calling custom scripts easier
      export PATH=`echo $PATH`:/opt/zabbix/scripts

      makes it easier to call the scripts when you place them in the /opt/zabbix/scripts directory.


      but i haven't had a chance to compile it yet to include that part

      Comment

      • jojo
        Member
        • Jul 2006
        • 57

        #4
        This is what i had for the zabbix server .spec file. You can see that it was pretty much self sufficient. I had to manually edit a few files to get it to work with the /opt/zabbix installation part and i will be posting the patches up as well.

        - I couldn't get it to install properly. Kept asking for all kinds of packages n stuff to be installed. it became too much of a hastle to try and compile with the --enable-static flag. It would compile easy enough without that flag but wouldn't install due to a whole heap of problems... anyways, if someone wants to have a crack at it, heres the .spec that i came up wit... it's pretty thorough.

        HTML Code:
        %define debug_package %{nil}
        
        Name:		zabbix-server
        Version:	1.1
        Release:	1
        Group:		System Environment/Daemons
        License:	GPL
        Summary:	ZABBIX network monitor server
        Vendor:		ZABBIX SIA
        URL:		http://www.zabbix.org
        Packager:	Sol Tutaki <[email protected]>
        Source:		zabbix-1.1.tar.gz
        Autoreq:	no
        BuildPrereq:    mysql-devel, net-snmp-devel, mysql-server, php
        Buildroot: 	%{_tmppath}/%{name}-%{version}-buildroot
        
        %define apache_sysconfdir       /etc/httpd
        %define _prefix         	/opt/zabbix
        %define zabbix_bindir		%{_prefix}/bin
        %define zabbix_datadir		%{_prefix}/misc
        %define zabbix_confdir		%{_prefix}/etc
        %define zabbix_initdir		%{_sysconfdir}/init.d
        %define zabbix_docdir		%{_prefix}/doc
        %define zabbix_piddir		/var/tmp
        %define zabbix_logdir		%{_prefix}/log
        %define zabbix_phpfrontend      %{_prefix}/www
        %define zabbix_libdir           %{_prefix}/lib
        %define dbuser			root
        %define dbpass			
        
        %description
        The ZABBIX server is a network monitor
        
        %prep
        %setup -q -n zabbix-1.1
        
        %build
        %configure --prefix=/opt/zabbix --with-mysql --with-net-snmp --enable-server
        make
        
        %clean
        rm -fr $RPM_BUILD_ROOT
        
        %pre
        # create ZABBIX group
        if [ -z "`grep zabbix /etc/group`" ]; then
          /usr/sbin/groupadd zabbix >/dev/null 2>&1
        fi
        
        # create ZABBIX uzer
        if [ -z "`grep zabbix /etc/passwd`" ]; then
          /usr/sbin/useradd -g zabbix -c "Zabbix user account" -s /bin/false zabbix >/dev/null 2>&1
        fi
        
        %install
        rm -fr $RPM_BUILD_ROOT
        
        # copy documentation
        install -d %{buildroot}%{zabbix_docdir}
        install -m 644 AUTHORS %{buildroot}%{zabbix_docdir}/AUTHORS
        install -m 644 COPYING %{buildroot}%{zabbix_docdir}/COPYING
        install -m 644 NEWS %{buildroot}%{zabbix_docdir}/NEWS
        install -m 644 README %{buildroot}%{zabbix_docdir}/README
        
        # copy binaries
        install -d %{buildroot}%{zabbix_bindir}
        install -s -m 755 src/zabbix_server/zabbix_server %{buildroot}%{zabbix_bindir}/zabbix
        
        # copy config files
        install -d %{buildroot}%{zabbix_confdir}
        install -m 755 misc/conf/zabbix.conf %{buildroot}%{zabbix_confdir}/zabbix.conf
        
        # copy startup script
        install -d %{buildroot}%{zabbix_initdir}
        install -m 755 misc/init.d/nighthawk/zabbix %{buildroot}%{zabbix_initdir}/zabbix
        
        # SQL scripts
        install -d %{buildroot}%{zabbix_datadir}
        cp -r create/* %{buildroot}%{zabbix_datadir}
        
        # Log folder
        install -d %{buildroot}%{zabbix_logdir}
        
        # apache2 config
        cat >zabbix.conf <<EOF
        Alias /zabbix %{zabbix_phpfrontend}
        
        <Directory "%{zabbix_phpfrontend}">
            Options FollowSymLinks
            AllowOverride None
            Order allow,deny
            Allow from all
        </Directory>
        EOF
        
        
        # Place the newly created zabbix.conf file into the httpd conf.d directory
        install -d %{buildroot}%{apache_sysconfdir}/conf.d
        install -m 644 zabbix.conf %{buildroot}%{apache_sysconfdir}/conf.d/zabbix.conf
        
        # Copy the PHP frontends
        install -d %{buildroot}%{zabbix_phpfrontend}
        cp -r frontends/php/* %{buildroot}%{zabbix_phpfrontend}
        
        %post
        # configure ZABBIX server daemon
        sed -i	-e "s#AlertScriptsPath=/home/zabbix/bin/#AlertScriptsPath=%{zabbix_bindir}/#g" \
        	-e "s#PidFile=/var/tmp/zabbix_server.pid#PidFile=%{zabbix_piddir}/zabbix.pid#g" \
        	-e "s#LogFile=/tmp/zabbix_server.log#LogFile=%{zabbix_logdir}/zabbix.log#g" \
                -e "s#DBUser=root#DBUser=zabbix#g" \
        	%{zabbix_confdir}/zabbix.conf
        
        # Change the DB TYPE to MYSQL and the DB USER to zabbix
        sed -i  -e "s#\$DB_TYPE =\"POSTGRESQL\";#\$DB_TYPE =\"MYSQL\";#g" \
        	-e "s#=\"root\";#=\"zabbix\";#g" \
                %{zabbix_phpfrontend}/include/db.inc.php
        
        sed -i  -e "s#grep zabbix_server#grep zabbix#g" \
                %{zabbix_phpfrontend}/include/config.inc.php
        
        sed -i  -e "s#zabbix_server#zabbix#g" \
        	%{zabbix_initdir}/zabbix
        
        chkconfig --add zabbix
        chkconfig zabbix on
        
        if [ -z "`grep -i "Zabbix server" /etc/services`" ]; then
          cat >>etc/services <<EOF
        zabbix          10051/tcp                       # Zabbix server
        EOF
        fi
        
        # Add a sql user called zabbix @localhost. Create the zabbix DB
        # Make sure the zabbix user has full access to the zabbix DB and no other permissions
        cat %{zabbix_datadir}/data/setupdb.sql |mysql -u%{dbuser}
        
        # Create the tables inside the database
        cat %{zabbix_datadir}/mysql/schema.sql |mysql -u%{dbuser} zabbix
        
        # Populate the tables with data and then remove the data directory
        cat %{zabbix_datadir}/data/data.sql |mysql -u%{dbuser} zabbix
        rm -rf %{zabbix_datadir}
        
        /sbin/service zabbix start
        /sbin/service zabbix status
        
        %preun
        /sbin/service zabbix stop || true
        rm -f %{zabbix_piddir}/zabbix.pid
        if [ $1 -eq 0 ] ; then
        	chkconfig --del zabbix
        fi
        
        %files
        %defattr(0755,zabbix,zabbix)
        
        %dir %{zabbix_docdir}
        %attr(0644,zabbix,zabbix) %{zabbix_docdir}/AUTHORS
        %attr(0644,zabbix,zabbix) %{zabbix_docdir}/COPYING
        %attr(0644,zabbix,zabbix) %{zabbix_docdir}/NEWS
        %attr(0644,zabbix,zabbix) %{zabbix_docdir}/README
        
        %dir %{zabbix_confdir}
        %attr(0644,zabbix,zabbix) %{zabbix_confdir}/zabbix.conf
        
        %dir %{zabbix_bindir}
        %{zabbix_bindir}/zabbix
        
        %{zabbix_initdir}/zabbix
        
        %dir %{zabbix_datadir}
        %{zabbix_datadir}/
        
        %dir %{zabbix_logdir}
        
        %dir %{zabbix_phpfrontend}
        %attr(0755,zabbix,zabbix) %{zabbix_phpfrontend}/
        
        %attr(0644,root,root) %{apache_sysconfdir}/conf.d/zabbix.conf
        
        %changelog
        * Fri Aug 18 2006 Sol Tutaki <[email protected]>
        - 1.1
        - Final packaging
        - All files installed under /opt/zabbix
        - Automatic creation of zabbix DB
        - Automatic creation of zabbix user, mysql zabbix user and permissions
        - Re-packaged php files into server package
        
        * Thu Dec 01 2005 Eugene Grigorjev <[email protected]>
        - 1.1beta2
        - initial packaging

        Comment

        • baalrukh
          Junior Member
          • Aug 2006
          • 5

          #5
          Very usefull, i'm testing it in my Fedora cores and it works very well.

          Comment

          • jojo
            Member
            • Jul 2006
            • 57

            #6
            Thanks, just finished updating it to 1.1.2

            The spec file is alot better now.

            Just gotta get the PID running under /var/run without spitting out errors and it'll be ready for release.

            Comment

            • jojo
              Member
              • Jul 2006
              • 57

              #7
              couldn't get the PID file running under /var/run so i changed it back to /var/tmp

              It uses the fedora core init.d scripts instead because they seem to be more thorough then the redhat 8.0 ones.

              this is the new one using the latest zabbix agentd build (1.1.2):



              Heres the zabbix-agentd-1.1.2.spec:
              HTML Code:
              %define debug_package %{nil}
              
              Name:		zabbix-agentd
              Version:	1.1.2
              Release:	1
              Group:		System Environment/Daemons
              License:	GPL
              Summary:	ZABBIX network monitor agent
              Vendor:		ZABBIX SIA
              URL:		http://www.zabbix.org
              Packager:	Sol Tutaki <[email protected]>
              Source:		zabbix-%{version}.tar.gz
              
              Autoreq:	no
              Buildroot: 	%{_tmppath}/%{name}-%{version}-%{release}-buildroot
              
              Prefix:		/opt/zabbix
              
              Requires:         sed
              Requires(post):   chkconfig, initscripts
              Requires(preun):  chkconfig, initscripts
              Requires(postun): initscripts
              
              %define zabbix_bindir	%{prefix}/bin
              %define zabbix_confdir	%{prefix}/etc
              %define zabbix_initdir	/etc/init.d
              %define zabbix_docdir	/usr/share/doc/%{name}-%{version}-%{release}
              
              %define zabbix_piddir	/var/tmp
              %define zabbix_logdir	%{prefix}/log
              
              %description
              The ZABBIX agent is a network monitor
              
              %prep
              %setup
              
              %build
              %configure --prefix=%{prefix} --enable-agent
              make
              
              %clean
              rm -fr $RPM_BUILD_ROOT
              
              %pre
              # create ZABBIX group
              if [ -z "`grep zabbix /etc/group`" ]; then
                /usr/sbin/groupadd zabbix >/dev/null 2>&1
              fi
              
              # create ZABBIX user
              if [ -z "`grep zabbix /etc/passwd`" ]; then
                /usr/sbin/useradd -g zabbix -c "Zabbix user account" -s /bin/false zabbix >/dev/null 2>&1
              fi
              
              %install
              rm -fr $RPM_BUILD_ROOT
              
              # copy documentation
              install -d %{buildroot}%{zabbix_docdir}
              install -m 644 AUTHORS %{buildroot}%{zabbix_docdir}/AUTHORS
              install -m 644 COPYING %{buildroot}%{zabbix_docdir}/COPYING
              install -m 644 NEWS %{buildroot}%{zabbix_docdir}/NEWS
              install -m 644 README %{buildroot}%{zabbix_docdir}/README
              install -m 644 ChangeLog %{buildroot}%{zabbix_docdir}/ChangeLog
              
              
              # copy binaries
              install -d %{buildroot}%{zabbix_bindir}
              install -s -m 755 src/zabbix_agent/zabbix_agentd %{buildroot}%{zabbix_bindir}/zabbix_agentd
              
              # copy config files
              install -d %{buildroot}%{zabbix_confdir}
              install -m 755 misc/conf/zabbix_agentd.conf %{buildroot}%{zabbix_confdir}/zabbix_agentd.conf
              
              # copy startup script
              install -d %{buildroot}%{zabbix_initdir}
              install -m 755 misc/init.d/fedora/core/zabbix_agentd %{buildroot}%{zabbix_initdir}/zabbix_agentd
              
              install -d %{buildroot}%{zabbix_logdir}
              
              %post
              # configure ZABBIX agent daemon
              %{__sed} -i -e "s#Hostname=localhost#Hostname=`uname -n`#g" \
              	    -e "s#PidFile=/var/tmp/zabbix_agentd.pid#PidFile=%{zabbix_piddir}/zabbix_agentd.pid#g" \
              	    -e "s#LogFile=/tmp/zabbix_agentd.log#LogFile=%{zabbix_logdir}/zabbix_agentd.log#g" \
              	    -e "s#Timeout=3#Timeout=30#g" \
              	%{zabbix_confdir}/zabbix_agentd.conf
              
              %{__sed} -i -e "s#BASEDIR=\/opt\/zabbix#USER=zabbix; BASEDIR=%{prefix}; conffile=\"%{zabbix_confdir}/zabbix_agentd.conf\"#g" \
                          -e "s#\$FULLPATH#\$FULLPATH -c \$conffile#g" \
                      %{zabbix_initdir}/zabbix_agentd
              
              chkconfig --add zabbix_agentd
              chkconfig --levels 345 zabbix_agentd on
              
              if [ -z "`grep -i "Zabbix agent" /etc/services`" ]; then
                cat >>etc/services <<EOF
              zabbix-agentd          10050/tcp                       # Zabbix agent
              EOF
              fi
              
              #service zabbix_agentd start
              #service zabbix_agentd status
              
              %preun
              if [ -n "`/sbin/pidof zabbix_agentd`" ]; then
              service zabbix_agentd stop
              sleep 2
              fi
              
              %postun
              rm -f %{zabbix_piddir}/zabbix_agentd.pid
              rm -f %{zabbix_logdir}/zabbix_agentd.log
              
              %files
              %dir %attr(0755,zabbix,zabbix) %{zabbix_docdir}
              %attr(0644,root,root) %{zabbix_docdir}/AUTHORS
              %attr(0644,root,root) %{zabbix_docdir}/COPYING
              %attr(0644,root,root) %{zabbix_docdir}/NEWS
              %attr(0644,root,root) %{zabbix_docdir}/README
              %attr(0644,root,root) %{zabbix_docdir}/ChangeLog
              
              %dir %attr(0755,zabbix,zabbix) %{zabbix_confdir}
              %attr(0644,zabbix,zabbix) %config(noreplace) %{zabbix_confdir}/zabbix_agentd.conf
              
              %dir %attr(0755,zabbix,zabbix) %{zabbix_bindir}
              %attr(0755,zabbix,zabbix) %{zabbix_bindir}/zabbix_agentd
              
              %attr(0755,root,root) %{zabbix_initdir}/zabbix_agentd
              
              %dir %attr(0755,zabbix,zabbix) %{zabbix_logdir}
              
              %changelog
              * Wed Oct 11 2006 Sol Tutaki <[email protected]>
              - 1.1.1-2
              - Moved zabbix user check to pre install
              - Cleaned up directory structure
              * Wed Jul 19 2006 Alexey Zilber <[email protected]>
              - 1.1.1
              - Updated packaging, cleaned up directory structure for
              - RedHat compatibility, added uninstall,build checks.
              * Thu Dec 01 2005 Eugene Grigorjev <[email protected]>
              - 1.1beta2
              - initial packaging

              Comment

              • jojo
                Member
                • Jul 2006
                • 57

                #8
                heres an updated one for 1.4.2

                I didn't modify any of the files in the zabbix-1.4.2.tar.gz.

                You just need to do a rpmbuild -ba /path/to/zabbix.spec

                built on a centos 5 machine with all yum updates applied. Has been compiled and then tested on fedora core 7 and centos 4. Statically linked libs probably make this rpm a little more versatile.

                Make sure you change the variables to suit your own purposes

                and change the server name! once you do a rpm -i /path/to/zabbix_agentd-1.4.2-1.i386.rpm it will install the zabbix agent, start the service and do a service zabbix_agentd status as well. For quick deployment, try to have everything configured before building.

                Code:
                %define debug_package %{nil}
                
                Name:           zabbix_agentd
                Version:        1.4.2
                Release:        1
                Group:          System Environment/Daemons
                License:        GPL
                Summary:        ZABBIX network monitor agent
                Vendor:         ZABBIX SIA
                URL:            http://www.zabbix.org
                Packager:       Sol Tutaki <[email protected]>
                Source:         %{name}-%{version}-%{release}.tar.gz
                
                Autoreq:        no
                Buildroot:      %{_tmppath}/%{name}-%{version}-%{release}-buildroot
                
                Prefix:         /opt/zabbix
                
                Requires:         sed
                Requires(post):   chkconfig, initscripts
                Requires(preun):  chkconfig, initscripts
                Requires(postun): initscripts
                
                %define zabbix_bindir   %{prefix}/bin
                %define zabbix_confdir  %{prefix}/etc
                %define zabbix_initdir  /etc/init.d
                %define zabbix_docdir   /usr/share/doc/%{name}-%{version}-%{release}
                
                %define zabbix_piddir   /var/tmp
                %define zabbix_logdir   %{prefix}/log
                
                %define zabbix_server   127.0.0.1
                
                %description
                The ZABBIX agent is a network monitor
                
                %prep
                %setup
                
                %build
                %configure --prefix=%{prefix} --enable-static --enable-agent
                make
                
                %clean
                rm -fr $RPM_BUILD_ROOT
                
                %pre
                # create ZABBIX group
                if [ -z "`grep zabbix /etc/group`" ]; then
                  /usr/sbin/groupadd zabbix >/dev/null 2>&1
                fi
                
                # create ZABBIX user
                if [ -z "`grep zabbix /etc/passwd`" ]; then
                  /usr/sbin/useradd -g zabbix -c "Zabbix user account" -s /bin/false zabbix >/dev/null 2>&1
                fi
                
                %install
                rm -fr $RPM_BUILD_ROOT
                
                # copy documentation
                install -d %{buildroot}%{zabbix_docdir}
                install -m 644 AUTHORS %{buildroot}%{zabbix_docdir}/AUTHORS
                install -m 644 COPYING %{buildroot}%{zabbix_docdir}/COPYING
                install -m 644 NEWS %{buildroot}%{zabbix_docdir}/NEWS
                install -m 644 README %{buildroot}%{zabbix_docdir}/README
                install -m 644 ChangeLog %{buildroot}%{zabbix_docdir}/ChangeLog
                
                
                # copy binaries
                install -d %{buildroot}%{zabbix_bindir}
                install -s -m 755 src/zabbix_agent/zabbix_agentd %{buildroot}%{zabbix_bindir}/zabbix_agentd
                
                # copy config files
                install -d %{buildroot}%{zabbix_confdir}
                install -m 755 misc/conf/zabbix_agentd.conf %{buildroot}%{zabbix_confdir}/zabbix_agentd.conf
                
                # copy startup script
                install -d %{buildroot}%{zabbix_initdir}
                install -m 755 misc/init.d/fedora/core5/zabbix_agentd %{buildroot}%{zabbix_initdir}/zabbix_agentd
                
                install -d %{buildroot}%{zabbix_logdir}
                
                %post
                # configure ZABBIX agent daemon
                %{__sed} -i -e "s#Hostname=localhost#Hostname=`uname -n`#g" \
                            -e "s#PidFile=/var/tmp/zabbix_agentd.pid#PidFile=%{zabbix_piddir}/zabbix_agentd.pid#g" \
                            -e "s#LogFile=/tmp/zabbix_agentd.log#LogFile=%{zabbix_logdir}/zabbix_agentd.log#g" \
                            -e "s#Timeout=3#Timeout=30#g" \
                            -e "s#127.0.0.1#%{zabbix_server}#g" \
                        %{zabbix_confdir}/zabbix_agentd.conf
                
                %{__sed} -i -e "s#/etc/zabbix/zabbix_agentd.conf#%{zabbix_confdir}/zabbix_agentd.conf#g" \
                            -e "s#/usr/bin/zabbix_agentd#%{zabbix_bindir}/zabbix_agentd#g" \
                        %{zabbix_initdir}/zabbix_agentd
                
                chkconfig --add zabbix_agentd
                chkconfig --levels 345 zabbix_agentd on
                
                if [ -z "`grep -i "Zabbix agent" /etc/services`" ]; then
                  cat >>etc/services <<EOF
                zabbix_agentd          10050/tcp                       # Zabbix agent
                EOF
                fi
                
                service zabbix_agentd start
                service zabbix_agentd status
                
                %preun
                if [ -n "`/sbin/pidof zabbix_agentd`" ]; then
                service zabbix_agentd stop
                sleep 2
                fi
                
                %postun
                rm -f %{zabbix_piddir}/zabbix_agentd.pid
                rm -f %{zabbix_logdir}/zabbix_agentd.log
                
                %files
                %dir %attr(0755,zabbix,zabbix) %{zabbix_docdir}
                %attr(0644,root,root) %{zabbix_docdir}/AUTHORS
                %attr(0644,root,root) %{zabbix_docdir}/COPYING
                %attr(0644,root,root) %{zabbix_docdir}/NEWS
                %attr(0644,root,root) %{zabbix_docdir}/README
                %attr(0644,root,root) %{zabbix_docdir}/ChangeLog
                
                %dir %attr(0755,zabbix,zabbix) %{zabbix_confdir}
                %attr(0644,zabbix,zabbix) %config(noreplace) %{zabbix_confdir}/zabbix_agentd.conf
                
                %dir %attr(0755,zabbix,zabbix) %{zabbix_bindir}
                %attr(0755,zabbix,zabbix) %{zabbix_bindir}/zabbix_agentd
                
                %attr(0755,root,root) %{zabbix_initdir}/zabbix_agentd
                
                %dir %attr(0755,zabbix,zabbix) %{zabbix_logdir}
                
                %changelog
                * Fri Aug 24 2007 Sol Tutaki <[email protected]>
                - 1.4.2-1
                - Updated packaging to 1.4.2 (release 1)
                * Wed Oct 11 2006 Sol Tutaki <[email protected]>
                - 1.1.1-2
                - Moved zabbix user check to pre install
                - Cleaned up directory structure
                * Wed Jul 19 2006 Alexey Zilber <[email protected]>
                - 1.1.1
                - Updated packaging, cleaned up directory structure for
                - RedHat compatibility, added uninstall,build checks.
                * Thu Dec 01 2005 Eugene Grigorjev <[email protected]>
                - 1.1beta2
                - initial packaging
                Last edited by jojo; 01-09-2007, 08:35.

                Comment

                • just2blue4u
                  Senior Member
                  • Apr 2006
                  • 347

                  #9
                  i placed my .pid files into /var/run/zabbix/... maybe that works 4 u, too?
                  Big ZABBIX is watching you!
                  (... and my 48 hosts, 4513 items, 1280 triggers via zabbix v1.6 on CentOS 5.0)

                  Comment

                  Working...