> This patch add 3 extra packages for zabbix-agentd:
> zabbix-extra-network: a detection rule with the ifname (eth0.1) and the 
> network name (wan).
> zabbix-extra-wifi: an universal detection rule for wifi (using libuci-lua) 
> and many userparameters (using libiwinfo-lua)
> zabbix-extra-mac80211: a phy (phy0) detection rule and userparameters for 
> mac80211 devices
>
> zabbix-extra-network and zabbix-extra-wifi will work as non root user as soon 
> as uci is updated
> (patch commited in uci git, 
> http://nbd.name/gitweb.cgi?p=uci.git;a=commit;h=07d6fd66f6a20e35490bc8b55d26fdb389016120)
> zabbix-extra-mac80211 come with a startup script (just one chmod) to set the 
> rights so that you can still run zabbix as non root user.
> (patching mac80211 is a bit too much, and the chmod only give read rights on 
> the statistics dir)
>
> Ready to use templates are available here: 
> http://wiki.openwrt.org/doc/howto/zabbix
>
> Please delete files/zabbix_agentd.conf, it's an empty file.
>
> Signed-off-by: Etienne CHAMPETIER <etienne.champet...@free.fr>

This is for the packages feed and needs to be applied with -p0.

I tested every parameter on a TP-Link tl-wr1043nd with multiple ssids.
Thanks for your work!
The chmod on the statistics dir is a nice compromise.

Acked-by: Stefan Hellermann <ste...@the2masters.de>

>
> Index: admin/zabbix/files/wifi
> ===================================================================
> --- admin/zabbix/files/wifi     (révision 0)
> +++ admin/zabbix/files/wifi     (révision 0)
> @@ -0,0 +1,29 @@
> +#see http://wiki.openwrt.org/doc/howto/zabbix for ready to use templates
> +
> +# 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 ''))"
> +
> +#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'))"
> Index: admin/zabbix/files/zabbix_extra_mac80211.init
> ===================================================================
> --- admin/zabbix/files/zabbix_extra_mac80211.init       (révision 0)
> +++ admin/zabbix/files/zabbix_extra_mac80211.init       (révision 0)
> @@ -0,0 +1,9 @@
> +#!/bin/sh /etc/rc.common
> +# Copyright (C) 2008-2011 OpenWrt.org
> +
> +START=59
> +
> +start() {
> +       chmod -R a+r /sys/kernel/debug/ieee80211/*/statistics/
> +}
> +
> Index: admin/zabbix/files/network
> ===================================================================
> --- admin/zabbix/files/network  (révision 0)
> +++ admin/zabbix/files/network  (révision 0)
> @@ -0,0 +1,9 @@
> +#see http://wiki.openwrt.org/doc/howto/zabbix for ready to use templates
> +
> +# network interface discovery
> +# exemple: {"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.."]}")'
> +
> +
> +
> Index: admin/zabbix/files/mac80211
> ===================================================================
> --- admin/zabbix/files/mac80211 (révision 0)
> +++ admin/zabbix/files/mac80211 (révision 0)
> @@ -0,0 +1,27 @@
> +#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
> +
> Index: admin/zabbix/patches/010-change-agentd-config.patch
> ===================================================================
> --- admin/zabbix/patches/010-change-agentd-config.patch (révision 36419)
> +++ admin/zabbix/patches/010-change-agentd-config.patch (copie de travail)
> @@ -1,5 +1,3 @@
> -diff --git a/conf/zabbix_agentd.conf b/conf/zabbix_agentd.conf
> -index ed04751..e714c4d 100644
>  --- a/conf/zabbix_agentd.conf
>  +++ b/conf/zabbix_agentd.conf
>  @@ -3,12 +3,8 @@
> @@ -52,3 +50,12 @@
>   ### Option: HostnameItem
>   #     Item used for generating Hostname if it is undefined.
>   #     Ignored if Hostname is defined.
> +@@ -213,7 +204,7 @@ Hostname=Zabbix server
> + # Include=
> +
> + # Include=/usr/local/etc/zabbix_agentd.userparams.conf
> +-# Include=/usr/local/etc/zabbix_agentd.conf.d/
> ++Include=/etc/zabbix_agentd.conf.d/
> +
> + ####### USER-DEFINED MONITORED PARAMETERS #######
> +
> Index: admin/zabbix/Makefile
> ===================================================================
> --- admin/zabbix/Makefile       (révision 36419)
> +++ admin/zabbix/Makefile       (copie de travail)
> @@ -41,6 +41,24 @@
>    TITLE+= agentd
>  endef
>
> +define Package/zabbix-extra-mac80211
> +  $(call Package/zabbix/Default)
> +  TITLE+= discovery/userparameters for mac80211
> +  DEPENDS += +zabbix-agentd @PACKAGE_MAC80211_DEBUGFS @KERNEL_DEBUG_FS
> +endef
> +
> +define Package/zabbix-extra-network
> +  $(call Package/zabbix/Default)
> +  TITLE+= discovery/userparameters for network
> +  DEPENDS += +zabbix-agentd +libuci-lua +lua
> +endef
> +
> +define Package/zabbix-extra-wifi
> +  $(call Package/zabbix/Default)
> +  TITLE+= discovery/userparameters for wifi
> +  DEPENDS += +zabbix-agentd +libiwinfo-lua +libuci-lua +lua
> +endef
> +
>  define Package/zabbix-sender
>    $(call Package/zabbix/Default)
>    TITLE+= sender
> @@ -63,6 +81,25 @@
>    DEPENDS += +libsqlite3
>  endef
>
> +define Package/zabbix-extra-mac80211/description
> +An extra package for zabbix-agentd that adds a discovery rule for mac80211 
> wifi phy and many userparameters.
> +It contains an init script to allow zabbix-agentd to still run as zabbix 
> user and not as root.
> +See http://wiki.openwrt.org/doc/howto/zabbix for ready to use zabbix 
> templates.
> +endef
> +
> +define Package/zabbix-extra-network/description
> +An extra package for zabbix-agentd that adds a discovery rule for openwrt 
> network interfaces.
> +The idea here is to discover only interfaces listed in /etc/config/network 
> (discover br-lan and not eth0.1 and wlan0)
> +See http://wiki.openwrt.org/doc/howto/zabbix for ready to use zabbix 
> templates.
> +endef
> +
> +define Package/zabbix-extra-wifi/description
> +An extra package for zabbix-agentd that adds a discovery rule for wifi 
> interfaces and many userparameters.
> +As it uses libiwinfo, it works with all wifi devices supported by openwrt.
> +See http://wiki.openwrt.org/doc/howto/zabbix for ready to use zabbix 
> templates.
> +endef
> +
> +
>  define Package/zabbix-agentd/config
>    select BUSYBOX_CONFIG_HOSTNAME if !PACKAGE_net-tools-hostname
>    select BUSYBOX_CONFIG_UNAME if !PACKAGE_coreutils-uname
> @@ -113,6 +150,15 @@
>                 $(1)/etc/init.d/zabbix_$(2)
>  endef
>
> +define Package/zabbix/install/zabbix.conf.d
> +       $(INSTALL_DIR) \
> +               $(1)/etc/zabbix_$(2).conf.d
> +
> +       $(INSTALL_BIN) \
> +               ./files/$(3) \
> +               $(1)/etc/zabbix_$(2).conf.d/$(3)
> +endef
> +
>  define Package/zabbix-agent/conffiles
>  /etc/zabbix_agent.conf
>  endef
> @@ -137,6 +183,19 @@
>         $(call Package/zabbix/install/init.d,$(1),agentd)
>  endef
>
> +define Package/zabbix-extra-mac80211/install
> +       $(call Package/zabbix/install/init.d,$(1),extra_mac80211)
> +       $(call Package/zabbix/install/zabbix.conf.d,$(1),agentd,mac80211)
> +endef
> +
> +define Package/zabbix-extra-network/install
> +       $(call Package/zabbix/install/zabbix.conf.d,$(1),agentd,network)
> +endef
> +
> +define Package/zabbix-extra-wifi/install
> +       $(call Package/zabbix/install/zabbix.conf.d,$(1),agentd,wifi)
> +endef
> +
>  define Package/zabbix-sender/install
>         $(call Package/zabbix/install/bin,$(1),sender)
>  endef
> @@ -157,6 +216,9 @@
>
>  $(eval $(call BuildPackage,zabbix-agent))
>  $(eval $(call BuildPackage,zabbix-agentd))
> +$(eval $(call BuildPackage,zabbix-extra-mac80211))
> +$(eval $(call BuildPackage,zabbix-extra-network))
> +$(eval $(call BuildPackage,zabbix-extra-wifi))
>  $(eval $(call BuildPackage,zabbix-sender))
>  $(eval $(call BuildPackage,zabbix-server))
>  $(eval $(call BuildPackage,zabbix-proxy))
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to