这篇文章主要介绍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 <
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 <
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 <
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如何安装”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注创新互联行业资讯频道!
分享标题:zabbix_agent如何安装
网站URL:http://scpingwu.com/article/giijee.html