From 396022001ac00af010e125069502bf88ca0701ac Mon Sep 17 00:00:00 2001 From: Jonatan Z Date: Sun, 26 Mar 2023 11:58:06 +0200 Subject: [PATCH] first commit --- README.md | 2 ++ zabbix-setup.sh | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 README.md create mode 100644 zabbix-setup.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..809ad96 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# Simple Script to install Zabbix Agent 2 on VM or LXC +[https://www.zabbix.com/]() diff --git a/zabbix-setup.sh b/zabbix-setup.sh new file mode 100644 index 0000000..1f5de86 --- /dev/null +++ b/zabbix-setup.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +wget https://repo.zabbix.com/zabbix/5.2/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.2-1+ubuntu20.04_all.deb +dpkg -i zabbix-release_5.2-1+ubuntu20.04_all.deb +apt update +apt install zabbix-agent2 curl -y +sed -i 's/Server=127.0.0.1/Server=zabbix.vmlan/g' /etc/zabbix/zabbix_agent2.conf +sed -i 's/ServerActive=127.0.0.1/ServerActive=zabbix.vmlan/g' /etc/zabbix/zabbix_agent2.conf +sed -i 's/Hostname=Zabbix server/Hostname='$(hostname)'.vmlan/g' /etc/zabbix/zabbix_agent2.conf + + +lxc=$(systemd-detect-virt | grep lxc) + +if [ $lxc = lxc ]; then + echo "I'm inside matrix ;("; + curl -o /etc/zabbix/zabbix_agent2.d/zabbix_container.conf https://raw.githubusercontent.com/kvaps/zabbix-linux-container-template/master/zabbix_container.conf && systemctl restart zabbix-agent2 +else + echo "I'm living in real world!"; +fi + + + +systemctl enable zabbix-agent2 +systemctl start zabbix-agent2 +systemctl restart zabbix-agent2 + + +