X-Git-Url: https://arthur.barton.de/gitweb/?a=blobdiff_plain;f=charts.d%2Ftomcat.chart.sh;h=44a92c86e7bf35f27fb9beb2c324ac056b08720b;hb=b060bae83cc36fdc4f14120228e4c9b0d1ec42e8;hp=b0eddc7f0dac66345b79ad55b017a321b53ae5ac;hpb=055a553e17e1cf90ae6dcf6b6be8f71a3a46d874;p=netdata.git diff --git a/charts.d/tomcat.chart.sh b/charts.d/tomcat.chart.sh old mode 100755 new mode 100644 index b0eddc7f..44a92c86 --- a/charts.d/tomcat.chart.sh +++ b/charts.d/tomcat.chart.sh @@ -1,4 +1,11 @@ -#!/bin/bash +# no need for shebang - this file is loaded from charts.d.plugin + +# netdata +# real-time performance and health monitoring, done right! +# (C) 2016 Costa Tsaousis +# GPL v3+ +# +# Contributed by @jgeromero with PR #277 # Description: Tomcat netdata charts.d plugin # Author: Jorge Romero @@ -9,8 +16,8 @@ tomcat_url="" tomcat_curl_opts="" # set tomcat username/password here -tomcatUser="" -tomcatPassword="" +tomcat_user="" +tomcat_password="" # _update_every is a special variable - it holds the number of seconds # between the calls of the _update() function @@ -34,24 +41,33 @@ tomcat_check() { # check if url, username, passwords are set if [ -z "${tomcat_url}" ]; then - echo >&2 "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 "${tomcatUser}" ]; then - echo >&2 "tomcat user is unset or set to the empty string" - return 1 + if [ -z "${tomcat_user}" ]; then + # check backwards compatibility + if [ -z "${tomcatUser}" ]; then + error "tomcat user is unset or set to the empty string" + return 1 + else + tomcat_user="${tomcatUser}" + fi fi - if [ -z "${tomcatPassword}" ]; then - echo >&2 "tomcat password is unset or set to the empty string" - return 1 + if [ -z "${tomcat_password}" ]; then + # check backwards compatibility + if [ -z "${tomcatPassword}" ]; then + error "tomcat password is unset or set to the empty string" + return 1 + else + tomcat_password="${tomcatPassword}" + fi fi # check if we can get to tomcat's status page tomcat_get if [ $? -ne 0 ] then - echo >&2 "tomcat: couldn't get to status page on URL '${tomcat_url}'."\ - "Please make sure tomcat url, username and password are correct." + error "cannot get to status page on URL '${tomcat_url}'. Please make sure tomcat url, username and password are correct." return 1 fi @@ -65,8 +81,8 @@ tomcat_check() { tomcat_get() { # collect tomcat values tomcat_port="$(IFS=/ read -ra a <<< "$tomcat_url"; hostport=${a[2]}; echo "${hostport#*:}")" - mapfile -t lines < <(curl -u "$tomcatUser":"$tomcatPassword" -Ss ${tomcat_curl_opts} "$tomcat_url" |\ - xmlstarlet sel \ + 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 \ -n -v @currentThreadsBusy \