First make structure:
sudo mkdir /mydata && sudo mkdir /mydata/updates
Update the system:
sudo -s
sudo apt-get update > /mydata/updates/logs/latest-Linux-repoupdate.log && echo "Update complete.... doing OS upgrade" && sudo apt -y upgrade --auto-remove > /mydata/updates/logs/latest-Linux-OSpatches.log && echo "Upgrade complete....cleaning up..." && sudo apt clean >> /mydata/updates/logs/latest-Linux-OSpatches.log && echo "Cleaning complete...saving timestamp and saving logs..." && sudo touch /mydata/updates/latest-Linux-patches-date && sudo echo date >> /mydata/updates/latest-Linux-patches-date && echo "Upgrade complete, logs stored in: /mydata/updates/logs"
Edit Zabbix-agent2 configuration:
sudo vi /etc/zabbix/zabbix_agent2.conf
UserParameter=apt.daysSinceUpgrade,aptTime=$(expr `date +%s` - `stat -c %Y /mydata/updates/latest-Linux-patches-date`) && echo $(( aptTime / 86400 ))
Add a template in Zabbix:
Add triggers according to your taste:
You can then play around with this in the dashboards to give a heads up when it's time to upgrade the system.
Good luck!
Kommentarer
Skicka en kommentar