collectd: add network uci config

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
(cherry-picked for 19.07)
Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
This commit is contained in:
Florian Eckert 2019-09-16 15:48:02 +02:00 committed by Hannu Nyman
parent df7d418c97
commit 6884430d49
3 changed files with 75 additions and 0 deletions

View file

@ -73,6 +73,61 @@ process_curl_page() {
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
}
CONFIG_LIST=""
add_list_option() {
local value="$1"
@ -172,6 +227,10 @@ process_plugins() {
CONFIG_STRING=""
process_curl
;;
network)
CONFIG_STRING=""
process_network "$cfg"
;;
*)
CONFIG_STRING=""
process_generic "$cfg" "\\t" "/usr/share/collectd/plugin/$cfg.json"

View file

@ -108,6 +108,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'

View file

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