I've been experimenting with Zabbix Agent (7.0.12) on OpenWrt stable and the Linux by Zabbix Agent template mostly works[1].
I did, however, discover that system.sw.packages.get does not work with opkg (the current OpenWrt package manager). Because I couldn't override the built-in key, I cloned a template with a new key system.sw.owrt_packages.get which runs a user script (below). So I have two questions about this:
- Is there a better way to handle this kind of situation than cloning and using user script with a new key?
- For the script below, suggestions on improvements are welcome. I am not an
awkguru and am sure there are better ways of writing this script. At least it is many times faster than the shellwhile read var; doloop I first had. Pointers to lists / forums where folks more familiar with awk hang out would be appreciated (my web searching has gotten frustrating as the search engines emphasize fluffy ad-laden content over useful results).
#!/bin/sh
echo "["
opkg info 2>/dev/null| \
awk 'BEGIN { RS=ORS="\n\n\n"; FS=OFS="\n" } { print $0 }' | \
awk 'BEGIN { RS="\n\n"; FS="\n" } /Status: install ok installed/ { print $0 "\n\n" }' | \
awk 'BEGIN { FS="\n" } $1 ~ /Package|Version|Size|Architecture|Installed-Time/ { print $0 }' | \
awk 'BEGIN { RS="\n", FS=": " }
$1 == "Package" { print "\"name\": " "\"" $2 "\"," }
$1 == "Version" { print "\"version\": " "\"" $2 "\"," }
$1 == "Size" { print "\"size\": " $2 "," }
$1 == "Architecture" { print "\"arch\": " "\"" $2 "\"," }
$1 == "Installed-Time" { print "\"buildtime\": {\n\"timestamp\": 0,\n\"value\": \"\"\n},\n\"installtime\": {\n\"timestamp\": " $2 ",\n\"value\": \"" strftime("%b %d %H:%M:%S %Y %Z",$2) "\"\n}\n}," }
' | \
awk 'BEGIN { FS="\n" }
/name/ { print "{\n" $0 "\n\"manager\": \"opkg\"," }
$0 !~ /name/ { print $0 }
' | \
sed -e '$s%,%%'
echo "]"
which gets the output of opkg from this format:
Package: ppp-mod-pppoe
Version: 2.5.1-r1
Depends: libc, kmod-pppoe
Status: install ok installed
Section: net
Architecture: aarch64_cortex-a76
Size: 13872
Filename: ppp-mod-pppoe_2.5.1-r1_aarch64_cortex-a76.ipk
Description: This package contains a PPPoE (PPP over Ethernet) plugin for ppp.
Installed-Time: 1758316778
Package: collectd-mod-df
Version: 5.12.0-r54
Depends: libc, collectd
Status: install ok installed
Section: utils
Architecture: aarch64_cortex-a76
Size: 7952
Filename: collectd-mod-df_5.12.0-r54_aarch64_cortex-a76.ipk
Description: disk space input plugin
Installed-Time: 1758316778
to the system.sw.packages.get-style JSON:
{
"name": "ppp-mod-pppoe",
"manager": "opkg",
"version": "2.5.1-r1",
"arch": "aarch64_cortex-a76",
"size": 13872,
"buildtime": {
"timestamp": 0,
"value": ""
},
"installtime": {
"timestamp": 1758316778,
"value": "Sep 19 17:19:38 2025 EDT"
}
},
{
"name": "collectd-mod-df",
"manager": "opkg",
"version": "5.12.0-r54",
"arch": "aarch64_cortex-a76",
"size": 7952,
"buildtime": {
"timestamp": 0,
"value": ""
},
"installtime": {
"timestamp": 1758316778,
"value": "Sep 19 17:19:38 2025 EDT"
}
},
I've also gotten the frontend running on OpenWrt on an old Gigabyte mini-PC, and it looks like it might work the for the relatively small number of hosts I am monitoring (20-ish including network devices), but that is another story...
[1] The main unsupported bits besides the one in this post are complaints about 'speed' not supported on some interfaces that I do not have configured (and don't care about).
I’ve also posted on the Zabbix community-templates Discussions as this is rather obscure.