fix variable naming in tomcat.chart.sh
paulfantom committed
Jun 17, 2016 at 17:01 UTC
70e2d2feb380d3ae43e9b89e10cea721c30260ac
1 file changed
+19
-9
charts.d/tomcat.chart.sh
+19
-9
@@ -9,8 +9,8 @@ tomcat_url=""
9
tomcat_curl_opts=""
10
11
# set tomcat username/password here
12
-tomcatUser=""
13
-tomcatPassword=""
12
+tomcat_user=""
13
+tomcat_password=""
14
15
# _update_every is a special variable - it holds the number of seconds
16
# between the calls of the _update() function
@@ -37,13 +37,23 @@ tomcat_check() {
37
echo >&2 "tomcat url is unset or set to the empty string"
38
return 1
39
fi
40
- if [ -z "${tomcatUser}" ]; then
41
- echo >&2 "tomcat user is unset or set to the empty string"
42
- return 1
40
+ if [ -z "${tomcat_user}" ]; then
41
+ # check backwards compatibility
42
+ if [ -z "${tomcatUser}" ]; then
43
+ echo >&2 "tomcat user is unset or set to the empty string"
44
+ return 1
45
+ else
46
+ tomcat_user="${tomcatUser}"
47
+ fi
48
fi
44
- if [ -z "${tomcatPassword}" ]; then
45
- echo >&2 "tomcat password is unset or set to the empty string"
46
- return 1
49
+ if [ -z "${tomcat_password}" ]; then
50
+ # check backwards compatibility
51
+ if [ -z "${tomcatPassword}" ]; then
52
+ echo >&2 "tomcat password is unset or set to the empty string"
53
+ return 1
54
+ else
55
+ tomcat_password="${tomcatPassword}"
56
+ fi
57
fi
58
59
# check if we can get to tomcat's status page
@@ -65,7 +75,7 @@ tomcat_check() {
75
tomcat_get() {
76
# collect tomcat values
77
tomcat_port="$(IFS=/ read -ra a <<< "$tomcat_url"; hostport=${a[2]}; echo "${hostport#*:}")"
68
- mapfile -t lines < <(curl -u "$tomcatUser":"$tomcatPassword" -Ss ${tomcat_curl_opts} "$tomcat_url" |\
78
+ mapfile -t lines < <(curl -u "$tomcat_user":"$tomcat_password" -Ss ${tomcat_curl_opts} "$tomcat_url" |\
79
xmlstarlet sel \
80
-t -m "/status/jvm/memory" -v @free \
81
-n -m "/status/connector[@name='\"http-bio-$tomcat_port\"']/threadInfo" -v @currentThreadCount \