#!/bin/bash
#install the Zabbix Agent
#Create by Shiyong
ID Zabbix &>/dev/null | | Useradd-s/sbin/nologin Zabbix
Mkdir/etc/zabbix/var/log/zabbix
Chown zabbix.zabbix/var/log/zabbix/
Tar zxf zabbix-2.0.12.tar.gz-c/usr/src/
cd/usr/src/zabbix-2.0.12/
./configure--prefix=/usr/local/zabbix/--sysconfdir=/etc/zabbix/--enable-agent &>/dev/null && make &>/dev/null && make install &>/dev/null
CP misc/init.d/fedora/core/zabbix_agentd/etc/init.d/
cd/etc/zabbix/
CP zabbix_agentd.conf Zabbix_agentd.conf.origin
echo "Modify the Zabbix_agentd conf file"
Sleep 1
Read-p "Input the Zabbix server IP:" IP
#使用 "" Reference variable IP
Sed-i "/server=127.0.0.1/s/server=127.0.0.1/server=127.0.0.1, $IP/"/etc/zabbix/zabbix_agentd.conf
Sed-i "/serveractive=127.0.0.1/s/serveractive=127.0.0.1/serveractive= $IP: 10051/"/etc/zabbix/zabbix_agentd.conf
Sed-i '/logfile=\/tmp\/zabbix_agentd.log/[email protected]=/tmp/[email protected]=/var/log/zabbix/[email protected ] '/etc/zabbix/zabbix_agentd.conf
Sed-i '/# unsafeuserparameters=0/s/# unsafeuserparameters=0/unsafeuserparameters=1/'/etc/zabbix/zabbix_ Agentd.conf
echo "include=/etc/zabbix/zabbix_agentd.conf.d/" >>/etc/zabbix/zabbix_agentd.conf
Ln-s/usr/local/zabbix/sbin/zabbix_agentd/usr/local/sbin/
/etc/init.d/zabbix_agentd start
Chkconfig Zabbix_agentd on
echo "Zabbix install finished"
Shell script to install Zabbix agent automatically