zabbix 客户端一键安装脚本

作者: print("") 分类: linux 发布时间: 2018-04-25 17:23

写了一个很 low 很low 的zabbix 客户端的安装代码

下载地址如下:https://www.o2oxy.cn/zabbix.sh

#!/bin/bash


Host=`date  | cut -b 12-19`
ServerIP="103.233.11.72"

check_zabbix(){
	check=`rpm -qa |grep zabbix-agent | cut -b 1-12`
	if [ $check == 'zabbix-agent'  ];then
		echo "OK"
	else	rpm -ivh http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm 
		yum install zabbix-agent -y 
		modify_file
		start_zabbix
		echo_iptables
		Obtain_ip
		
	fi 
}

modify_file(){
	if [ -f  /etc/zabbix/zabbix_agentd.conf ];then
		sed -i 's/Server=127.0.0.1/Server=103.233.11.72/g' /etc/zabbix/zabbix_agentd.conf
		sed -i 's/ServerActive=127.0.0.1/ServerActive=103.233.11.72/g' /etc/zabbix/zabbix_agentd.conf
		sed -i 's/Hostname=Zabbix server/Hostname=client/g' /etc/zabbix/zabbix_agentd.conf
		check_file1=`cat /etc/zabbix/zabbix_agentd.conf |grep Server=103.233.11.72 |wc -l`
		check_file2=`cat /etc/zabbix/zabbix_agentd.conf |grep  ServerActive=103.233.11.72 |wc -l`
		check_file=`cat /etc/zabbix/zabbix_agentd.conf |grep Hostname=client  |wc -l`
		if [ check_file != 0 ];then
			echo "ServerIP OK" 
		else
			echo "Server NO"
			exit
		fi
		
		if [ check_file1 != 0 ];then
			echo "ServerActive OK" 
		else
			echo "Server NO"
			exit
		fi
		
		if [ check_file2 != 0 ];then
	 		echo  "HostName OK"
		fi
	else
		echo "good bey "
		exit
	fi 
	
}

start_zabbix(){
	if [ -f /etc/init.d/zabbix-agent ];then
	     /etc/init.d/zabbix-agent start
	else
	   echo "false"
	   exit 
	fi 
}


echo_iptables(){
	iptables -I INPUT -m state --state NEW -m udp -p udp --dport 10050 -j ACCEPT
	iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 10050 -j ACCEPT
}



Obtain_ip(){
	ip=	`curl members.3322.org/dyndns/getip`
	echo $ip

}
check_zabbix

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!

1
说点什么

avatar
1 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
0 Comment authors
通过宝塔面板编译安装zabbix 3.0 – DAF_sec Recent comment authors
  Subscribe  
最新 最旧 得票最多
提醒
trackback

[…] https://www.o2oxy.cn/708.html […]