Install Zabbix agent on SLES 11

Begging :.... If this helped you in any way and you have some spare BitCoins, you may donate them to me - 16tb2Rgn4uDptrEuR94BkhQAZNgfoMj3ug

Download the agent software from the Zabbix site :- http://www.zabbix.com/download.php
Pre-compiled Zabbix 2.2.1 (stable) agents are available for selected platforms

As root user
Make a directory to ftp the software to
mkdir -p /opt/temp

Add the group and user Zabbix : -useradd and groupadd zabbix
ftp file zabbix_agents_2.0.4.linux2_6_23.amd64.tar.gz, zabbix-agentd.conf and the .sh scripts to /opt/temp
svr3:~ # ls -ltr /opt/temp
total 4131360
-rw-r--r-- 1 root root 5703 Nov 24 09:08 zabbix_agentd.conf
-rw-r--r-- 1 root root 209205 Nov 24 09:09 zabbix_agents_1.8.3.linux2_6.amd64.tar.gz
svr3:~ # useradd zabbix
svr3:~ # groupadd zabbix
svr3:~ # cd /opt/temp
svr3:/opt/temp # tar -xvf zabbix_agents_2.0.4.linux2_6_23.amd64.tar.gz
sbin/zabbix_agent
sbin/zabbix_agentd
bin/zabbix_get
bin/zabbix_sender
conf/zabbix_agent.conf
conf/zabbix_agentd.conf
conf/zabbix_agentd/userparameter_examples.conf
conf/zabbix_agentd/userparameter_mysql.conf
svr3:/opt/temp #
svr3:/opt/temp # ls -ltr
total 328
-rw-r--r-- 1 root  root 286523 Feb  7 11:25 zabbix_agents_2.0.4.linux2_6_23.amd64.tar.gz
-rw-r--r-- 1 root  root   5999 Feb  7 11:30 zabbix_agentd.conf
drwxr-xr-x 2 root  root   4096 Feb  7 11:31 sbin
drwxr-xr-x 3 root  root   4096 Feb  7 11:31 conf
drwxr-xr-x 2 root  root   4096 Feb  7 11:31 bin
svr3:/opt/temp #

The code above will create sbin and bin directory under the directory /opt/temp, copy the contents of /opt/temp/sbin and /opt/temp/bin to /usr/local/sbin and /usr/local/bin respectively
svr3:/opt/temp # mv /opt/temp/sbin/* /usr/local/sbin/
svr3:/opt/temp # ls -ltr /opt/temp/sbin
total 0
szmtnsvr3:/opt/temp # ls -ltr /usr/local/sbin
total 432
-rwxr-xr-x 1 root sfcb 228624 Dec 10 13:41 zabbix_agentd
-rwxr-xr-x 1 root sfcb 199496 Dec 10 13:41 zabbix_agent
svr3:/opt/temp # mv /opt/temp/bin/* /usr/local/bin/
svr3:/opt/temp # ls -ltr /opt/temp/bin
total 0
svr3:/opt/temp # ls -ltr /usr/local/bin
total 224
-rwxr-xr-x 1 root sfcb 95464 Dec 10 13:41 zabbix_sender
-rwxr-xr-x 1 root sfcb 81560 Dec 10 13:41 zabbix_get
-rwx------ 1 root     root  8850 Feb  5 14:46 postsetup.sh
svr3:/opt/temp #

Change ownership of the copied files, touch the log and lock files, make directory /var/log/zabbix and copy /opt/temp/zabbix_agentd.conf to new directory /etc/zabbix
svr3:/opt/temp # chown zabbix:zabbix /usr/local/sbin/zabbix*
svr3:/opt/temp # chown zabbix:zabbix /usr/local/bin/zabbix*
svr3:/opt/temp # cd /var/log
svr3:/var/log # mkdir zabbix
svr3:/var/log # touch /var/log/zabbix/zabbix_agentd.log
svr3:/var/log # chown -R zabbix:zabbix zabbix/
svr3:/var/log # mkdir /etc/zabbix
svr3:/var/log # mv /opt/temp/zabbix_agentd.conf /etc/zabbix/
svr3:/var/log # ls -ltr /etc/zabbix/
total 8
-rw-r--r-- 1 root root 5999 Feb  7 11:30 zabbix_agentd.conf
svr3:/var/log # chown -R zabbix:zabbix /etc/zabbix/
svr3:/var/log # ls -ltr /etc/zabbix/
total 8
-rw-r--r-- 1 zabbix zabbix 5999 Feb  7 11:30 zabbix_agentd.conf
svr3:/var/log # touch /etc/zabbix/zabbix_agentd.pid
svr3:/var/log # chown zabbix:zabbix /etc/zabbix/zabbix_agentd.pid
svr3:/var/log #

vi the zabbix_agend.conf file and set the Zabbix Master server IP, also set the hostname of the server that you are installing Zabbix on, for example
vi /etc/zabbix/zabbix_agentd.conf
 
##### Passive checks related
 
### Option: Server
# List of comma delimited IP addresses (or hostnames) of Zabbix servers.
# No spaces allowed. First entry is used for receiving list of and sending active checks.
# Note that hostnames must resolve hostname->IP address and IP address->hostname.
# If IPv6 support is enabled then '127.0.0.1', '::127.0.0.1', '::ffff:127.0.0.1' are treated equally.
#
# Mandatory: yes
# Default:
# Server=
 
Server=xxx.xxx.xxx.xxx ## This is the Master Zabbix server IP
 
### Option: Hostname
# Unique, case sensitive hostname.
# Required for active checks and must match hostname as configured on the server.
#
# Default:
# Hostname=system.uname
 
Hostname=svr3.domain.com #

Make the startup and stop script, etc/init.d/zabbix-agent
vi /etc/init.d/zabbix-agent
#!/bin/bash
#
# Init file for Zabbix Agent
#
#
# chkconfig: - 80 12
# description: Zabbix agent startup
# processname: zabbix-agent
### BEGIN INIT INFO
# Provides: zabbix-agent
# Required-Start: $network $local_fs $remote_fs
# Required-Stop: $network $local_fs $remote_fs
# Default-Start: 3 5
# Default-Start: 0 6
# chkconfig: 12345 95 05
# Description: Supports the direct execution of binary formats.
### END INIT INFO
source /etc/rc.status
source /etc/profile.local
RETVAL=0
prog="zabbix_agent"
start() {
  runningCheck
  cd /usr/local/sbin
  echo -n $"Starting $prog: "
  ./zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
  rc_status -v
}
stop() {
        echo "Shutdown may take a while....";
        echo -n $"Shutting down $prog: "
         if [ `ps -ef | grep zabbix_agent | grep -v grep | wc -l` -eq 0 ]; then
            echo "No Zabbix agent running."
         else
            pkill zabbix_agentd
            rc_status -v
            RETVAL=0
            return $RETVAL
         fi
}
restart() {
  stop
  start
}
runningCheck() {
    rc=0
    if [ `ps -ef | grep zabbix_agent | grep -v grep | wc -l` -ge 1 ]; then
          rc=1
    fi
    if [ $rc -ne 0 ]; then
        echo "Zabbix agent is already running"
        exit 0
    fi
}
case "$1" in
  start)
  start
  ;;
  stop)
  stop
  ;;
  status)
  if [ `ps -ef | grep zabbix_agent | grep -v grep | wc -l` -eq 0 ]; then
         echo "No Zabbix agent running."
  else
      echo "Zabbix agent running(PID): `ps -ef | grep zabbix_agent | grep -v grep | grep -v tool | awk {'print $2'}`"
  fi
  RETVAL=$?
  ;;
  restart)
  restart
  ;;
   *)
  echo $"Usage: $0 {start|stop|status|restart}"
  RETVAL=1
esac
exit $RETVAL

Make the script executable
svr3:/var/log # chmod +x /etc/init.d/zabbix-agent

Start the Zabbix agent, monitor the logfile and add the server to the Zabbix server.
svr3:/var/log # ps -ef | grep zabbix
root 27908 27785 0 09:30 pts/3 00:00:00 grep zabbix
svr3:/var/log # /etc/init.d/zabbix-agent status
No Zabbix agent running.
svr3:/var/log # /etc/init.d/zabbix-agent start
Starting zabbix_agent:                                                                                                                                                                             done
svr3:/var/log # /etc/init.d/zabbix-agent status
Zabbix agent running(PID): 9596
9597
9598
9599
9600
svr3:/var/log #
svr3:/var/log # ps -ef | grep zabbix
zabbix    9596     1  0 11:42 ?        00:00:00 zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
zabbix    9597  9596  0 11:42 ?        00:00:00 zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
zabbix    9598  9596  0 11:42 ?        00:00:00 zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
zabbix    9599  9596  0 11:42 ?        00:00:00 zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
zabbix    9600  9596  0 11:42 ?        00:00:00 zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
root      9771  2257  0 11:43 pts/1    00:00:00 grep zabbix
svr3:/var/log # cd /var/log/zabbix/
svr3:/var/log/zabbix # ls -ltr
total 16
-rw-r--r-- 1 zabbix zabbix 12597 Feb  7 11:43 zabbix_agentd.log
svr3:/var/log/zabbix # tail -f zabbix_agentd.log
  9598:20130207:114346.259 Sending back [352714752]
  9597:20130207:114346.837 In update_cpustats()
  9597:20130207:114346.840 End of update_cpustats()
  9598:20130207:114347.176 Processing request.
  9598:20130207:114347.188 Requested [vfs.fs.size[/boot,used]]
  9598:20130207:114347.188 Sending back [73269248]
  9597:20130207:114347.840 In update_cpustats()
  9597:20130207:114347.843 End of update_cpustats()
  9597:20130207:114348.843 In update_cpustats()
  9597:20130207:114348.846 End of update_cpustats()
  9598:20130207:114349.181 Processing request.
  9598:20130207:114349.280 Requested [vfs.fs.size[/home,used]]
  9598:20130207:114349.280 Sending back [34963456]
  9597:20130207:114349.846 In update_cpustats()
  9597:20130207:114349.848 End of update_cpustats()
^C
svr3:/var/log/zabbix #

The following will make sure that Zabbix starts when the server is rebooted
svr1:~ # chkconfig --list | grep zabbix
svr3:/etc/zabbix/scripts # chkconfig --add zabbix-agent
insserv: Script jexec is broken: incomplete LSB comment.
insserv: missing `Required-Stop:'  entry: please add even if empty.
insserv: Script jexec is broken: incomplete LSB comment.
insserv: missing `Required-Stop:'  entry: please add even if empty.
insserv: Script jexec is broken: incomplete LSB comment.
insserv: missing `Required-Stop:'  entry: please add even if empty.
insserv: Script jexec is broken: incomplete LSB comment.
insserv: missing `Required-Stop:'  entry: please add even if empty.
insserv: Script jexec is broken: incomplete LSB comment.
insserv: missing `Required-Stop:'  entry: please add even if empty.
insserv: Script jexec is broken: incomplete LSB comment.
insserv: missing `Required-Stop:'  entry: please add even if empty.
insserv: Script jexec is broken: incomplete LSB comment.
insserv: missing `Required-Stop:'  entry: please add even if empty.
insserv: Script jexec is broken: incomplete LSB comment.
insserv: missing `Required-Stop:'  entry: please add even if empty.
insserv: Script jexec is broken: incomplete LSB comment.
insserv: missing `Required-Stop:'  entry: please add even if empty.
insserv: warning: script 'init.ohasd' missing LSB tags and overrides
insserv: Default-Start undefined, assuming default start runlevel(s) for script `init.ohasd'
insserv: Script jexec is broken: incomplete LSB comment.
insserv: missing `Required-Stop:'  entry: please add even if empty.
zabbix-agent              0:off  1:off  2:off  3:on   4:off  5:on   6:off
svr3:/etc/zabbix/scripts # chkconfig --level 35 zabbix-agent on
svr3:/etc/zabbix/scripts # chkconfig --list | grep zabbix
zabbix-agent              0:off  1:off  2:off  3:on   4:off  5:on   6:off
svr3:/etc/zabbix/scripts #

To check the Zabbix agent version, status etc, make sure that the Zabbix agent is the latest, on v2.0.4 at 07/Feb/2013
svr3:/etc/zabbix/scripts # /usr/local/sbin/zabbix_agentd -V
Zabbix Agent (daemon) v2.0.4 (revision 31984) (08 December 2012)
Compilation time: Dec 10 2012 13:41:24
svr3:/etc/zabbix/scripts # /etc/init.d/zabbix-agent status
Zabbix agent running(PID): 9596
9597
9598
9599
9600
svr3:/etc/zabbix/scripts #

No comments:

Post a Comment

Note: only a member of this blog may post a comment.