【Zabbix】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
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31442725/viewspace-2148722/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- zabbix原始碼閱讀--zabbix_agent原始碼
- 自動化安裝zabbix指令碼(3.0/3.2)指令碼
- zabbix原始碼安裝原始碼
- zabbix安裝
- CentOS 7 原始碼安裝 Zabbix 6.0CentOS原始碼
- zabbix agent原始碼編譯安裝原始碼編譯
- 【ZABBIX】Linux下安裝ZABBIXLinux
- 【zabbix】zabbix遠端安裝部署
- zabbix安裝agent
- Zabbix安裝部署
- Zabbix Agent安裝
- apt安裝zabbixAPT
- zabbix3.4原始碼安裝步驟原始碼
- 原始碼安裝和配置zabbix 3.0 LST原始碼
- pyenv 安裝指令碼指令碼
- lnmp安裝指令碼LNMP指令碼
- zabbix安裝—–nginx安裝和配置Nginx
- 編譯安裝zabbix編譯
- 【監控】Zabbix安裝
- zabbix的安裝配置
- zabbix一鍵安裝
- zabbix3.0安裝
- 安裝zabbix使出錯
- Zabbix-2.4.5 安裝
- zabbix安裝文件薦
- zabbix5.0安裝
- Docker的指令碼安裝Docker指令碼
- Tomcat安裝指令碼Tomcat指令碼
- LNMP安裝shell指令碼LNMP指令碼
- Ansible安裝指令碼指令碼
- install安裝指令碼指令碼
- zabbix報警指令碼(wechat,email)指令碼AI
- shell指令碼:一鍵安裝LAMP、LNMP指令碼指令碼LAMPLNMP
- Zabbix 的容器版安裝
- Zabbix監控安裝部署
- centos8 安裝zabbixCentOS
- Zabbix Agent 安裝與使用
- Centos7-安裝ZabbixCentOS