Browse Source

zabbix: use ubus for zabbix-extra-network

this allow us to stop using uci /var/state,
which is deprecated since forever

Signed-off-by: Etienne Champetier <champetier.etienne@gmail.com>
lilik-openwrt-22.03
Etienne Champetier 6 years ago
parent
commit
5d1aa99648
3 changed files with 20 additions and 6 deletions
  1. +11
    -2
      admin/zabbix/Makefile
  2. +1
    -4
      admin/zabbix/files/network
  3. +8
    -0
      admin/zabbix/files/zabbix-network-ubus-acl.json

+ 11
- 2
admin/zabbix/Makefile View File

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=zabbix
PKG_VERSION:=3.4.14
PKG_RELEASE:=3
PKG_RELEASE:=4
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_HASH:=7443873cc970672d3c884230d3aeb082f2d8afcc2b757506c2d684ffdd12d77e
@ -74,7 +74,7 @@ endef
define Package/zabbix-extra-network
$(call Package/zabbix/Default)
TITLE+= discovery/userparameters for network
DEPENDS = +zabbix-agentd +libuci-lua +lua
DEPENDS = +zabbix-agentd +libubus-lua +lua
endef
define Package/zabbix-extra-wifi
@ -229,6 +229,15 @@ endef
define Package/zabbix-extra-network/install
$(call Package/zabbix/install/zabbix.conf.d,$(1),network)
$(INSTALL_DIR) $(1)/usr/share/acl.d
$(INSTALL_DATA) ./files/zabbix-network-ubus-acl.json $(1)/usr/share/acl.d/zabbix-network.json
endef
define Package/zabbix-extra-network/postinst
#!/bin/sh
if [ -z "$${IPKG_INSTROOT}" ]; then
killall -HUP ubusd
fi
endef
define Package/zabbix-extra-wifi/install


+ 1
- 4
admin/zabbix/files/network View File

@ -3,7 +3,4 @@
# network interface discovery
# example: {"data":[{"{#IF}":"lo", "{#NET}":"loopback"},{"{#IF}":"br-lan", "{#NET}":"lan"},{"{#IF}":"eth0.1", "{#NET}":"wan"}]}
#
UserParameter=netowrt.discovery,lua -l uci -e 'x = uci.cursor(nil, "/var/state");list = "{\"data\":[";x:foreach("network", "interface", function(s) list=list.."{\"{#IF}\":\""..s.ifname.."\", \"{#NET}\":\""..s[".name"].."\"}," end); list=string.gsub(list,",$",""); print(list.."]}")'
UserParameter=netowrt.discovery,lua -l ubus -e 'u=ubus.connect();list="{\"data\":[";dump=u:call("network.interface", "dump", {});for _, intf in ipairs(dump.interface) do list=list.."{\"{#IF}\":\""..intf.device.."\", \"{#NET}\":\""..intf.interface.."\"},";end;list=string.gsub(list,",$","");print(list.."]}")'

+ 8
- 0
admin/zabbix/files/zabbix-network-ubus-acl.json View File

@ -0,0 +1,8 @@
{
"user": "zabbix",
"access": {
"network.interface": {
"methods": [ "dump" ]
}
}
}

Loading…
Cancel
Save