Zabbix - adding apt update checks

Theres a number of articles on the internet on adding checks to package updates for Zabbix and Nagios.  I found the simplest way of doing this on Ubuntu is to use the update-notifier app-check application.   If you run /usr/lib/update-notifier/apt-check it will output the number of packages requiring updates as well as the number of security updates requiring updates.

To apply this check to Zabbix add the following to a conf file within your zabbix_agentd.d directory.

  • cd /etc/zabbix/zabbix_agentd.d
  • vi apt_updates.conf  or something meaningfule 
  • add the following content
  • UnsafeUserParameters=1
  • Timeout=10
  • UserParameter=apt.available.updates,updates=$(/usr/lib/update-notifier/apt-check 2>&1);echo $updates | cut -d ";" -f 1
  • UserParameter=apt.security.updates,updates=$(/usr/lib/update-notifier/apt-check 2>&1);echo $updates | cut -d ";" -f 2
  • restart your zabbix agent
The Timeout=10 is required as the script runs for a couple of seconds
Once the new userParameter has been added you can then add this to your zabbix console.  If like me you require this on all your Linux servers its best to deploy the file via Puppet or your preferred orchestration server.  Once deployed add a new item under the Linux OS template.

  • go to Configuration->Templates and click on Template OS Linux
  • click on Items
  • Click on Create Item
  • In the name field add apt.available.updates
  • In the key field add apt.available.updates
  • Save the item
  • Do the same for the Security updates
  • Click on Create Item
  • in the name field add apt.security.updates
  • In the key field add apt.security.updates
  • Save the item
If you require a trigger for the security updates,  
  • click on the Triggers link
  • click on Create trigger
  • Add a name of your chosing 
  • Add a severity  I usually use Warning as a base
  • Click Add  next to the expression field
  • Select Templates Under the Group items
  • Select your newly created Item
  • Under function select "Previous value is > N"
  • Save the trigger.
Enjoy !


Comments

Popular posts from this blog

DSTV Now on Amazon Fire TV Stick

Update Openvas Feeds