-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path500-zabbix-agent
More file actions
executable file
·74 lines (56 loc) · 1.83 KB
/
500-zabbix-agent
File metadata and controls
executable file
·74 lines (56 loc) · 1.83 KB
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
#!/bin/bash
# Setup the Zabbix agent
source common
INIT apt-remove --header "Removing existing Zabbix agents" -m purge --lazy zabbix-agent zabbix-agent2
INIT status "Setup Zabbix-Agent (+Plugins)"
INIT apt-install-url "https://repo.zabbix.com/zabbix/7.4/release/ubuntu/pool/main/z/zabbix-release/zabbix-release_7.4-0.2+ubuntu$(lsb_release -rs)_all.deb"
INIT apt-update
INIT apt-install \
zabbix-agent2 \
zabbix-agent2-plugin-mongodb \
zabbix-agent2-plugin-postgresql \
if [ -e "/etc/zabbix/zabbix_agentd.psk" ]; then
INIT skip "Generate Zabbix PSK Key"
else
INIT status "Generate Zabbix PSK key"
sudo sh -c "openssl rand -hex 32 > /etc/zabbix/zabbix_agentd.psk"
PSK=`cat /etc/zabbix/zabbix_agentd.psk`
echo
echo "Zabbix agent setup to continue with PSK [name = `hostname`] [PSK = [ $PSK ]]"
echo
echo "Press enter to continue, when this has been noted"
echo
read
fi
echo
echo "Enter upstream Zabbix server address"
ZABBIX_SERVER=`INIT ask --prompt "Zabbix Server" --var "PROFILE_ZABBIX_SERVER"`
echo
INIT status "Configure Zabbix-agent"
THIS_HOST=`hostname`
INIT file-set "/etc/zabbix/zabbix_agent2.conf" <<EOF
# Zabbix+Init v1.4
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=128
# Enable for debugging
# DebugLevel=4
Server=$ZABBIX_SERVER
ServerActive=$ZABBIX_SERVER
Hostname=$THIS_HOST
TLSConnect=psk
TLSAccept=psk
TLSPSKIdentity=$THIS_HOST
TLSPSKFile=/etc/zabbix/zabbix_agentd.psk
EnablePersistentBuffer=1
PersistentBufferPeriod=3h
PersistentBufferFile=/run/zabbix/zabbix-buffer.sqli
PluginSocket=/run/zabbix/agent.plugin.sock
ControlSocket=/run/zabbix/agent.sock
ForceActiveChecksOnStart=1
Include=/etc/zabbix/zabbix_agent2.d/plugins.d/*.conf
EOF
sudo systemctl restart zabbix-agent2
sudo systemctl enable zabbix-agent2
INIT status "Installing Firewall rule"
sudo ufw allow 10050/tcp