Hi

This patch add 30 UserParameter to monitor your wifi via zabbix.
The iwinfo part is generic, it only need a detection rule (like 
mac80211.devdiscovery) to be written for your type of device
The mac80211 is only tested with ath9k but it should work with all mac80211 phy.
Please see http://wiki.openwrt.org/doc/howto/zabbix for a complete template 
example.
Signed-off-by: Etienne CHAMPETIER <etienne.champet...@free.fr>


Index: Makefile
===================================================================
--- Makefile	(révision 34787)
+++ Makefile	(copie de travail)
@@ -9,7 +9,7 @@
 
 PKG_NAME:=zabbix
 PKG_VERSION:=2.0.3
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=@SF/zabbix
@@ -113,6 +113,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
@@ -135,6 +144,8 @@
 	$(call Package/zabbix/install/sbin,$(1),agentd)
 	$(call Package/zabbix/install/etc,$(1),agentd)
 	$(call Package/zabbix/install/init.d,$(1),agentd)
+	$(call Package/zabbix/install/zabbix.conf.d,$(1),agentd,mac80211)
+	$(call Package/zabbix/install/zabbix.conf.d,$(1),agentd,iwinfo)
 endef
 
 define Package/zabbix-sender/install
Index: files/iwinfo
===================================================================
--- files/iwinfo	(révision 0)
+++ files/iwinfo	(révision 0)
@@ -0,0 +1,19 @@
+#tested with ath9k/zabbix 2.0.3-2.0.4/openwrt AA rc1
+#see http://wiki.openwrt.org/doc/howto/zabbix for ready to use templates
+
+#iwinfo info (you need #DEV as parameter)
+UserParameter=iwinfo.channel[*],lua -l iwinfo -e "print(iwinfo['$1'].channel('$2'))"
+UserParameter=iwinfo.frequency[*],lua -l iwinfo -e "print(iwinfo['$1'].frequency('$2'))"
+UserParameter=iwinfo.txpower[*],lua -l iwinfo -e "print(iwinfo['$1'].txpower('$2'))"
+UserParameter=iwinfo.bitrate[*],lua -l iwinfo -e "local b = iwinfo['$1'].bitrate('$2'); print(b or '0')"
+UserParameter=iwinfo.signal[*],lua -l iwinfo -e "local s = iwinfo['$1'].signal('$2'); print(s or '-255')"
+UserParameter=iwinfo.noise[*],lua -l iwinfo -e "print(iwinfo['$1'].noise('$2'))"
+UserParameter=iwinfo.quality[*],lua -l iwinfo -e "print(iwinfo['$1'].quality('$2'))"
+UserParameter=iwinfo.quality_max[*],lua -l iwinfo -e "print(iwinfo['$1'].quality_max('$2'))"
+UserParameter=iwinfo.mode[*],lua -l iwinfo -e "print(iwinfo['$1'].mode('$2'))"
+UserParameter=iwinfo.ssid[*],lua -l iwinfo -e "print(iwinfo['$1'].ssid('$2'))"
+UserParameter=iwinfo.bssid[*],lua -l iwinfo -e "print(iwinfo['$1'].bssid('$2'))"
+UserParameter=iwinfo.country[*],lua -l iwinfo -e "print(iwinfo['$1'].country('$2'))"
+UserParameter=iwinfo.nbusers[*],lua -l iwinfo -e "print(#iwinfo['$1'].assoclist('$2'))"
+UserParameter=iwinfo.encryption[*],lua -l iwinfo -e "local e = iwinfo['$1'].encryption('$2'); print(e and e.description or 'None')"
+UserParameter=iwinfo.hwmode[*],lua -l iwinfo -e "local x=iwinfo['$1'].hwmodelist('$2'); print((x.a and 'a' or '')..(x.b and 'b' or '')..(x.g and 'g' or '')..(x.n and 'n' or ''))"
Index: files/mac80211
===================================================================
--- files/mac80211	(révision 0)
+++ files/mac80211	(révision 0)
@@ -0,0 +1,31 @@
+#tested with ath9k/zabbix 2.0.3-2.0.4/openwrt AA rc1
+#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)
+
+#automatically discover mac80211 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)
+#by default /sys/kernel/debug/ieee80211/ files are readable by root only
+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
+
+
+#automatically discover mac80211 dev (wlan0 ...)
+UserParameter=mac80211.devdiscovery,for dev in $(find /sys/kernel/debug/ieee80211/ -type d -name netdev:*); do list="$list,"'{"{#DEV}":"'${dev#/*:}'", "{#PHY}":"'$(basename $(dirname $dev))'", "{#SSID}":"'$(lua -l iwinfo -e "print(iwinfo['nl80211'].ssid('${dev#/*:}'))")'", "{#BSSID}":"'$(lua -l iwinfo -e "print(iwinfo['nl80211'].bssid('${dev#/*:}'))")'", "{#CHANNEL}":"'$(lua -l iwinfo -e "print(iwinfo['nl80211'].channel('${dev#/*:}'))")'"}'; done; echo '{"data":['${list#,}']}'
+
+
Index: files/zabbix_agentd.init
===================================================================
--- files/zabbix_agentd.init	(révision 34787)
+++ files/zabbix_agentd.init	(copie de travail)
@@ -23,6 +23,10 @@
 		group_exists zabbix 53 || group_add zabbix 53
 		touch ${SERVICE_PID_FILE}
 		chown zabbix:zabbix ${SERVICE_PID_FILE}
+                [ -d /sys/kernel/debug/ieee80211 ] && {
+                        chown -R root:zabbix /sys/kernel/debug/ieee80211/
+                        chmod -R g+r /sys/kernel/debug/ieee80211/
+                }
 	}
 
 	service_start ${PROG} -c ${CONFIG}
Index: patches/010-change-agentd-config.patch
===================================================================
--- patches/010-change-agentd-config.patch	(révision 34787)
+++ 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 #######
+ 
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to