Browse Source

zabbix: fix zabbix-extra-wifi discovery rule

As it use ubus call you need to run zabbix as root for it to work

Signed-off-by: Etienne CHAMPETIER <etienne.champetier@free.fr>
lilik-openwrt-22.03
Etienne CHAMPETIER 11 years ago
parent
commit
af1fe70acb
2 changed files with 3 additions and 7 deletions
  1. +1
    -1
      admin/zabbix/Makefile
  2. +2
    -6
      admin/zabbix/files/wifi

+ 1
- 1
admin/zabbix/Makefile View File

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=zabbix
PKG_VERSION:=2.2.3
PKG_RELEASE:=1
PKG_RELEASE:=2
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=@SF/zabbix


+ 2
- 6
admin/zabbix/files/wifi View File

@ -2,8 +2,8 @@
# wifi interface discovery
# exemple: {"data":[{"{#IF}":"wlan0", "{#MODE}":"ap", "{#SSID}":"Openwrt", "{#NET}":"lan", "{#DEV}":"radio0", "{#ENC}":"psk2+ccmp", "{#TYPE}":"mac80211", "{#HWMODE}":"11ng", "{#CHANNEL}":"11", "{#BSSID}":"xx:xx:xx:xx:xx:xx"}]}
#
UserParameter=wifi.ifdiscovery,lua -l uci -l iwinfo -e 'x = uci.cursor(nil, "/var/state");list = "{\"data\":[";x:foreach("wireless", "wifi-iface", function(s) list=list.."{\"{#IF}\":\""..s.ifname.."\", \"{#MODE}\":\""..s.mode.."\", \"{#SSID}\":\""..s.ssid.."\", \"{#NET}\":\""..s.network.."\", \"{#DEV}\":\""..s.device.."\", \"{#ENC}\":\""..(s.encryption or "?").."\", \"{#TYPE}\":\""..x:get("wireless",s.device,"type").."\", \"{#HWMODE}\":\""..(x:get("wireless",s.device,"hwmode") or "?").."\", \"{#CHANNEL}\":\""..x:get("wireless",s.device,"channel").."\", \"{#BSSID}\":\""..iwinfo[iwinfo.type(s.ifname)].bssid(s.ifname).."\"}," end); list=string.gsub(list,",$",""); print(list.."]}")'
# ubus call only work as root so you need to run zabbix as root to use wifi.ifdiscovery
UserParameter=wifi.ifdiscovery, lua -l uci -l ubus -l iwinfo -e 'u = ubus.connect();x = uci.cursor();list="{\"data\":[";stat=u:call("network.wireless", "status", {});for dev, dev_table in pairs(stat) do for i, iface in pairs(dev_table["interfaces"]) do s=iface["section"];list=list.."{\"{#IF}\":\""..iface["ifname"].."\", \"{#MODE}\":\""..x:get("wireless", s, "mode").."\", \"{#SSID}\":\""..x:get("wireless", s, "ssid").."\", \"{#NET}\":\""..x:get("wireless", s, "network").."\", \"{#DEV}\":\""..dev.."\", \"{#ENC}\":\""..(x:get("wireless", s, "encryption") or "?").."\", \"{#TYPE}\":\""..x:get("wireless", dev, "type").."\", \"{#HWMODE}\":\""..x:get("wireless", dev, "hwmode").."\", \"{#CHANNEL}\":\""..x:get("wireless", dev, "channel").."\", \"{#BSSID}\":\""..iwinfo[iwinfo.type(iface["ifname"])].bssid(iface["ifname"]).."\"},";end;end;list=string.gsub(list,",$","");print(list.."]}")'
#iwinfo info (you need {#IF} as parameter, like 'wlan0')
@ -23,7 +23,3 @@ UserParameter=wifi.iwinfo.nbusers[*],lua -l iwinfo -e "n = 0; for _,_ in pairs(i
UserParameter=wifi.iwinfo.encryption[*],lua -l iwinfo -e "e = iwinfo[iwinfo.type('$1')].encryption('$1'); print(e and e.description or 'None')"
UserParameter=wifi.iwinfo.hwmode[*],lua -l iwinfo -e "x=iwinfo[iwinfo.type('$1')].hwmodelist('$1'); print((x.a and 'a' or '')..(x.b and 'b' or '')..(x.g and 'g' or '')..(x.n and 'n' or ''))"
#uci info (you need {#DEV} as parameter, like 'radio0')
UserParameter=wifi.uci.hwmode[*],lua -l uci -e "x = uci.cursor(nil, '/var/state'); print(x:get('wireless','$1','hwmode'))"
UserParameter=wifi.uci.channel[*],lua -l uci -e "x = uci.cursor(nil, '/var/state'); print(x:get('wireless','$1','channel'))"
UserParameter=wifi.uci.txpower[*],lua -l uci -e "x = uci.cursor(nil, '/var/state'); print(x:get('wireless','$1','txpower'))"

Loading…
Cancel
Save