zabbix 客户端安装脚本
脚本是根据自己的生产环境中编写的,请注意编码格式,初次来写,有需要优化好的建议,大家都可以留言进行交流。1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#/bin/bash
#源码自动安装zabbix客户端脚本。
#需要把zabbix安装包放在/usr/loacl 下面执行。
#安装gcc cc插件
yum install -y gcc cc
#检查zabbix用户是否存在
user=zabbix
group=zabbix
#create group if not exists
egrep "^$group" /etc/group >& /dev/null
if [ $? -ne 0 ]
then
groupadd $group
fi
#create user if not exists
egrep "^$user" /etc/passwd >& /dev/null
if [ $? -ne 0 ]
then
useradd -g $group $user -s /sbin/nologin
echo zabbix |passwd --stdin $user >& /dev/null
fi
#检查原有zabbix服务,如果有则停掉
ps -ef |grep zabbix|grep -v grep
if [ $? -eq 0 ]
then
/etc/init.d/zabbix-agent stop || /etc/init.d/zabbix-agentd stop
fi
#编译安装
tar -zxvf /usr/local/zabbix-2.2.13.tar.gz;cd zabbix-2.2.13
./configure --prefix=/usr/local/zabbix-2.2.13/ --enable-agent
make&&make install
#修改配置文件
sed -i.bak 's/127.0.0.1/172.16.2.113/g' /usr/local/zabbix-2.2.13/conf/zabbix_agentd.conf
hostname=`cat /etc/sysconfig/network | sed -n '2p' | awk -F'=' '{print $2}'`
sed -i "s/Hostname=Zabbix server/Hostname="$hostname"/g"/usr/local/zabbix-2.2.13/conf/zabbix_agentd.conf
#配置init.d启动
cp /usr/local/zabbix-2.2.13/misc/init.d/fedora/core/zabbix_agentd/etc/init.d/zabbix_agentd
sed -i 's/BASEDIR=\/usr\/local/BASEDIR=\/usr\/local\/zabbix-2.2.13/g'/etc/init.d/zabbix_agentd
#配置开机启动
chkconfig--add zabbix_agentd
chkconfigzabbix_agentd on
/etc/init.d/zabbix_agentd start
#查看zabbix启动
netstat -lnp |grep zabbix
if [ $? -eq 0 ]
then
echo "Zabbix agent install have completed."
fi
谢谢楼主分享!
页:
[1]