zabbix-agent安裝指令碼
阿新 • • 發佈:2020-09-04
##!/bin/bash # file:ssh.sh # author: pansn # date:2020-07-17 15:02 # version 1.0 # description: Shell script # @Copyright (c) all right reserved #IP=`ifconfig | grep -E -o "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[04][0-9]|[01]?[0-9][0-9]?)"|grep -E '^10\.|^172\.|^192\.'|head -n1` wget https://repo.zabbix.com/zabbix/5.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.0-1+xenial_all.deb dpkg -i zabbix-release_5.0-1+xenial_all.deb apt update echo "安裝zabbix-agent" apt install zabbix-agent -y #rm -rf zabbix-agent-4.2.6-1.el7.x86_64.rpm echo‘備份agent.conf配置檔案‘ cp /etc/zabbix/zabbix_agentd.conf /etc/zabbix/zabbix_agentd.conf.bak echo '修改配置檔案' sed -i 's/Server=127.0.0.1/Server=zbx.xxx.cn/' /etc/zabbix/zabbix_agentd.conf sed -i "s/Hostname=Zabbix server/Hostname=`hostname`/" /etc/zabbix/zabbix_agentd.conf sed -i 's/^ServerActive=127.0.0.1/ServerActive=zbx.xxx.cn/' /etc/zabbix/zabbix_agentd.conf sed -i 's/# HostMetadata=/HostMetadata=linux zabbix.oneplus/' /etc/zabbix/zabbix_agentd.conf systemctl start zabbix-agent && systemctl enable zabbix-agent #檢測是否存在agent埠 port=$(netstat -nlp|grep 10050|wc -l) if [ ${port} -ne 0 ];then echo "zabbix-agent安裝成功" else echo "zabbix安裝失敗請檢查" fi rm -rf zabbix-release_5.0-1+xenial_all.deb