diff --git a/admin/zabbix/Makefile b/admin/zabbix/Makefile index 9c7102d99..6710e4c21 100644 --- a/admin/zabbix/Makefile +++ b/admin/zabbix/Makefile @@ -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 diff --git a/admin/zabbix/files/network b/admin/zabbix/files/network index b68e2a505..cc0105921 100644 --- a/admin/zabbix/files/network +++ b/admin/zabbix/files/network @@ -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.."]}")' diff --git a/admin/zabbix/files/zabbix-network-ubus-acl.json b/admin/zabbix/files/zabbix-network-ubus-acl.json new file mode 100644 index 000000000..f19f51b16 --- /dev/null +++ b/admin/zabbix/files/zabbix-network-ubus-acl.json @@ -0,0 +1,8 @@ +{ + "user": "zabbix", + "access": { + "network.interface": { + "methods": [ "dump" ] + } + } +}