Want more features on Pastebin? Sign Up, it's FREE!
Guest

zabbix patch v4

By: a guest on Jan 8th, 2013  |  syntax: None  |  size: 12.75 KB  |  views: 112  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Index: patches/010-change-agentd-config.patch
  2. ===================================================================
  3. --- patches/010-change-agentd-config.patch      (révision 35053)
  4. +++ patches/010-change-agentd-config.patch      (copie de travail)
  5. @@ -1,5 +1,3 @@
  6. -diff --git a/conf/zabbix_agentd.conf b/conf/zabbix_agentd.conf
  7. -index ed04751..e714c4d 100644
  8.  --- a/conf/zabbix_agentd.conf
  9.  +++ b/conf/zabbix_agentd.conf
  10.  @@ -3,12 +3,8 @@
  11. @@ -52,3 +50,12 @@
  12.   ### Option: HostnameItem
  13.   #     Item used for generating Hostname if it is undefined.
  14.   #     Ignored if Hostname is defined.
  15. +@@ -213,7 +204,7 @@ Hostname=Zabbix server
  16. + # Include=
  17. +
  18. + # Include=/usr/local/etc/zabbix_agentd.userparams.conf
  19. +-# Include=/usr/local/etc/zabbix_agentd.conf.d/
  20. ++Include=/etc/zabbix_agentd.conf.d/
  21. +
  22. + ####### USER-DEFINED MONITORED PARAMETERS #######
  23. +
  24. Index: Makefile
  25. ===================================================================
  26. --- Makefile    (révision 35053)
  27. +++ Makefile    (copie de travail)
  28. @@ -9,7 +9,7 @@
  29.  
  30.  PKG_NAME:=zabbix
  31.  PKG_VERSION:=2.0.3
  32. -PKG_RELEASE:=1
  33. +PKG_RELEASE:=2
  34.  
  35.  PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
  36.  PKG_SOURCE_URL:=@SF/zabbix
  37. @@ -41,6 +41,24 @@
  38.    TITLE+= agentd
  39.  endef
  40.  
  41. +define Package/zabbix-extra-mac80211
  42. +  $(call Package/zabbix/Default)
  43. +  TITLE+= discovery/userparameters for mac80211
  44. +  DEPENDS += +zabbix-agentd @PACKAGE_MAC80211_DEBUGFS @KERNEL_DEBUG_FS
  45. +endef
  46. +
  47. +define Package/zabbix-extra-network
  48. +  $(call Package/zabbix/Default)
  49. +  TITLE+= discovery/userparameters for network
  50. +  DEPENDS += +zabbix-agentd +libuci-lua +lua
  51. +endef
  52. +
  53. +define Package/zabbix-extra-wifi
  54. +  $(call Package/zabbix/Default)
  55. +  TITLE+= discovery/userparameters for wifi
  56. +  DEPENDS += +zabbix-agentd +libiwinfo-lua +libuci-lua +lua
  57. +endef
  58. +
  59.  define Package/zabbix-sender
  60.    $(call Package/zabbix/Default)
  61.    TITLE+= sender
  62. @@ -63,6 +81,27 @@
  63.    DEPENDS += +libsqlite3
  64.  endef
  65.  
  66. +define Package/zabbix-extra-mac80211/description
  67. +An extra package for zabbix-agentd that adds a discovery rule for mac80211 wifi phy and many userparameters.
  68. +It contains an init script to allow zabbix-agentd to still run as zabbix user and not as root.
  69. +See http://wiki.openwrt.org/doc/howto/zabbix for ready to use zabbix templates.
  70. +endef
  71. +
  72. +define Package/zabbix-extra-network/description
  73. +An extra package for zabbix-agentd that adds a discovery rule for openwrt network interfaces.
  74. +The idea here is to discover only interfaces listed in /etc/config/network (discover br-lan and not eth0.1 and wlan0)
  75. +It contains an init script to allow zabbix-agentd to still run as zabbix user and not as root.
  76. +See http://wiki.openwrt.org/doc/howto/zabbix for ready to use zabbix templates.
  77. +endef
  78. +
  79. +define Package/zabbix-extra-wifi/description
  80. +An extra package for zabbix-agentd that adds a discovery rule for wifi interfaces and many userparameters.
  81. +As it uses libiwinfo, it works with all wifi devices supported by openwrt.
  82. +It contains an init script to allow zabbix-agentd to still run as zabbix user and not as root.
  83. +See http://wiki.openwrt.org/doc/howto/zabbix for ready to use zabbix templates.
  84. +endef
  85. +
  86. +
  87.  define Package/zabbix-agentd/config
  88.    select BUSYBOX_CONFIG_HOSTNAME if !PACKAGE_net-tools-hostname
  89.    select BUSYBOX_CONFIG_UNAME if !PACKAGE_coreutils-uname
  90. @@ -113,6 +152,15 @@
  91.                 $(1)/etc/init.d/zabbix_$(2)
  92.  endef
  93.  
  94. +define Package/zabbix/install/zabbix.conf.d
  95. +       $(INSTALL_DIR) \
  96. +               $(1)/etc/zabbix_$(2).conf.d
  97. +
  98. +       $(INSTALL_BIN) \
  99. +               ./files/$(3) \
  100. +               $(1)/etc/zabbix_$(2).conf.d/$(3)
  101. +endef
  102. +
  103.  define Package/zabbix-agent/conffiles
  104.  /etc/zabbix_agent.conf
  105.  endef
  106. @@ -137,6 +185,21 @@
  107.         $(call Package/zabbix/install/init.d,$(1),agentd)
  108.  endef
  109.  
  110. +define Package/zabbix-extra-mac80211/install
  111. +       $(call Package/zabbix/install/init.d,$(1),extra_mac80211)
  112. +       $(call Package/zabbix/install/zabbix.conf.d,$(1),agentd,mac80211)
  113. +endef
  114. +
  115. +define Package/zabbix-extra-network/install
  116. +       $(call Package/zabbix/install/init.d,$(1),extra_network)
  117. +       $(call Package/zabbix/install/zabbix.conf.d,$(1),agentd,network)
  118. +endef
  119. +
  120. +define Package/zabbix-extra-wifi/install
  121. +       $(call Package/zabbix/install/init.d,$(1),extra_wifi)
  122. +       $(call Package/zabbix/install/zabbix.conf.d,$(1),agentd,wifi)
  123. +endef
  124. +
  125.  define Package/zabbix-sender/install
  126.         $(call Package/zabbix/install/bin,$(1),sender)
  127.  endef
  128. @@ -155,8 +218,26 @@
  129.         $(call Package/zabbix/install/etc,$(1),proxy)
  130.  endef
  131.  
  132. +define Package/zabbix-extra-mac80211/postinst
  133. +[ -n "$${IPKG_INSTROOT}" ] || /etc/init.d/zabbix_extra_mac80211 enable
  134. +exit 0
  135. +endef
  136. +
  137. +define Package/zabbix-extra-network/postinst
  138. +[ -n "$${IPKG_INSTROOT}" ] || /etc/init.d/zabbix_extra_network enable
  139. +exit 0
  140. +endef
  141. +
  142. +define Package/zabbix-extra-wifi/postinst
  143. +[ -n "$${IPKG_INSTROOT}" ] || /etc/init.d/zabbix_extra_wifi enable
  144. +exit 0
  145. +endef
  146. +
  147.  $(eval $(call BuildPackage,zabbix-agent))
  148.  $(eval $(call BuildPackage,zabbix-agentd))
  149. +$(eval $(call BuildPackage,zabbix-extra-mac80211))
  150. +$(eval $(call BuildPackage,zabbix-extra-network))
  151. +$(eval $(call BuildPackage,zabbix-extra-wifi))
  152.  $(eval $(call BuildPackage,zabbix-sender))
  153.  $(eval $(call BuildPackage,zabbix-server))
  154.  $(eval $(call BuildPackage,zabbix-proxy))
  155. Index: files/mac80211
  156. ===================================================================
  157. --- files/mac80211      (révision 0)
  158. +++ files/mac80211      (révision 0)
  159. @@ -0,0 +1,28 @@
  160. +#tested with ath9k/zabbix 2.0.3-2.0.4/openwrt AA rc1
  161. +#see http://wiki.openwrt.org/doc/howto/zabbix for ready to use templates
  162. +
  163. +# If you want to know the exact meaning of an UserParameter, you can search in the ieee80211 standard:
  164. +# http://standards.ieee.org/getieee802/download/802.11-2012.pdf
  165. +# exemple: for mac80211.ACKFailureCount search for dot11ACKFailureCount (page 2145)
  166. +
  167. +# mac80211 phy discovery (like 'phy0')
  168. +# exemple: {"data":[{"{#PHY}":"phy0"}]}
  169. +#
  170. +UserParameter=mac80211.phydiscovery,for phy in $(ls /sys/kernel/debug/ieee80211/); do list="$list,"'{"{#PHY}":"'$phy'"}'; done; echo '{"data":['${list#,}']}'
  171. +
  172. +#phy statistics (you need {#PHY} as parameter)
  173. +#
  174. +UserParameter=mac80211.ACKFailureCount[*],cat /sys/kernel/debug/ieee80211/$1/statistics/dot11ACKFailureCount
  175. +UserParameter=mac80211.FCSErrorCount[*],cat /sys/kernel/debug/ieee80211/$1/statistics/dot11FCSErrorCount
  176. +UserParameter=mac80211.RTSFailureCount[*],cat /sys/kernel/debug/ieee80211/$1/statistics/dot11RTSFailureCount
  177. +UserParameter=mac80211.RTSSuccessCount[*],cat /sys/kernel/debug/ieee80211/$1/statistics/dot11RTSSuccessCount
  178. +UserParameter=mac80211.FailedCount[*],cat /sys/kernel/debug/ieee80211/$1/statistics/failed_count
  179. +UserParameter=mac80211.FrameDuplicateCount[*],cat /sys/kernel/debug/ieee80211/$1/statistics/frame_duplicate_count
  180. +UserParameter=mac80211.MulticastReceivedFrameCount[*],cat /sys/kernel/debug/ieee80211/$1/statistics/multicast_received_frame_count
  181. +UserParameter=mac80211.MulticastTransmittedFrameCount[*],cat /sys/kernel/debug/ieee80211/$1/statistics/multicast_transmitted_frame_count
  182. +UserParameter=mac80211.MultipleRetryCount[*],cat /sys/kernel/debug/ieee80211/$1/statistics/multiple_retry_count
  183. +UserParameter=mac80211.ReceivedFragmentCount[*],cat /sys/kernel/debug/ieee80211/$1/statistics/received_fragment_count
  184. +UserParameter=mac80211.RetryCount[*],cat /sys/kernel/debug/ieee80211/$1/statistics/retry_count
  185. +UserParameter=mac80211.TransmittedFragmentCount[*],cat /sys/kernel/debug/ieee80211/$1/statistics/transmitted_fragment_count
  186. +UserParameter=mac80211.TransmittedFrameCount[*],cat /sys/kernel/debug/ieee80211/$1/statistics/transmitted_frame_count
  187. +
  188. Index: files/zabbix_extra_network.init
  189. ===================================================================
  190. --- files/zabbix_extra_network.init     (révision 0)
  191. +++ files/zabbix_extra_network.init     (révision 0)
  192. @@ -0,0 +1,9 @@
  193. +#!/bin/sh /etc/rc.common
  194. +# Copyright (C) 2008-2011 OpenWrt.org
  195. +
  196. +START=59
  197. +
  198. +start() {
  199. +       chmod a+r /var/state/network
  200. +}
  201. +
  202. Index: files/wifi
  203. ===================================================================
  204. --- files/wifi  (révision 0)
  205. +++ files/wifi  (révision 0)
  206. @@ -0,0 +1,30 @@
  207. +#tested with ath9k/zabbix 2.0.3-2.0.4/openwrt AA rc1
  208. +#see http://wiki.openwrt.org/doc/howto/zabbix for ready to use templates
  209. +
  210. +# wifi interface discovery
  211. +# 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"}]}
  212. +#
  213. +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.."]}")'
  214. +
  215. +
  216. +#iwinfo info (you need {#IF} as parameter, like 'wlan0')
  217. +UserParameter=wifi.iwinfo.channel[*],lua -l iwinfo -e "print(iwinfo[iwinfo.type('$1')].channel('$1'))"
  218. +UserParameter=wifi.iwinfo.frequency[*],lua -l iwinfo -e "print(iwinfo[iwinfo.type('$1')].frequency('$1'))"
  219. +UserParameter=wifi.iwinfo.txpower[*],lua -l iwinfo -e "print(iwinfo[iwinfo.type('$1')].txpower('$1'))"
  220. +UserParameter=wifi.iwinfo.bitrate[*],lua -l iwinfo -e "b = iwinfo[iwinfo.type('$1')].bitrate('$1'); print(b or '0')"
  221. +UserParameter=wifi.iwinfo.signal[*],lua -l iwinfo -e "s = iwinfo[iwinfo.type('$1')].signal('$1'); print(s or '-255')"
  222. +UserParameter=wifi.iwinfo.noise[*],lua -l iwinfo -e "print(iwinfo[iwinfo.type('$1')].noise('$1'))"
  223. +UserParameter=wifi.iwinfo.quality[*],lua -l iwinfo -e "print(iwinfo[iwinfo.type('$1')].quality('$1'))"
  224. +UserParameter=wifi.iwinfo.quality_max[*],lua -l iwinfo -e "print(iwinfo[iwinfo.type('$1')].quality_max('$1'))"
  225. +UserParameter=wifi.iwinfo.mode[*],lua -l iwinfo -e "print(iwinfo[iwinfo.type('$1')].mode('$1'))"
  226. +UserParameter=wifi.iwinfo.ssid[*],lua -l iwinfo -e "print(iwinfo[iwinfo.type('$1')].ssid('$1'))"
  227. +UserParameter=wifi.iwinfo.bssid[*],lua -l iwinfo -e "print(iwinfo[iwinfo.type('$1')].bssid('$1'))"
  228. +UserParameter=wifi.iwinfo.country[*],lua -l iwinfo -e "print(iwinfo[iwinfo.type('$1')].country('$1'))"
  229. +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)"
  230. +UserParameter=wifi.iwinfo.encryption[*],lua -l iwinfo -e "e = iwinfo[iwinfo.type('$1')].encryption('$1'); print(e and e.description or 'None')"
  231. +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 ''))"
  232. +
  233. +#uci info (you need {#DEV} as parameter, like 'radio0')
  234. +UserParameter=wifi.uci.hwmode[*],lua -l uci -e "x = uci.cursor(nil, '/var/state'); print(x:get('wireless','$1','hwmode'))"
  235. +UserParameter=wifi.uci.channel[*],lua -l uci -e "x = uci.cursor(nil, '/var/state'); print(x:get('wireless','$1','channel'))"
  236. +UserParameter=wifi.uci.txpower[*],lua -l uci -e "x = uci.cursor(nil, '/var/state'); print(x:get('wireless','$1','txpower'))"
  237. Index: files/zabbix_extra_mac80211.init
  238. ===================================================================
  239. --- files/zabbix_extra_mac80211.init    (révision 0)
  240. +++ files/zabbix_extra_mac80211.init    (révision 0)
  241. @@ -0,0 +1,9 @@
  242. +#!/bin/sh /etc/rc.common
  243. +# Copyright (C) 2008-2011 OpenWrt.org
  244. +
  245. +START=59
  246. +
  247. +start() {
  248. +       chmod -R a+r /sys/kernel/debug/ieee80211/*/statistics/
  249. +}
  250. +
  251. Index: files/zabbix_extra_wifi.init
  252. ===================================================================
  253. --- files/zabbix_extra_wifi.init        (révision 0)
  254. +++ files/zabbix_extra_wifi.init        (révision 0)
  255. @@ -0,0 +1,9 @@
  256. +#!/bin/sh /etc/rc.common
  257. +# Copyright (C) 2008-2011 OpenWrt.org
  258. +
  259. +START=59
  260. +
  261. +start() {
  262. +       chmod a+r /var/state/wireless
  263. +}
  264. +
  265. Index: files/network
  266. ===================================================================
  267. --- files/network       (révision 0)
  268. +++ files/network       (révision 0)
  269. @@ -0,0 +1,10 @@
  270. +#tested with ath9k/zabbix 2.0.3-2.0.4/openwrt AA rc1
  271. +#see http://wiki.openwrt.org/doc/howto/zabbix for ready to use templates
  272. +
  273. +# network interface discovery
  274. +# exemple: {"data":[{"{#IF}":"lo", "{#NET}":"loopback"},{"{#IF}":"br-lan", "{#NET}":"lan"},{"{#IF}":"eth0.1", "{#NET}":"wan"}]}
  275. +#
  276. +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.."]}")'
  277. +
  278. +
  279. +
clone this paste RAW Paste Data