#!/bin/sh
path=/opt/zabbix
ver=http://downloads.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.0.4/zabbix-3.0.4.tar.gz
wgetp=/usr/local/src
server=192.168.1.55
check=`lsof -i :10050`
conf=$path/etc/zabbix_agentd.conf
name=`ifconfig |grep netmask|grep -v "127.0.0.1"|awk '{print $2}'`
user=zabbix
##############下载agent源码包############
yum -y group install Development Tools
useradd -M -s /sbin/nologin zabbix
yum -y install lsof wget
cd $wgetp
if [[ -f zabbix-3.0.4.tar.gz ]]; then
echo "文件已存在"
cd zabbix-3.0.4
./configure --prefix=$path --enable-agent
else
wget $ver
tar -xvzf zabbix-3.0.4.tar.gz
cd zabbix-3.0.4
./configure --prefix=$path --enable-agent
fi
#if [[ $? != 0 ]]; then
# echo "zabbix install faile pls 检查依赖问题 "
#fi
make
if [[ $? != 0 ]]; then
echo " make failed "
fi
make install
sleep 2
cd $path
##############备份zabbix.conf
cp $conf $conf-$(date +%F)
######替换配置文件#############
cat << EOF >$conf
LogFile=/tmp/zabbix_agentd.log
Server=$server
#ServerActive=$server
Hostname=$name
UnsafeUserParameters=1
EnableRemoteCommands=1
RefreshActiveChecks=300
Timeout=5
Include=$path/etc/zabbix_agentd.conf.d/
EOF
chown -R zabbix.zabbix $path
sleep 2
./sbin/zabbix_agentd
######检测agent是否启动
$check
if [[ $? == 0 ]]; then
echo "zabbix is runing"
else
echo "zabbix is runing failed"
fi
tailf /tmp/zabbix_agentd.log
附上window安装:
C:\Windows\system32>C:\zabbix_agents\bin\win64\zabbix_agentd.exe -i -c C:\zabbix
_agents\conf\zabbix_agentd.win.conf
#注意顺序 -i -c
zabbix_agentd.exe [1468]: service [Zabbix Agent] installed successfully
zabbix_agentd.exe [1468]: event source [Zabbix Agent] installed successfully
windows agent配置文件
LogFile=C:\zabbix_agents\zabbix_agentd.log
Server=172.16.100.106
#ServerActive=172.16.100.106
Hostname=172.16.100.81
UnsafeUserParameters=1
EnableRemoteCommands=1
RefreshActiveChecks=300
Timeout=5
#Include=c:\zabbix_agents\zabbix_agentd.conf.d\*.conf