Pārlūkot izejas kodu

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>
Etienne CHAMPETIER 10 gadus atpakaļ
vecāks
revīzija
af1fe70acb
2 mainītis faili ar 3 papildinājumiem un 7 dzēšanām
  1. 1
    1
      admin/zabbix/Makefile
  2. 2
    6
      admin/zabbix/files/wifi

+ 1
- 1
admin/zabbix/Makefile Parādīt failu

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

+ 2
- 6
admin/zabbix/files/wifi Parādīt failu

@@ -2,8 +2,8 @@
2 2
 
3 3
 # wifi interface discovery
4 4
 # 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"}]}
5
-#
6
-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.."]}")'
5
+# ubus call only work as root so you need to run zabbix as root to use wifi.ifdiscovery
6
+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.."]}")'
7 7
 
8 8
 
9 9
 #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
23 23
 UserParameter=wifi.iwinfo.encryption[*],lua -l iwinfo -e "e = iwinfo[iwinfo.type('$1')].encryption('$1'); print(e and e.description or 'None')"
24 24
 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 ''))"
25 25
 
26
-#uci info (you need {#DEV} as parameter, like 'radio0')
27
-UserParameter=wifi.uci.hwmode[*],lua -l uci -e "x = uci.cursor(nil, '/var/state'); print(x:get('wireless','$1','hwmode'))"
28
-UserParameter=wifi.uci.channel[*],lua -l uci -e "x = uci.cursor(nil, '/var/state'); print(x:get('wireless','$1','channel'))"
29
-UserParameter=wifi.uci.txpower[*],lua -l uci -e "x = uci.cursor(nil, '/var/state'); print(x:get('wireless','$1','txpower'))"