> Hi > > 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 > > With each packages come a startup script (just one chmod now) to set rights > so that you can still run zabbix as non root user. > Ready to use templates are available here: > http://wiki.openwrt.org/doc/howto/zabbix > I've renamed all the wifi stuff, please use updated templates. > > Please delete files/zabbix_agentd.conf, it's an empty file. > > Signed-off-by: Etienne CHAMPETIER <etienne.champet...@free.fr>
Acked-by: Stefan Hellermann <ste...@the2masters.de> > > Index: files/mac80211 > =================================================================== > --- files/mac80211 (révision 0) > +++ files/mac80211 (révision 0) > @@ -0,0 +1,28 @@ > +#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) > + > +# 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: files/zabbix_extra_network.init > =================================================================== > --- files/zabbix_extra_network.init (révision 0) > +++ files/zabbix_extra_network.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 /var/state/ > +} > + > Index: files/wifi > =================================================================== > --- files/wifi (révision 0) > +++ files/wifi (révision 0) > @@ -0,0 +1,30 @@ > +#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 > + > +# 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: files/zabbix_extra_mac80211.init > =================================================================== > --- files/zabbix_extra_mac80211.init (révision 0) > +++ 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: files/zabbix_extra_wifi.init > =================================================================== > --- files/zabbix_extra_wifi.init (révision 0) > +++ files/zabbix_extra_wifi.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 /var/state/ > +} > + > Index: files/network > =================================================================== > --- files/network (révision 0) > +++ files/network (révision 0) > @@ -0,0 +1,10 @@ > +#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 > + > +# 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: 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 ####### > + > 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 > @@ -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 > @@ -113,6 +131,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 +164,21 @@ > $(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/init.d,$(1),extra_network) > + $(call Package/zabbix/install/zabbix.conf.d,$(1),agentd,network) > +endef > + > +define Package/zabbix-extra-wifi/install > + $(call Package/zabbix/install/init.d,$(1),extra_wifi) > + $(call Package/zabbix/install/zabbix.conf.d,$(1),agentd,wifi) > +endef > + > define Package/zabbix-sender/install > $(call Package/zabbix/install/bin,$(1),sender) > endef > @@ -155,8 +197,26 @@ > $(call Package/zabbix/install/etc,$(1),proxy) > endef > > +define Package/zabbix-extra-mac80211/postinst > +[ -n "$${IPKG_INSTROOT}" ] || /etc/init.d/zabbix_extra_mac80211 enable > +exit 0 > +endef > + > +define Package/zabbix-extra-network/postinst > +[ -n "$${IPKG_INSTROOT}" ] || /etc/init.d/zabbix_extra_network enable > +exit 0 > +endef > + > +define Package/zabbix-extra-wifi/postinst > +[ -n "$${IPKG_INSTROOT}" ] || /etc/init.d/zabbix_extra_wifi enable > +exit 0 > +endef > + > $(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