Linux自動安裝zabbix(64位)

#!/bin/bash



# zabbix server 或 zabbix proxy IP,根據實際情況設置?

SERVER_IP="172.20.50.21"?


# get network ip addr function? ?

function getIP()? ?

{? ?

? ? NET=$1? ?

? ? if [ "$NET" = "" ]; then? ?

? ? ? ? NET="eth0"? ?

? ? fi? ?

? ? IP=""? ?

? ? if [ $(ifconfig | grep "$NET" | wc -l) -gt 0 ]; then? ?

? ? ? ? IP=$(ifconfig $NET | grep 'inet addr:' | awk -F: '{print $2}' | awk '{print $1}')? ?

? ? fi? ?

? ? echo $IP? ?

}?


# get IP segment function? ?

function getSegment()? ?

{? ?

? ? IP_ADD=$1? ?

? ? N=$2? ?

? ? echo $(echo $IP_ADD | cut -d. -f$N)? ?

}?


ETH0_IP=$(getIP eth0)?


IP_ADDR=$ETH0_IP?

LOCAL_IP=$IP_ADDR?


yum -y install gcc?


groupadd zabbix? ?

useradd -g zabbix -s /sbin/nologin? -M zabbix?


cd /usr/local/src?

tar zxvf zabbix_agents_2.2.19.linux2_6.amd64.tar.gz?

cd zabbix_agents_2.2.19.linux2_6.amd64



./configure --prefix=/usr/local/zabbix --enable-agent?

make?

make install?


cp misc/init.d/fedora/core/zabbix_agentd /etc/init.d?

sed -i 's/BASEDIR=\/usr\/local/BASEDIR=\/usr\/local\/zabbix/g' /etc/init.d/zabbix_agentd?

chkconfig --add zabbix_agentd? ?

chkconfig zabbix_agentd on?


sed -i "s/^Server=127.0.0.1/Server=$SERVER_IP/g" /usr/local/zabbix/etc/zabbix_agentd.conf?

sed -i "s/^ServerActive=127.0.0.1/#ServerActive=127.0.0.1/" /usr/local/zabbix/etc/zabbix_agentd.conf?

sed -i "s/^# ListenIP=0.0.0.0/ListenIP=$LOCAL_IP/" /usr/local/zabbix/etc/zabbix_agentd.conf?

sed -i 's/^# UnsafeUserParameters=0/UnsafeUserParameters=1/' /usr/local/zabbix/etc/zabbix_agentd.conf?


/etc/init.d/zabbix_agentd start?

?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容