Skip to content

Instantly share code, notes, and snippets.

@xandr0s
Created May 8, 2014 10:06
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save xandr0s/274ad3ae2c128a662395 to your computer and use it in GitHub Desktop.
Save xandr0s/274ad3ae2c128a662395 to your computer and use it in GitHub Desktop.
Config Zabbix-agent on OpenWRT router/AP
LogFile=/tmp/zabbix_agentd.log
Server=1.2.3.4
ServerActive=1.2.3.4
Hostname=Zabbix server
# 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.."]}")'
#iwinfo info (you need {#IF} as parameter, like 'wlan0')
UserParameter=wifi.iwinfo.channel[*],lua -l iwinfo -e "print(iwinfo[iwinfo.type('$1')].channel('$1'))"
UserParameter=wifi.iwinfo.frequency[*],lua -l iwinfo -e "print(iwinfo[iwinfo.type('$1')].frequency('$1'))"
UserParameter=wifi.iwinfo.txpower[*],lua -l iwinfo -e "print(iwinfo[iwinfo.type('$1')].txpower('$1'))"
UserParameter=wifi.iwinfo.bitrate[*],lua -l iwinfo -e "b = iwinfo[iwinfo.type('$1')].bitrate('$1'); print(b or '0')"
UserParameter=wifi.iwinfo.signal[*],lua -l iwinfo -e "s = iwinfo[iwinfo.type('$1')].signal('$1'); print(s or '-255')"
UserParameter=wifi.iwinfo.noise[*],lua -l iwinfo -e "print(iwinfo[iwinfo.type('$1')].noise('$1'))"
UserParameter=wifi.iwinfo.quality[*],lua -l iwinfo -e "print(iwinfo[iwinfo.type('$1')].quality('$1'))"
UserParameter=wifi.iwinfo.quality_max[*],lua -l iwinfo -e "print(iwinfo[iwinfo.type('$1')].quality_max('$1'))"
UserParameter=wifi.iwinfo.mode[*],lua -l iwinfo -e "print(iwinfo[iwinfo.type('$1')].mode('$1'))"
UserParameter=wifi.iwinfo.ssid[*],lua -l iwinfo -e "print(iwinfo[iwinfo.type('$1')].ssid('$1'))"
UserParameter=wifi.iwinfo.bssid[*],lua -l iwinfo -e "print(iwinfo[iwinfo.type('$1')].bssid('$1'))"
UserParameter=wifi.iwinfo.country[*],lua -l iwinfo -e "print(iwinfo[iwinfo.type('$1')].country('$1'))"
UserParameter=wifi.iwinfo.nbusers[*],lua -l iwinfo -e "n = 0; for _,_ in pairs(iwinfo[iwinfo.type('$1')].assoclist('$1')) do n = n + 1 end; print(n)"
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 ''))"
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'))"
#see http://wiki.openwrt.org/doc/howto/zabbix for ready to use templates
# If you want to know the exact meaning of an UserParameter, you can search in the ieee80211 standard:
# http://standards.ieee.org/getieee802/download/802.11-2012.pdf
# exemple: for mac80211.ACKFailureCount search for dot11ACKFailureCount (page 2145)
# mac80211 phy discovery (like 'phy0')
# exemple: {"data":[{"{#PHY}":"phy0"}]}
#
UserParameter=mac80211.phydiscovery,for phy in $(ls /sys/kernel/debug/ieee80211/); do list="$list,"'{"{#PHY}":"'$phy'"}'; done; echo '{"data":['${list#,}']}'
#phy statistics (you need {#PHY} as parameter)
#
UserParameter=mac80211.ACKFailureCount[*],cat /sys/kernel/debug/ieee80211/$1/statistics/dot11ACKFailureCount
UserParameter=mac80211.FCSErrorCount[*],cat /sys/kernel/debug/ieee80211/$1/statistics/dot11FCSErrorCount
UserParameter=mac80211.RTSFailureCount[*],cat /sys/kernel/debug/ieee80211/$1/statistics/dot11RTSFailureCount
UserParameter=mac80211.RTSSuccessCount[*],cat /sys/kernel/debug/ieee80211/$1/statistics/dot11RTSSuccessCount
UserParameter=mac80211.FailedCount[*],cat /sys/kernel/debug/ieee80211/$1/statistics/failed_count
UserParameter=mac80211.FrameDuplicateCount[*],cat /sys/kernel/debug/ieee80211/$1/statistics/frame_duplicate_count
UserParameter=mac80211.MulticastReceivedFrameCount[*],cat /sys/kernel/debug/ieee80211/$1/statistics/multicast_received_frame_count
UserParameter=mac80211.MulticastTransmittedFrameCount[*],cat /sys/kernel/debug/ieee80211/$1/statistics/multicast_transmitted_frame_count
UserParameter=mac80211.MultipleRetryCount[*],cat /sys/kernel/debug/ieee80211/$1/statistics/multiple_retry_count
UserParameter=mac80211.ReceivedFragmentCount[*],cat /sys/kernel/debug/ieee80211/$1/statistics/received_fragment_count
UserParameter=mac80211.RetryCount[*],cat /sys/kernel/debug/ieee80211/$1/statistics/retry_count
UserParameter=mac80211.TransmittedFragmentCount[*],cat /sys/kernel/debug/ieee80211/$1/statistics/transmitted_fragment_count
UserParameter=mac80211.TransmittedFrameCount[*],cat /sys/kernel/debug/ieee80211/$1/statistics/transmitted_frame_count
@systemflare
Copy link

the autodiscovery rule is not working:

zabbix_get -s 192.168.0.104 -k wifi.ifdiscovery

lua: (command line):1: bad argument #1 to 'type' (string expected, got nil)
stack traceback:
[C]: in function 'foreach'
(command line):1: in main chunk
[C]: ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment