# make sure this is stretch
grep PRETTY_NAME /etc/os-release
# update system
apt-get update -y && apt-get dist-upgrade -y
# set only 16MB for the GPU
echo "gpu_mem=16" >> /boot/config.txt
# disable wifi to save power
echo "dtoverlay=pi3-disable-wifi" >> /boot/config.txt
# update firmware
rpi-update
# download and install zabbix repo
cd
wget https://repo.zabbix.com/zabbix/4.0/raspbian/pool/main/z/zabbix-release/zabbix-release_4.0-2+stretch_all.deb
dpkg -i zabbix-release_4.0-2+stretch_all.deb
# update system
apt update
# install all components + some conveniences
apt install zabbix-agent zabbix-proxy-sqlite3 zabbix-get zabbix-sender snmp-mibs-downloader snmp vim tidy jq git libxml2-utils
# make sure all services are not running
systemctl stop {zabbix-proxy,zabbix-agent}
# put proxy conf inside variable
proxy=/etc/zabbix/zabbix_proxy.conf
sed -i "s|^Server=.*$|Server=ec2-35-166-97-138.us-west-2.compute.amazonaws.com|" $proxy
sed -i '/^Hostname=.*$/d' $proxy
sed -i "s|^.*HostnameItem=.*$|HostnameItem=system.run\[ifconfig eth0\|egrep -o \"..:..:.. \"\|sed \"s\|:\|\|g;s\|.\$\|\|;s\|^\|RPiProxY\|\"\]|" $proxy
sed -i "s|^DBName=.*$|DBName=\/dev\/shm\/zabbix_proxy.db.sqlite3|" $proxy
sed -i "s|^PidFile=.*$|PidFile=\/dev\/shm\/zabbix_proxy.pid|" $proxy
sed -i "s|^LogFile=.*$|LogFile=\/dev\/shm\/zabbix_proxy.log|" $proxy
sed -i "s|^.*EnableRemoteCommands=.*$|EnableRemoteCommands=1|" $proxy
sed -i "s|^Timeout=.*$|Timeout=30|" $proxy
sed -i "s|^.*ConfigFrequency=.*$|ConfigFrequency=300|" $proxy
grep -v "^#\|^$" $proxy
# put agent conf inside variable
agent=/etc/zabbix/zabbix_agentd.conf
grep -v "^$\|^#" $agent
Set the log file for agent:
sed -i "s|^LogFile=.*$|LogFile=\/dev\/shm\/zabbix_agentd.log|" $agent
Set the pid file for agent:
sed -i "s|^PidFile=.*$|PidFile=\/dev\/shm\/zabbix_agentd.pid|" $agent
Remove the static hostname:
sed -i '/^Hostname=.*$/d' $agent
Set dynamic hostname:
sed -i "s|^.*HostnameItem=.*$|HostnameItem=system.run\[ifconfig eth0\|egrep -o \"..:..:.. \"\|sed \"s\|:\|\|g;s\|.\$\|\|;s\|^\|RPiProxY\|\"\]|" $agent
Enable remote commands:
sed -i "s|^.*EnableRemoteCommands=.*$|EnableRemoteCommands=1|" $agent
Allow zabbix agent to execute sensitive commmands like 'vcgencmd measure_temp':
usermod -a -G video zabbix
Observe again the latest configuration:
grep -v "^$\|^#" $agent
Start the agent:
systemctl start zabbix-agent
Check if the pid file and the log file have been created:
ls -l /dev/shm
Check the agent log file:
cat /dev/shm/zabbix_agentd.log
No comments:
Post a Comment