zabbix-apt
zabbix-apt copied to clipboard
Feature: Add additional items with package names
Hi!
FWIW, since this is working great even with Zabbix 6.2, I made some modifications to get the package names besides only the counters, so that I can decide, if there is an important update or not.
- Change
apt.conf
:
# Treat security and regular updates differently
# This is just a simulation, that can be run under zabbix user
# Since updating packages lists (apt-get update) requires root user,
# use APT::Periodic or some other functionality for that
UserParameter=apt.security,apt-get -s upgrade | grep -ci ^inst.*security | tr -d '\n'
UserParameter=apt.updates,apt-get -s upgrade | grep -iPc '^Inst((?!security).)*$' | tr -d '\n'
UserParameter=apt.sec_text,apt-get -s upgrade | grep -io ^inst.*security | grep -oiP "([a-z0-9\.\-]+) \[([a-z0-9:~\-\+.]+)\] \(([a-z0-9:~\-\+.]+)" | sed 's#] (# -> #' | sed 's/$/]/'
UserParameter=apt.upd_text,apt-get -s upgrade | grep -iP '^Inst((?!security).)*$' | grep -oiP "([a-z0-9\.\-]+) \[([a-z0-9:~\-\+.]+)\] \(([a-z0-9:~\-\+.]+)" | sed 's#] (# -> #' | sed 's/$/]/'
- Modify Template:
<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>
<version>6.2</version>
<date>2022-11-30T12:35:37Z</date>
<template_groups>
<template_group>
<uuid>a571c0d144b14fd4a87a9d9b2aa9fcd6</uuid>
<name>Templates/Applications</name>
</template_group>
</template_groups>
<templates>
<template>
<uuid>ab900107205f48a5a79f6e83aaf610b9</uuid>
<template>Template App APT Updates</template>
<name>Template App APT Updates</name>
<groups>
<group>
<name>Templates/Applications</name>
</group>
</groups>
<items>
<item>
<uuid>7e25def970a84995b72a546bdb02c5c5</uuid>
<name>Security Updates</name>
<key>apt.security</key>
<delay>900</delay>
<trends>0</trends>
<tags>
<tag>
<tag>Application</tag>
<value>APT</value>
</tag>
</tags>
</item>
<item>
<uuid>0e4be9aa803340f99435f3784e735289</uuid>
<name>Security Content</name>
<key>apt.sec_text</key>
<delay>900</delay>
<trends>0</trends>
<value_type>TEXT</value_type>
<tags>
<tag>
<tag>Application</tag>
<value>APT</value>
</tag>
<tag>
<tag>APT</tag>
<value>Security</value>
</tag>
</tags>
</item>
<item>
<uuid>61b656de95544835984db066a375465a</uuid>
<name>Non-Critical Updates</name>
<key>apt.updates</key>
<delay>900</delay>
<trends>0</trends>
<tags>
<tag>
<tag>Application</tag>
<value>APT</value>
</tag>
</tags>
</item>
<item>
<uuid>726ce535bbe44f3080b0e6140636e3fc</uuid>
<name>Non-Critical Content</name>
<key>apt.upd_text</key>
<delay>900</delay>
<trends>0</trends>
<value_type>TEXT</value_type>
<tags>
<tag>
<tag>Application</tag>
<value>APT</value>
</tag>
<tag>
<tag>APT</tag>
<value>Non-Critical</value>
</tag>
</tags>
</item>
</items>
<tags>
<tag>
<tag>Application</tag>
<value>APT</value>
</tag>
</tags>
</template>
</templates>
<triggers>
<trigger>
<uuid>e2fdafc15f5b4d5da61b2bbdadcb1735</uuid>
<expression>last(/Template App APT Updates/apt.security)>0 and last(/Template App APT Updates/apt.updates)>0</expression>
<name>{ITEM.LASTVALUE1} security and {ITEM.LASTVALUE2} regular updates on {HOST.NAME}</name>
<priority>WARNING</priority>
<manual_close>YES</manual_close>
</trigger>
<trigger>
<uuid>c1083010fed846a199220a0685a7e998</uuid>
<expression>last(/Template App APT Updates/apt.security)>0 and last(/Template App APT Updates/apt.updates)=0</expression>
<name>{ITEM.LASTVALUE} of security updates on {HOST.NAME}:</name>
<priority>WARNING</priority>
<manual_close>YES</manual_close>
</trigger>
<trigger>
<uuid>61d9a47e71914a21ab18499d2fe1f4c2</uuid>
<expression>last(/Template App APT Updates/apt.updates)>0 and last(/Template App APT Updates/apt.security)=0</expression>
<name>{ITEM.LASTVALUE} regular updates on {HOST.NAME}</name>
<priority>INFO</priority>
<manual_close>YES</manual_close>
</trigger>
</triggers>
</zabbix_export>
You will get two new items Security Content
and Non-Critical Content
, which will show the package names of pending upgrades.
I, additionally, added a table widget to my Zabbix Dashboard, with the content of all 4 variables, so that I have a quick overview of what is pending.
Regards, Holger
That's cool. Are you able to add a screenshot of your widgets in action? i wonder how a large number of pending packages would render on the zabbix ui.
@hooliowobbits It is a condensed list. If you hover over a text part, the list shows at your mouse cursor. It currently renders like this (servernames greyed out:


fwiw this repo seems dead. might be worth making a fork and pushing your changes there complete with updated doco etc.
Yes, I know. But I had no time and was lazy 😁 .... maybe in a few days...