-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzabbix-agent.sh
35 lines (35 loc) · 1.22 KB
/
zabbix-agent.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
#!/bin/bash/
Resolv= /etc/resolv.conf
if [ -f "$Resolv"]; then
sudo echo "resolv is exist!"
else
sudo touch /etc/resolv.conf
echo "nameserver 8.8.8.8 \nnameserver 4.2.2.4" > /etc/resolv.conf
fi
sudo apt update -y
File=/home/ubuntu/zabbix-release_6.0-4%2Bubuntu20.04_all.deb
if [ -f "$File"]; then
sudo echo "file does exist!!"
else
sudo echo "file does not exist!!"
wget https://repo.zabbix.com/zabbix/6.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.0-4%2Bubuntu20.04_all.deb
fi
sudo dpkg -i zabbix-release_6.0-4%2Bubuntu20.04_all.deb
sudo apt update
sudo apt install zabbix-agent -y
service_name="zabbix-agent"
if systemctl is-active --quiet "$service_name.service" ; then
sudo echo "$service_name running"
else
sudo systemctl start "$service_name"
fi
sudo echo "Please enter your zabbix server :"
read x
sudo echo "Please enter your hostname :"
read y
sudo sed -i "s/ServerActive=127.0.0.1/ServerActive=$x/" /etc/zabbix/zabbix_agentd.conf
sudo sed -i "s/Server=127.0.0.1/Server=$x/" /etc/zabbix/zabbix_agentd.conf
sudo sed -i 's/LogFileSize=0/LogFileSize=1/' /etc/zabbix/zabbix_agentd.conf
sudo sed -i "s/Hostname=Zabbix server/Hostname=$y/" /etc/zabbix/zabbix_agentd.conf
sudo systemctl restart zabbix-agent
sudo systemctl enable zabbix-agent