这篇文章主要介绍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进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。