Browse Source

Merge pull request #10017 from TDT-AG/pr/20190917-collectd

collectd: add missing uci config sections
lilik-openwrt-22.03
Hannu Nyman 5 years ago
committed by GitHub
parent
commit
e69b4574a9
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 183 additions and 1 deletions
  1. +1
    -1
      utils/collectd/Makefile
  2. +135
    -0
      utils/collectd/files/collectd.init
  3. +35
    -0
      utils/collectd/files/collectd.uci
  4. +6
    -0
      utils/collectd/files/usr/share/collectd/plugin/apcups.json
  5. +2
    -0
      utils/collectd/files/usr/share/collectd/plugin/curl.json
  6. +2
    -0
      utils/collectd/files/usr/share/collectd/plugin/iptables.json
  7. +2
    -0
      utils/collectd/files/usr/share/collectd/plugin/network.json

+ 1
- 1
utils/collectd/Makefile View File

@ -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/ \


+ 135
- 0
utils/collectd/files/collectd.init View File

@ -44,6 +44,129 @@ process_exec_sections() {
fi
}
process_curl() {
printf "<Plugin curl>\n" >> "$COLLECTD_CONF"
config_foreach process_curl_page curl_page
printf "</Plugin>\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<Page \"%s\">\n" "${name}" >> "$COLLECTD_CONF"
printf "\\t\\tURL \"%s\"\n" "${url}" >> "$COLLECTD_CONF"
printf "\\t\\tMeasureResponseTime true\n" >> "$COLLECTD_CONF"
printf "\\t</Page>\n" >> "$COLLECTD_CONF"
}
process_network() {
local cfg="$1"
local TimeToLive Forward CacheFlush
printf "<Plugin network>\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 "</Plugin>\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 "<Plugin iptables>\n" >> "$COLLECTD_CONF"
config_foreach process_iptables_sections iptables_match
printf "</Plugin>\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"


+ 35
- 0
utils/collectd/files/collectd.uci View File

@ -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'


+ 6
- 0
utils/collectd/files/usr/share/collectd/plugin/apcups.json View File

@ -0,0 +1,6 @@
{
"string": [
"Host",
"Port"
]
}

+ 2
- 0
utils/collectd/files/usr/share/collectd/plugin/curl.json View File

@ -0,0 +1,2 @@
{
}

+ 2
- 0
utils/collectd/files/usr/share/collectd/plugin/iptables.json View File

@ -0,0 +1,2 @@
{
}

+ 2
- 0
utils/collectd/files/usr/share/collectd/plugin/network.json View File

@ -0,0 +1,2 @@
{
}

Loading…
Cancel
Save