From 8a7b72f7cd1ccd547a03eb4243294e741d661d3f Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 8 Feb 2019 08:30:37 +0100 Subject: Adding upstream version 1.12.0. Signed-off-by: Daniel Baumann --- collectors/charts.d.plugin/tomcat/tomcat.chart.sh | 26 ++++++++++++----------- 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'collectors/charts.d.plugin/tomcat/tomcat.chart.sh') diff --git a/collectors/charts.d.plugin/tomcat/tomcat.chart.sh b/collectors/charts.d.plugin/tomcat/tomcat.chart.sh index 294487b8b..9ca75e63e 100644 --- a/collectors/charts.d.plugin/tomcat/tomcat.chart.sh +++ b/collectors/charts.d.plugin/tomcat/tomcat.chart.sh @@ -32,24 +32,23 @@ tomcat_priority=60000 # will be in the proper units tomcat_decimal_detail=1000000 -# used by volume chart to convert bytes to KB -tomcat_decimal_KB_detail=1000 +# used by volume chart to convert bytes to kB +tomcat_decimal_kB_detail=1000 tomcat_check() { require_cmd xmlstarlet || return 1 - # check if url, username, passwords are set if [ -z "${tomcat_url}" ]; then - error "tomcat url is unset or set to the empty string" + error "tomcat url is unset or set to the empty string" return 1 fi if [ -z "${tomcat_user}" ]; then # check backwards compatibility # shellcheck disable=SC2154 if [ -z "${tomcatUser}" ]; then - error "tomcat user is unset or set to the empty string" + error "tomcat user is unset or set to the empty string" return 1 else tomcat_user="${tomcatUser}" @@ -59,7 +58,7 @@ tomcat_check() { # check backwards compatibility # shellcheck disable=SC2154 if [ -z "${tomcatPassword}" ]; then - error "tomcat password is unset or set to the empty string" + error "tomcat password is unset or set to the empty string" return 1 else tomcat_password="${tomcatPassword}" @@ -69,8 +68,7 @@ tomcat_check() { # check if we can get to tomcat's status page tomcat_get # shellcheck disable=2181 - if [ $? -ne 0 ] - then + if [ $? -ne 0 ]; then error "cannot get to status page on URL '${tomcat_url}'. Please make sure tomcat url, username and password are correct." return 1 fi @@ -84,8 +82,12 @@ tomcat_check() { tomcat_get() { # collect tomcat values - tomcat_port="$(IFS=/ read -ra a <<< "$tomcat_url"; hostport=${a[2]}; echo "${hostport#*:}")" - mapfile -t lines < <(run curl -u "$tomcat_user":"$tomcat_password" -Ss ${tomcat_curl_opts} "$tomcat_url" |\ + tomcat_port="$( + IFS=/ read -ra a <<<"$tomcat_url" + hostport=${a[2]} + echo "${hostport#*:}" + )" + mapfile -t lines < <(run curl -u "$tomcat_user":"$tomcat_password" -Ss ${tomcat_curl_opts} "$tomcat_url" | run xmlstarlet sel \ -t -m "/status/jvm/memory" -v @free \ -n -m "/status/connector[@name='\"http-bio-$tomcat_port\"']/threadInfo" -v @currentThreadCount \ @@ -107,8 +109,8 @@ tomcat_create() { cat <