adding checks to make sure url, username and password are set.
Jorge Romero committed
May 6, 2016 at 15:28 UTC
5e5cf142e7e86b9cb41fa6df6dd7e399e07e2c83
1 file changed
+20
-3
charts.d/tomcat.chart.sh
+20
-3
@@ -4,9 +4,10 @@
4
# Author: Jorge Romero
5
6
# the URL to download tomcat status info
7
-tomcat_url="http://localhost:8080/manager/status?XML=true"
7
+# usually http://localhost:8080/manager/status?XML=true
8
+tomcat_url=""
9
9
-# set tomcat user/password here
10
+# set tomcat username/password here
11
tomcatUser=""
12
tomcatPassword=""
13
@@ -29,10 +30,26 @@ tomcat_check() {
30
31
require_cmd xmlstarlet || return 1
32
33
+
34
+ # check if url, username, passwords are set
35
+ if [ -z "${tomcat_url}" ]; then
36
+ echo "tomcat url is unset or set to the empty string"
37
+ return 1
38
+ fi
39
+ if [ -z "${tomcatUser}" ]; then
40
+ echo "tomcat user is unset or set to the empty string"
41
+ return 1
42
+ fi
43
+ if [ -z "${tomcatPassword}" ]; then
44
+ echo "tomcat password is unset or set to the empty string"
45
+ return 1
46
+ fi
47
+
48
+ # check if we can get to tomcat's status page
49
tomcat_get
50
if [ $? -ne 0 ]
51
then
35
- echo >&2 "tomcat: cannot find status page on URL '${tomcat_url}'. Please set tomcat_url='http://localhost:8080/manager/status?XML=true'"
52
+ echo >&2 "tomcat: couldn't get to status page on URL '${tomcat_url}'. Please make sure tomcat url, username and password are correct."
53
return 1
54
fi
55