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>
This commit is contained in:
parent
2df5d52b9e
commit
5d1aa99648
3 changed files with 20 additions and 6 deletions
|
@ -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
|
||||
|
|
|
@ -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
admin/zabbix/files/zabbix-network-ubus-acl.json
Normal file
8
admin/zabbix/files/zabbix-network-ubus-acl.json
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"user": "zabbix",
|
||||
"access": {
|
||||
"network.interface": {
|
||||
"methods": [ "dump" ]
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue