|
@ -44,6 +44,129 @@ process_exec_sections() { |
|
|
fi |
|
|
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="" |
|
|
CONFIG_LIST="" |
|
|
add_list_option() { |
|
|
add_list_option() { |
|
|
local value="$1" |
|
|
local value="$1" |
|
@ -139,6 +262,18 @@ process_plugins() { |
|
|
CONFIG_STRING="" |
|
|
CONFIG_STRING="" |
|
|
process_exec |
|
|
process_exec |
|
|
;; |
|
|
;; |
|
|
|
|
|
curl) |
|
|
|
|
|
CONFIG_STRING="" |
|
|
|
|
|
process_curl |
|
|
|
|
|
;; |
|
|
|
|
|
network) |
|
|
|
|
|
CONFIG_STRING="" |
|
|
|
|
|
process_network "$cfg" |
|
|
|
|
|
;; |
|
|
|
|
|
iptables) |
|
|
|
|
|
CONFIG_STRING="" |
|
|
|
|
|
process_iptables |
|
|
|
|
|
;; |
|
|
*) |
|
|
*) |
|
|
CONFIG_STRING="" |
|
|
CONFIG_STRING="" |
|
|
process_generic "$cfg" "\\t" "/usr/share/collectd/plugin/$cfg.json" |
|
|
process_generic "$cfg" "\\t" "/usr/share/collectd/plugin/$cfg.json" |
|
|