forked from AutisticShark/Airport-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
zabbix_agent_c8.sh
64 lines (53 loc) · 1.92 KB
/
zabbix_agent_c8.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
#!/usr/bin/env bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
cat << "EOF"
Author: M1Screw
Github: https://github.com/M1Screw/Airport-toolkit
EOF
echo "Zabbix agent installation script for CentOS Stream 8 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/8/x86_64/zabbix-release-4.0-2.el8.noarch.rpm"
zabbix_release_50_url="http://repo.zabbix.com/zabbix/5.0/rhel/8/x86_64/zabbix-release-5.0-1.el8.noarch.rpm"
zabbix_config_file_path="/etc/zabbix/zabbix_agentd.conf"
while :; do echo
echo -e "Please select Zabbix agent version you want to install:"
echo -e "\t1. 4.0"
echo -e "\t2. 5.0"
read -p "Please input a number:(Default 2 press Enter) " zabbix_version
[ -z ${zabbix_version} ] && zabbix_version=1
if [[ ! ${zabbix_version} =~ ^[1-2]$ ]]; then
echo "Bad answer! Please only input number 1~2"
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" $zabbix_config_file_path
}
do_enable_and_start_zabbix_agent(){
systemctl enable zabbix-agent
systemctl restart zabbix-agent
}
do_install_zabbix_agent_40(){
rpm -ivh $zabbix_release_40_url
yum install zabbix-agent -y
}
do_install_zabbix_agent_50(){
rpm -ivh $zabbix_release_50_url
yum install zabbix-agent -y
}
do_zabbix_agent_configure
if [[ ${zabbix_version} == 1 ]]; then
do_install_zabbix_agent_40
elif [[ ${zabbix_version} == 2 ]]; then
do_install_zabbix_agent_50
fi
do_enable_and_start_zabbix_agent