您好,登錄后才能下訂單哦!
這篇文章主要介紹zabbix_agent如何安裝,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!
一.install_zabbix_agent_centos5.sh
#!/bin/bash
yum -y install unixODBC-devel unixODBC net-snmp net-snmp-devel OpenIPMI OpenIPM-devel openldap openldap-devel wget curl.x86_64
grep zabbix_agent /etc/services > /dev/null
stat1=$?
if [ $stat1 -ne 0 ];then
cat >> /etc/services <<EOF
zabbix_agent 10050/tcp #Zabbix Agent
zabbix_agent 10050/udp #Zabbix Agent
zabbix_trapper 10051/tcp #Zabbix Trapper
zabbix_trapper 10051/udp #Zabbix Trapper
EOF
fi
cd /opt
if [ -d "zabbix" ];then
/etc/init.d/zabbix_agentd stop
\mv zabbix /tmp
fi
tar zxvf zabbix-2.4.3_centos5.tar.gz
mv /opt/zabbix-2.4.3 /opt/zabbix
cp /opt/zabbix/zabbix_agentd /etc/init.d/
cp /opt/zabbix/iostatcron /etc/cron.d/
chown root:root /etc/cron.d/iostatcron
chown root:root /etc/init.d/zabbix_agentd
chmod a+x /etc/init.d/zabbix_agentd
rpm -ivh /opt/zabbix/python-pika-0.9.5-3.el5.noarch.rpm
id zabbix
stat=$?
if [ "$stat" -ne 0 ];then
useradd zabbix
chown -R zabbix:zabbix /opt/zabbix
else
chown -R zabbix:zabbix /opt/zabbix
fi
chmod a+x /opt/zabbix/sbin/*
chmod a+x /opt/zabbix/bin/*
chmod a+x /opt/zabbix/script/*
cat /var/spool/cron/root | grep "discovery_port.sh" | grep -v grep > /dev/null
stat1=$?
if [ "$stat1" -ne 0 ];then
echo "*/10 * * * * /opt/zabbix/script/discovery_port.sh > /dev/null 2>&1 &" >> /var/spool/cron/root
fi
cat /var/spool/cron/root | grep "discovery_services.py" | grep -v grep > /dev/null
stat2=$?
if [ "$stat2" -ne 0 ];then
echo "*/30 * * * * /usr/bin/nohup /opt/zabbix/script/discovery_services.py > /dev/null 2>&1 &" >> /var/spool/cron/root
fi
cat /var/spool/cron/root | grep "get_java_jstat.py" | grep -v grep > /dev/null
stat_jstat=$?
if [ "$stat_jstat" -ne 0 ];then
echo "*/1 * * * * /usr/bin/nohup /opt/zabbix/script/get_java_jstat.py > /dev/null 2>&1 &" >> /var/spool/cron/root
fi
#set hostname
#ip=`/sbin/ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v "172."|grep -v "192"|grep -v inet6|awk '{print $2}'|tr -d "addr:"|he
ad -n 1`
ip=`/sbin/ifconfig -a|grep inet|grep -v inet6|grep -v 127.0.0.1|awk -F\: '{print $2}'|awk '{print $1}'|grep -v "^172"|head -n 1
`
echo $ip
sed -i 's/Hostname=.*/Hostname='${ip}_jgz'/g' /opt/zabbix/etc/zabbix_agentd.conf
grep Hostname /opt/zabbix/etc/zabbix_agentd.conf
/etc/init.d/zabbix_agentd start
grep 'zabbix_agentd' /etc/rc.d/rc.local|grep -v grep > /dev/null
stat3=$?
if [ "$stat3" -ne 0 ];then
echo "/etc/init.d/zabbix_agentd start" >> /etc/rc.d/rc.local
fi
二.install_zabbix_agent_centos6.sh
#!/bin/bash
yum -y install unixODBC-devel unixODBC net-snmp net-snmp-devel OpenIPMI OpenIPM-devel openldap openldap-devel wget curl.x86_64
grep zabbix_agent /etc/services > /dev/null
stat1=$?
if [ $stat1 -ne 0 ];then
cat >> /etc/services <<EOF
zabbix_agent 10050/tcp #Zabbix Agent
zabbix_agent 10050/udp #Zabbix Agent
zabbix_trapper 10051/tcp #Zabbix Trapper
zabbix_trapper 10051/udp #Zabbix Trapper
EOF
fi
cd /opt
if [ -d "zabbix" ];then
/etc/init.d/zabbix_agentd stop
\mv zabbix /tmp
fi
tar zxvf zabbix-2.4.3_centos6.tar.gz
mv /opt/zabbix-2.4.3 /opt/zabbix
cp /opt/zabbix/zabbix_agentd /etc/init.d/
cp /opt/zabbix/iostatcron /etc/cron.d/
chown root:root /etc/cron.d/iostatcron
chown root:root /etc/init.d/zabbix_agentd
chmod a+x /etc/init.d/zabbix_agentd
rpm -ivh /opt/zabbix/python-pika-0.9.5-2.el6.noarch.rpm
id zabbix
stat=$?
if [ "$stat" -ne 0 ];then
useradd zabbix
chown -R zabbix:zabbix /opt/zabbix
else
chown -R zabbix:zabbix /opt/zabbix
fi
chmod a+x /opt/zabbix/sbin/*
chmod a+x /opt/zabbix/bin/*
chmod a+x /opt/zabbix/script/*
cat /var/spool/cron/root | grep "discovery_port.sh" | grep -v grep > /dev/null
stat1=$?
if [ "$stat1" -ne 0 ];then
echo "*/10 * * * * /opt/zabbix/script/discovery_port.sh > /dev/null 2>&1 &" >> /var/spool/cron/root
fi
cat /var/spool/cron/root | grep "discovery_services.py" | grep -v grep > /dev/null
stat2=$?
if [ "$stat2" -ne 0 ];then
echo "*/30 * * * * /usr/bin/nohup /opt/zabbix/script/discovery_services.py > /dev/null 2>&1 &" >> /var/spool/cron/root
fi
cat /var/spool/cron/root | grep "get_java_jstat.py" | grep -v grep > /dev/null
stat_jstat=$?
if [ "$stat_jstat" -ne 0 ];then
echo "*/1 * * * * /usr/bin/nohup /opt/zabbix/script/get_java_jstat.py > /dev/null 2>&1 &" >> /var/spool/cron/root
fi
#ip=`/sbin/ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v "172."|grep -v "192"|grep -v inet6|awk '{print $2}'|tr -d "addr:"|he
ad -n 1`
ip=`/sbin/ifconfig -a|grep inet|grep -v inet6|grep -v 127.0.0.1|awk -F\: '{print $2}'|awk '{print $1}'|grep -v "^172"|head -n 1
`
echo $ip
sed -i 's/Hostname=.*/Hostname='${ip}_jgz'/g' /opt/zabbix/etc/zabbix_agentd.conf
grep Hostname /opt/zabbix/etc/zabbix_agentd.conf
/etc/init.d/zabbix_agentd start
grep 'zabbix_agentd' /etc/rc.d/rc.local|grep -v grep > /dev/null
stat3=$?
if [ "$stat3" -ne 0 ];then
echo "/etc/init.d/zabbix_agentd start" >> /etc/rc.d/rc.local
fi
三.install_zabbix_agent_centos7.sh
#!/bin/bash
grep zabbix_agent /etc/services > /dev/null
stat1=$?
if [ $stat1 -ne 0 ];then
cat >> /etc/services <<EOF
zabbix_agent 10050/tcp #Zabbix Agent
zabbix_agent 10050/udp #Zabbix Agent
zabbix_trapper 10051/tcp #Zabbix Trapper
zabbix_trapper 10051/udp #Zabbix Trapper
EOF
fi
cd /opt
if [ -d "zabbix" ];then
/etc/init.d/zabbix_agentd stop
\mv zabbix /tmp
fi
tar zxvf zabbix-2.4.3_centos7.tar.gz
cd /opt/zabbix-2.4.3
./configure --prefix=/opt/zabbix --enable-agent
make
make install
#mv /opt/zabbix-2.4.3 /opt/zabbix
cp /opt/zabbix-2.4.3/zabbix_agentd /etc/init.d/
cp /opt/zabbix-2.4.3/iostatcron /etc/cron.d/
\cp /opt/zabbix-2.4.3/zabbix_agentd.conf /opt/zabbix/etc/
cp -r /opt/zabbix-2.4.3/script /opt/zabbix/script
mkdir /opt/zabbix/logs
mkdir /opt/zabbix/var
chown root:root /etc/cron.d/iostatcron
chown root:root /etc/init.d/zabbix_agentd
chmod a+x /etc/init.d/zabbix_agentd
rpm -ivh python2-pika-0.10.0-3.el7.noarch.rpm
id zabbix
stat=$?
if [ "$stat" -ne 0 ];then
useradd zabbix
chown -R zabbix:zabbix /opt/zabbix
else
chown -R zabbix:zabbix /opt/zabbix
fi
chmod a+x /opt/zabbix/sbin/*
chmod a+x /opt/zabbix/bin/*
chmod a+x /opt/zabbix/script/*
cat /var/spool/cron/root | grep "discovery_port.sh" | grep -v grep > /dev/null
stat1=$?
if [ "$stat1" -ne 0 ];then
echo "*/10 * * * * /opt/zabbix/script/discovery_port.sh > /dev/null 2>&1 &" >> /var/spool/cron/root
fi
cat /var/spool/cron/root | grep "discovery_services.py" | grep -v grep > /dev/null
stat2=$?
if [ "$stat2" -ne 0 ];then
echo "*/30 * * * * /usr/bin/nohup /opt/zabbix/script/discovery_services.py > /dev/null 2>&1 &" >> /var/spool/cron/root
fi
cat /var/spool/cron/root | grep "get_java_jstat.py" | grep -v grep > /dev/null
stat_jstat=$?
if [ "$stat_jstat" -ne 0 ];then
echo "*/1 * * * * /usr/bin/nohup /opt/zabbix/script/get_java_jstat.py > /dev/null 2>&1 &" >> /var/spool/cron/root
fi
#ip=`/sbin/ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v "172."|grep -v "192"|grep -v inet6|awk '{print $2}'|tr -d "addr:"|he
ad -n 1`
ip=`/sbin/ifconfig -a|grep inet|grep -v inet6|grep -v 127.0.0.1|awk -F\: '{print $2}'|awk '{print $1}'|grep -v "^172"|head -n 1
`
echo $ip
sed -i 's/Hostname=.*/Hostname='${ip}_jgz'/g' /opt/zabbix/etc/zabbix_agentd.conf
grep Hostname /opt/zabbix/etc/zabbix_agentd.conf
systemctl daemon-reload
/etc/init.d/zabbix_agentd start
grep 'zabbix_agentd' /etc/rc.d/rc.local|grep -v grep > /dev/null
stat3=$?
if [ "$stat3" -ne 0 ];then
echo "/etc/init.d/zabbix_agentd start" >> /etc/rc.d/rc.local
fi
以上是“zabbix_agent如何安裝”這篇文章的所有內容,感謝各位的閱讀!希望分享的內容對大家有幫助,更多相關知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。