【zabbix】zabbix遠端安裝部署

ringoo_ming發表於2017-12-14

利用的指令碼有之前介紹的python指令碼: 【python】用python指令碼實現ansible的推送、下載、上傳檔案功能  



  1. # ! / bin / bash

  2. IP = $ 1
  3. exceptip_file = "/opt/python/set_host_proxy_exceptip.txt"
  4. # check zabbix_agent is started
  5. stat_z = ` python / opt / python / paramiko - upload . py - H $IP - c 'ps -ef|grep zabbix_agentd|grep -v sh|grep -v grep>/dev/null;echo $?' | g
  6. rep - v "#" | grep - v IP | grep - v Perform | grep - v Script`
  7. echo $stat_z
  8. #exit 0

  9. if [ $stat_z - ne 0 ] ; then
  10.     # 得到作業系統的版本
  11.     OS_VERSION = ` python / opt / python / paramiko - upload . py - H $IP - c "cat /etc/redhat-release" | awk - F 'release' '{print $2}' | awk '{pr
  12. int $1}' | awk - F\ . '{print $1}' `
  13.     echo $OS_VERSION
  14.     # 開始安裝
  15.     #如果作業系統的版本是6
  16.      if [ "$OS_VERSION" - eq 6 ] ; then
  17.         echo "centos 6"
  18.         python / opt / python / paramiko - upload . py - H $IP - s '/opt/python/zabbix_agentd' '/opt' zabbix - 2 . 4 . 3_centos6 . tar . gz
  19.         python / opt / python / paramiko - upload . py - H $IP - s '/opt/python/zabbix_agentd' '/opt' install_zabbix_agent_centos6 . sh
  20.         python / opt / python / paramiko - upload . py - H $IP - c 'sh /opt/install_zabbix_agent_centos6.sh'
  21.      #如果作業系統的版本是7
  22.     elif [ "$OS_VERSION" - eq 7 ] ; then
  23.         echo "centos 7"
  24.         python / opt / python / paramiko - upload . py - H $IP - s '/opt/python/zabbix_agentd' '/opt' zabbix - 2 . 4 . 3_centos7 . tar . gz
  25.         python / opt / python / paramiko - upload . py - H $IP - s '/opt/python/zabbix_agentd' '/opt' install_zabbix_agent_centos7 . sh
  26.         python / opt / python / paramiko - upload . py - H $IP - c 'sh /opt/install_zabbix_agent_centos7.sh'
  27.      #如果作業系統的版本是5
  28.      elif [ "$OS_VERSION" - eq 5 ] ; then
  29.     echo "centos 5"
  30.     python / opt / python / paramiko - upload . py - H $IP - s '/opt/python/zabbix_agentd' '/opt' zabbix - 2 . 4 . 3_centos5 . tar . gz
  31.     python / opt / python / paramiko - upload . py - H $IP - s '/opt/python/zabbix_agentd' '/opt' install_zabbix_agent_centos5 . sh
  32.     python / opt / python / paramiko - upload . py - H $IP - c 'sh /opt/install_zabbix_agent_centos5.sh'
  33.     fi
  34.     #升級zabbix的配置
  35.     sh / opt / python / yuanchen_update_zabbix_agent . sh $IP
  36. else
  37.     # updata zabbix_agent config
  38.     sh / opt / python / yuanchen_update_zabbix_agent . sh $IP
  39. fi


關於zabbix _agent_centos不同版本的指令碼請參見這裡:
install_zabbix_agent_centos5.sh
install_zabbix_agent_centos6.sh
install_zabbix_agent_centos7.sh




來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31442725/viewspace-2148721/,如需轉載,請註明出處,否則將追究法律責任。