From 1205ab461b2f6ec8fcd1eefa8f3d8085a15ee089 Mon Sep 17 00:00:00 2001 From: Florian Eckert Date: Mon, 16 Sep 2019 14:55:17 +0200 Subject: [PATCH] collectd: add curl uci config Signed-off-by: Florian Eckert --- utils/collectd/files/collectd.init | 33 +++++++++++++++++++ utils/collectd/files/collectd.uci | 7 ++++ .../files/usr/share/collectd/plugin/curl.json | 2 ++ 3 files changed, 42 insertions(+) create mode 100644 utils/collectd/files/usr/share/collectd/plugin/curl.json diff --git a/utils/collectd/files/collectd.init b/utils/collectd/files/collectd.init index a9182380f..a29920015 100644 --- a/utils/collectd/files/collectd.init +++ b/utils/collectd/files/collectd.init @@ -44,6 +44,35 @@ 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" +} + CONFIG_LIST="" add_list_option() { local value="$1" @@ -139,6 +168,10 @@ process_plugins() { CONFIG_STRING="" process_exec ;; + curl) + CONFIG_STRING="" + process_curl + ;; *) 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 fa472c985..22cade912 100644 --- a/utils/collectd/files/collectd.uci +++ b/utils/collectd/files/collectd.uci @@ -30,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' 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 @@ +{ +}