forked from AutisticShark/Airport-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
zabbix_agent_c7.sh
78 lines (68 loc) · 2.77 KB
/
zabbix_agent_c7.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
cat << "EOF"
______ ____ __
/\__ _\ __ /\ _`\ /\ \__
\/_/\ \/ ___ __ _/\_\ ___ \ \ \/\_\ __ \ \ ,_\
\ \ \ / __`\/\ \/'\/\ \ /'___\ \ \ \/_/_ /'__`\ \ \ \/
\ \ \/\ \L\ \/> </\ \ \/\ \__/ \ \ \L\ \/\ \L\.\_\ \ \_
\ \_\ \____//\_/\_\\ \_\ \____\ \ \____/\ \__/.\_\\ \__\
\/_/\/___/ \//\/_/ \/_/\/____/ \/___/ \/__/\/_/ \/__/
Author: Toxic Cat
Github: https://github.com/Toxic-Cat/Airport-toolkit
EOF
echo "Zabbix installation script for CentOS 7 x64"
[ $(id -u) != "0" ] && { echo "Error: You must be root to run this script!"; exit 1; }
#Configuration
zabbix_release_40_url = http://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-2.el7.noarch.rpm
zabbix_release_41_url = http://repo.zabbix.com/zabbix/4.1/rhel/7/x86_64/zabbix-release-4.1-1.el7.noarch.rpm
zabbix_release_42_url = http://repo.zabbix.com/zabbix/4.2/rhel/7/x86_64/zabbix-release-4.2-2.el7.noarch.rpm
zabbix_release_43_url = http://repo.zabbix.com/zabbix/4.3/rhel/7/x86_64/zabbix-release-4.3-3.el7.noarch.rpm
while :; do echo
echo -e "Please select Zabbix agent version you want to install:"
echo -e "\t1. 4.0"
echo -e "\t2. 4.1"
echo -e "\t3. 4.2"
echo -e "\t4. 4.3"
read -p "Please input a number:(Default 1 press Enter) " connection_method
[ -z ${connection_method} ] && connection_method=1
if [[ ! ${connection_method} =~ ^[1-4]$ ]]; then
echo "Bad answer! Please only input number 1~4"
else
break
fi
done
do_zabbix_agent_configure(){
echo -n "Please enter Zabbix master's IP address:"
read zabbix_master_ip
echo -n "Please enter this server's hostname:"
read agent_hostname
}
do_edit_zabbix_agent_config(){
sed -i -e "s/Server=127.0.0.1/Server=$zabbix_master_ip/g" -e "s/ServerActive=127.0.0.1/ServerActive=$zabbix_master_ip/g" -e "s/Hostname=Zabbix server/Hostname=$agent_hostname/g" /etc/zabbix/zabbix_agentd.conf
}
do_install_zabbix_agent_40(){
do_zabbix_agent_configure
rpm -ivh $zabbix_release_40_url
yum install zabbix-agent -y
do_edit_zabbix_agent_config
}
do_install_zabbix_agent_41(){
do_zabbix_agent_configure
rpm -ivh $zabbix_release_41_url
yum install zabbix-agent -y
do_edit_zabbix_agent_config
}
do_install_zabbix_agent_42(){
do_zabbix_agent_configure
rpm -ivh $zabbix_release_42_url
yum install zabbix-agent -y
do_edit_zabbix_agent_config
}
do_install_zabbix_agent_43(){
do_zabbix_agent_configure
rpm -ivh $zabbix_release_43_url
yum install zabbix-agent -y
do_edit_zabbix_agent_config
}