I'm trying to make a template for Debian/Ubuntu package versions (since Zabbix's system.sw.package does not get versions from dpkg) and I am having some trouble finding what a discovery rule key value should be.
Both the server and agent are Debian 11, Zabbix server version is 6.0.4, Agent version is 6.0.6
So far this is my template configuration:
Macro:
{$SYSTEM.PACKAGE.MATCHES} .* Filter of system packages by name
Discovery rule:
Name: Package Version Discovery
Key: system.sw.package.version
Filters: {#PKG} matches {$SYSTEM.PACKAGE.MATCHES}
Item prototype:
Name: {#PKG} Version
Key: system.sw.package.version["{#PKG}"]
On the Zabbix agent I have a custom parameter defined:
UserParameter=system.sw.package.version[*],/bin/dpkg-query --show '--showformat=${Version}\n' $1 2>/dev/null | sed -e 's/+.*//g' 2>/dev/null | sed -e 's/1://g' 2>/dev/null | sed -e 's/~.*//g' 2>/dev/null
(ignore my terrible way of getting the package version isolated in the dpkg-query command....)
On other templates, the discovery rule has a specific [value] on the key. For example the systemd template (https://www.zabbix.com/integrations/systemd) has its discovery rule key look like this: systemd.unit.discovery[service]
But [service] is not referenced anywhere else in the template, and since systemd is monitored naively through zabbix-agent2, I don't really know what [service] is doing on the agent side.
So with a custom userparameter for the key, what do I need to add to the discovery rule key to act similar in function to the systemd template?
The end goal here is to apply the template to a host, and define a macro (in this case {$SYSTEM.PACKAGE.MATCHES} ) with a list of packages to get versions for (for example, openssh-server|apache2|dnsmasq), and have a discovery rule create items for each package name in the macro.
Can anyone help me with this?
Both the server and agent are Debian 11, Zabbix server version is 6.0.4, Agent version is 6.0.6
So far this is my template configuration:
Macro:
{$SYSTEM.PACKAGE.MATCHES} .* Filter of system packages by name
Discovery rule:
Name: Package Version Discovery
Key: system.sw.package.version
Filters: {#PKG} matches {$SYSTEM.PACKAGE.MATCHES}
Item prototype:
Name: {#PKG} Version
Key: system.sw.package.version["{#PKG}"]
On the Zabbix agent I have a custom parameter defined:
UserParameter=system.sw.package.version[*],/bin/dpkg-query --show '--showformat=${Version}\n' $1 2>/dev/null | sed -e 's/+.*//g' 2>/dev/null | sed -e 's/1://g' 2>/dev/null | sed -e 's/~.*//g' 2>/dev/null
(ignore my terrible way of getting the package version isolated in the dpkg-query command....)
On other templates, the discovery rule has a specific [value] on the key. For example the systemd template (https://www.zabbix.com/integrations/systemd) has its discovery rule key look like this: systemd.unit.discovery[service]
But [service] is not referenced anywhere else in the template, and since systemd is monitored naively through zabbix-agent2, I don't really know what [service] is doing on the agent side.
So with a custom userparameter for the key, what do I need to add to the discovery rule key to act similar in function to the systemd template?
The end goal here is to apply the template to a host, and define a macro (in this case {$SYSTEM.PACKAGE.MATCHES} ) with a list of packages to get versions for (for example, openssh-server|apache2|dnsmasq), and have a discovery rule create items for each package name in the macro.
Can anyone help me with this?
Comment