@cryptotaxi247 / netdata-1 / commits / 17053582f

support custom curl options in charts.d plugins

Costa Tsaousis (ktsaou) committed May 23, 2016 at 20:23 UTC 17053582ff88c91b5692e7a54ec85ee6973b86d9
4 files changed +12 -7
charts.d/apache.chart.sh
+2 -1
@@ -2,6 +2,7 @@
2
3 # the URL to download apache status info
4 apache_url="http://127.0.0.1:80/server-status?auto"
5 +apache_curl_opts=
6
7 # _update_every is a special variable - it holds the number of seconds
8 # between the calls of the _update() function
@@ -94,7 +95,7 @@ apache_detect() {
95
96 apache_get() {
97 local oIFS="${IFS}" ret
97 - IFS=$':\n' apache_response=($(curl -Ss "${apache_url}"))
98 + IFS=$':\n' apache_response=($(curl -Ss ${apache_curl_opts} "${apache_url}"))
99 ret=$?
100 IFS="${oIFS}"
101
charts.d/nginx.chart.sh
+2 -1
@@ -4,6 +4,7 @@
4 # must start with X_
5
6 nginx_url="http://127.0.0.1:80/stub_status"
7 +nginx_curl_opts=""
8
9 # _update_every is a special variable - it holds the number of seconds
10 # between the calls of the _update() function
@@ -19,7 +20,7 @@ nginx_reading=0
20 nginx_writing=0
21 nginx_waiting=0
22 nginx_get() {
22 - nginx_response=($(curl -Ss "${nginx_url}"))
23 + nginx_response=($(curl -Ss ${nginx_curl_opts} "${nginx_url}"))
24 [ $? -ne 0 -o "${#nginx_response[@]}" -eq 0 ] && return 1
25
26 if [ "${nginx_response[0]}" != "Active" \
charts.d/phpfpm.chart.sh
+6 -4
@@ -8,6 +8,7 @@
8 # you can see, https://easyengine.io/tutorials/php/fpm-status-page/
9
10 declare -A phpfpm_urls=()
11 +declare -A phpfpm_curl_opts=()
12
13 # _update_every is a special variable - it holds the number of seconds
14 # between the calls of the _update() function
@@ -29,8 +30,9 @@ phpfpm_max_active_processes=0
30 phpfpm_max_children_reached=0
31 phpfpm_slow_requests=0
32 phpfpm_get() {
32 - url=$1
33 - phpfpm_response=($(curl -Ss "${url}"))
33 + local opts="${1}" url="${2}"
34 +
35 + phpfpm_response=($(curl -Ss ${opts} "${url}"))
36 [ $? -ne 0 -o "${#phpfpm_response[@]}" -eq 0 ] && return 1
37
38 if [[ "${phpfpm_response[0]}" != "pool:" \
@@ -94,7 +96,7 @@ phpfpm_check() {
96 local m
97 for m in "${!phpfpm_urls[@]}"
98 do
97 - phpfpm_get "${phpfpm_urls[$m]}"
99 + phpfpm_get "${phpfpm_curl_opts[$m]}" "${phpfpm_urls[$m]}"
100 if [ $? -ne 0 ]; then
101 echo >&2 "phpfpm: cannot find status on URL '${phpfpm_url[$m]}'. Please set phpfpm_urls[$m]='http://localhost/status' in $confd/phpfpm.conf"
102 unset phpfpm_urls[$m]
@@ -149,7 +151,7 @@ phpfpm_update() {
151 local m
152 for m in "${!phpfpm_urls[@]}"
153 do
152 - phpfpm_get "${phpfpm_urls[$m]}"
154 + phpfpm_get "${phpfpm_curl_opts[$m]}" "${phpfpm_urls[$m]}"
155 if [ $? -ne 0 ]; then
156 continue
157 fi
charts.d/tomcat.chart.sh
+2 -1
@@ -6,6 +6,7 @@
6 # the URL to download tomcat status info
7 # usually http://localhost:8080/manager/status?XML=true
8 tomcat_url=""
9 +tomcat_curl_opts=""
10
11 # set tomcat username/password here
12 tomcatUser=""
@@ -64,7 +65,7 @@ tomcat_check() {
65 tomcat_get() {
66 # collect tomcat values
67 tomcat_port="$(IFS=/ read -ra a <<< "$tomcat_url"; hostport=${a[2]}; echo "${hostport#*:}")"
67 - mapfile -t lines < <(curl -u "$tomcatUser":"$tomcatPassword" -Ss "$tomcat_url" |\
68 + mapfile -t lines < <(curl -u "$tomcatUser":"$tomcatPassword" -Ss ${tomcat_curl_opts} "$tomcat_url" |\
69 xmlstarlet sel \
70 -t -m "/status/jvm/memory" -v @free \
71 -n -m "/status/connector[@name='\"http-bio-$tomcat_port\"']/threadInfo" -v @currentThreadCount \