Browse Source

collectd: add network uci config

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
lilik-openwrt-22.03
Florian Eckert 5 years ago
parent
commit
7d3cbda4af
3 changed files with 75 additions and 0 deletions
  1. +59
    -0
      utils/collectd/files/collectd.init
  2. +14
    -0
      utils/collectd/files/collectd.uci
  3. +2
    -0
      utils/collectd/files/usr/share/collectd/plugin/network.json

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

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


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

@ -108,6 +108,20 @@ config globals 'globals'
# list VerboseInterface 'br-lan' # list VerboseInterface 'br-lan'
# list QDisc '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' #config plugin 'nut'
# option enable '0' # option enable '0'
# option UPS 'myupsname' # option UPS 'myupsname'


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

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

Loading…
Cancel
Save