diff --git a/utils/collectd/Makefile b/utils/collectd/Makefile index 9d946167c..4216acfca 100644 --- a/utils/collectd/Makefile +++ b/utils/collectd/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=collectd PKG_VERSION:=5.9.0 -PKG_RELEASE:=5 +PKG_RELEASE:=6 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE_URL:=https://collectd.org/files/ \ diff --git a/utils/collectd/files/collectd.init b/utils/collectd/files/collectd.init index a9182380f..89715d4c4 100644 --- a/utils/collectd/files/collectd.init +++ b/utils/collectd/files/collectd.init @@ -44,6 +44,129 @@ process_exec_sections() { fi } +process_curl() { + printf "\n" >> "$COLLECTD_CONF" + config_foreach process_curl_page curl_page + printf "\n\n" >> "$COLLECTD_CONF" +} + +process_curl_page() { + local cfg="$1" + + local name url + + config_get name "$cfg" name + [ -z "$name" ] && { + $LOG notice "No name option in config $cfg defined" + return 0 + } + + config_get url "$cfg" url + [ -z "$url" ] && { + $LOG notice "No URL option in config $cfg defined" + return 0 + } + + printf "\\t\n" "${name}" >> "$COLLECTD_CONF" + printf "\\t\\tURL \"%s\"\n" "${url}" >> "$COLLECTD_CONF" + printf "\\t\\tMeasureResponseTime true\n" >> "$COLLECTD_CONF" + printf "\\t\n" >> "$COLLECTD_CONF" +} + +process_network() { + local cfg="$1" + + local TimeToLive Forward CacheFlush + + printf "\n" >> "$COLLECTD_CONF" + config_foreach process_network_sections network_listen "listen" + config_foreach process_network_sections network_server "server" + + config_get TimeToLive "$cfg" TimeToLive + [ -z "$TimeToLive" ] || { + printf "\\tTimeToLive %s\n" "${TimeToLive}" >> "$COLLECTD_CONF" + } + + config_get CacheFlush "$cfg" CacheFlush + [ -z "$CacheFlush" ] || { + printf "\\tCacheFlush %s\n" "${CacheFlush}" >> "$COLLECTD_CONF" + } + + config_get_bool Forward "$cfg" Forward + if [ "$value" = "0" ]; then + printf "\\tForward false\n" >> "$COLLECTD_CONF" + else + printf "\\tForward true\n" >> "$COLLECTD_CONF" + fi + + printf "\n\n" >> "$COLLECTD_CONF" +} + +process_network_sections() { + local cfg="$1" + local section="$2" + + local host port output + + config_get host "$cfg" host + [ -z "$host" ] && { + $LOG notice "No host option in config $cfg defined" + return 0 + } + + if [ "$section" = "server" ]; then + output="Server \"$host\"" + else + output="Listen \"$host\"" + fi + + config_get port "$cfg" port + if [ -z "$port" ]; then + printf "\\t%s\n" "${output}" >> "$COLLECTD_CONF" + else + printf "\\t%s \"%s\"\n" "${output}" "${port}" >> "$COLLECTD_CONF" + fi +} + +process_iptables() { + local cfg="$1" + + printf "\n" >> "$COLLECTD_CONF" + config_foreach process_iptables_sections iptables_match + printf "\n\n" >> "$COLLECTD_CONF" +} + +process_iptables_sections() { + local cfg="$1" + + local table chain + + config_get table "$cfg" table + [ -z "$table" ] && { + $LOG notice "No table option in config $cfg defined" + return 0 + } + + config_get chain "$cfg" chain + [ -z "$chain" ] && { + $LOG notice "No chain option in config $cfg defined" + return 0 + } + + config_get index "$cfg" index + [ -z "$index" ] && { + $LOG notice "No index option in config $cfg defined" + return 0 + } + + config_get name "$cfg" name + if [ -z "$name" ]; then + printf "\\tChain %s %s %s\n" "${table}" "${chain}" "${index}" >> "$COLLECTD_CONF" + else + printf "\\tChain %s %s %s \"%s\"\n" "${table}" "${chain}" "${index}" "${name}">> "$COLLECTD_CONF" + fi +} + CONFIG_LIST="" add_list_option() { local value="$1" @@ -139,6 +262,18 @@ process_plugins() { CONFIG_STRING="" process_exec ;; + curl) + CONFIG_STRING="" + process_curl + ;; + network) + CONFIG_STRING="" + process_network "$cfg" + ;; + iptables) + CONFIG_STRING="" + process_iptables + ;; *) CONFIG_STRING="" process_generic "$cfg" "\\t" "/usr/share/collectd/plugin/$cfg.json" diff --git a/utils/collectd/files/collectd.uci b/utils/collectd/files/collectd.uci index 73e2c2ab5..a04cbc31a 100644 --- a/utils/collectd/files/collectd.uci +++ b/utils/collectd/files/collectd.uci @@ -8,6 +8,11 @@ config globals 'globals' # option Interval '30' # option ReadThreads '2' +#config plugin 'apcups' +# option enable '0' +# option Host 'localhost' +# option Port '3551' + #config plugin 'conntrack' # option enable '0' @@ -25,6 +30,13 @@ config globals 'globals' # option StoreRates '0' # option DataDir '/tmp' +#config plugin 'curl' +# option enable '0' + +#config curl_page +# option name 'test' +# option url 'http://finance.google.com/finance?q=NYSE%3AAMD%22' + #config plugin 'df' # option enable '0' # list Device '/dev/mtdblock/4' @@ -69,6 +81,15 @@ config globals 'globals' # list Interface 'br-lan' # option IgnoreSelected '0' +#config plugin 'iptables' +# option enable '1' + +#config iptables_match +# option table 'nat' +# option chain 'zone_wan_postrouting' +# option index '1' +# option name 'WLAN-Clients traffic' + #config plugin 'irq' # option enable '0' # list Irq '2' @@ -96,6 +117,20 @@ config globals 'globals' # list VerboseInterface 'br-lan' # list QDisc 'br-lan' +#config plugin 'network' +# option enable '1' +# option TimeToLive '128' +# option Forward '1' +# option CacheFlush '86400' + +#config network_listen +# option host '0.0.0.0' +# option port '25826' + +#config network_server +# option host '1.1.1.1' +# option port '25826' + #config plugin 'nut' # option enable '0' # option UPS 'myupsname' diff --git a/utils/collectd/files/usr/share/collectd/plugin/apcups.json b/utils/collectd/files/usr/share/collectd/plugin/apcups.json new file mode 100644 index 000000000..15a31df9f --- /dev/null +++ b/utils/collectd/files/usr/share/collectd/plugin/apcups.json @@ -0,0 +1,6 @@ +{ + "string": [ + "Host", + "Port" + ] +} diff --git a/utils/collectd/files/usr/share/collectd/plugin/curl.json b/utils/collectd/files/usr/share/collectd/plugin/curl.json new file mode 100644 index 000000000..2c63c0851 --- /dev/null +++ b/utils/collectd/files/usr/share/collectd/plugin/curl.json @@ -0,0 +1,2 @@ +{ +} diff --git a/utils/collectd/files/usr/share/collectd/plugin/iptables.json b/utils/collectd/files/usr/share/collectd/plugin/iptables.json new file mode 100644 index 000000000..2c63c0851 --- /dev/null +++ b/utils/collectd/files/usr/share/collectd/plugin/iptables.json @@ -0,0 +1,2 @@ +{ +} diff --git a/utils/collectd/files/usr/share/collectd/plugin/network.json b/utils/collectd/files/usr/share/collectd/plugin/network.json new file mode 100644 index 000000000..2c63c0851 --- /dev/null +++ b/utils/collectd/files/usr/share/collectd/plugin/network.json @@ -0,0 +1,2 @@ +{ +}