zabbix 客户端的安装
这里我们在客户端安装就是用rpm的安装方式了:
在我使用RPM安装的时候遇到了一个错误
[root@git src]# rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/6/x86_64/zabbix-agent-3.0.3-1.el6.x86_64.rpm
Retrieving http://repo.zabbix.com/zabbix/3.0/rhel/6/x86_64/zabbix-agent-3.0.3-1.el6.x86_64.rpm
warning: /var/tmp/rpm-tmp.xOmGB5: Header V4 DSA/SHA1 Signature, key ID 79ea5ed4: NOKEY
error: Failed dependencies:
libodbc.so.2()(64bit) is needed by zabbix-agent-3.0.3-1.el6.x86_64
解决办法:
yum -y install unixODBC
然后再执行
rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/6/x86_64/zabbix-agent-3.0.3-1.el6.x86_64.rpm
或者使用
rpm -ivh http://mirrors.aliyun.com/zabbix/zabbix/3.0/rhel/6/x86_64/zabbix-get-3.0.3-1.el6.x86_64.rpm
然后执行
yum clean all
yum -y install zabbix zabbix-agent
再然后就是配置zabbix客户端了
zabbix agent的配置很简单,只需要修改zabbix agent配置文件中的Server、ServerActive和Hostname这三项即可。
其中Server、ServerActive是zabbix server服务器的IP地址,Hostname是被监控端的IP地址,如下:
vim /etc/zabbix/zabbix_agentd.conf
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=192.168.220.98
ServerActive=192.168.220.98
Hostname=192.168.220.99
Include=/etc/zabbix/zabbix_agentd.d/
/etc/init.d/zabbix-agent start
配置完以上之后就是添加监控主机了
(1)首先要做的就是下载压缩包
yum install -y gcc gcc-c++ make pcre* openssl* cmake ncurses-devel gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel
cd /usr/local/src
wget http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.2.3/zabbix-2.2.3.tar.gz
tar xf zabbix-2.2.3.tar.gz
cd zabbix-2.2.3
./configure --prefix=/usr/local/zabbix --enable-agent
cd /usr/local
groupadd zabbix
useradd zabbix -g zabbix
chown zabbix:zabbix zabbix -R
cd zabbix
mkdir run
cd etc
vim zabbix_agentd.conf
修改其中的
[root@file206 etc]# cat zabbix_agentd.conf | grep -v "^#" | grep -v "^$"
LogFile=/usr/local/zabbix/run/zabbix_agentd.log
ListenPort=10050
ListenIP=0.0.0.0
StartAgents=0
ServerActive=192.168.10.111 (zabbix服务端IP)
Hostname=206_samba
Timeout=10
网上摘了一个zabbix的启动脚本
[root@file206 etc]# cat /etc/init.d/zabbix
#!/bin/bash
#
# chkconfig: - 90 10
# description: Starts and stops Zabbix Agent using chkconfig
# Tested on Fedora Core 2 - 5
# Should work on all Fedora Core versions
#
# @name: zabbix_agentd
# @author: Alexander Hagenah <hagenah@topconcepts.com>
# @created: 18.04.2006
#
# Modified for Zabbix 2.0.0
# May 2012, Zabbix SIA
#
# Source function library.
. /etc/init.d/functions
# Variables
# Edit these to match your system settings
# Zabbix-Directory
BASEDIR=/usr/local/zabbix
# Binary File
BINARY_NAME=zabbix_agentd
# Full Binary File Call
FULLPATH=$BASEDIR/sbin/$BINARY_NAME
# PID file
PIDFILE=$BASEDIR/run/$BINARY_NAME.pid
# Establish args
ERROR=0
STOPPING=0
#
# No need to edit the things below
#
# application checking status
if [ -f $PIDFILE ] && [ -s $PIDFILE ]
then
PID=`cat $PIDFILE`
if [ "x$PID" != "x" ] && kill -0 $PID 2>/dev/null && [ $BINARY_NAME == `ps -e | grep $PID | awk '{print $4}'` ]
then
STATUS="$BINARY_NAME (pid `pidof $APP`) running.."
RUNNING=1
else
rm -f $PIDFILE
STATUS="$BINARY_NAME (pid file existed ($PID) and now removed) not running.."
RUNNING=0
fi
else
if [ `ps -e | grep $BINARY_NAME | head -1 | awk '{ print $1 }'` ]
then
STATUS="$BINARY_NAME (pid `pidof $APP`, but no pid file) running.."
else
STATUS="$BINARY_NAME (no pid file) not running"
fi
RUNNING=0
fi
# functions
start() {
if [ $RUNNING -eq 1 ]
then
echo "$0 $ARG: $BINARY_NAME (pid $PID) already running"
else
action $"Starting $BINARY_NAME: " $FULLPATH
touch /var/lock/subsys/$BINARY_NAME
fi
}
stop() {
echo -n $"Shutting down $BINARY_NAME: "
killproc $BINARY_NAME
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$BINARY_NAME
RUNNING=0
}
# logic
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status $BINARY_NAME
;;
restart)
stop
sleep 1
start
;;
help|*)
echo $"Usage: $0 {start|stop|status|restart|help}"
cat <<EOF
start - start $BINARY_NAME
stop - stop $BINARY_NAME
status - show current status of $BINARY_NAME
restart - restart $BINARY_NAME if running by sending a SIGHUP or start if not running
help - this screen
EOF
exit 1
;;
esac
exit 0
/etc/init.d/zabbix start