3 # Description: Tomcat netdata charts.d plugin
6 # the URL to download tomcat status info
7 tomcat_url="http://localhost:8080/manager/status?XML=true"
9 # set tomcat user/password here
13 # _update_every is a special variable - it holds the number of seconds
14 # between the calls of the _update() function
19 # convert tomcat floating point values
20 # to integer using this multiplier
21 # this only affects precision - the values
22 # will be in the proper units
23 tomcat_decimal_detail=1000000
25 # used by volume chart to convert bytes to KB
26 tomcat_decimal_KB_detail=1000
30 require_cmd xmlstarlet || return 1
35 echo >&2 "tomcat: cannot find status page on URL '${tomcat_url}'. Please set tomcat_url='http://localhost:8080/manager/status?XML=true'"
40 # - 0 to enable the chart
41 # - 1 to disable the chart
47 # Collect tomcat values
48 mapfile -t lines < <(curl -u "$tomcatUser":"$tomcatPassword" -Ss "$tomcat_url" |\
50 -t -m "/status/jvm/memory" -v @free \
51 -n -m "/status/connector[@name='\"http-bio-8080\"']/threadInfo" -v @currentThreadCount \
52 -n -v @currentThreadsBusy \
53 -n -m "/status/connector[@name='\"http-bio-8080\"']/requestInfo" -v @requestCount \
54 -n -v @bytesSent -n -)
56 tomcat_jvm_freememory="${lines[0]}"
57 tomcat_threads="${lines[1]}"
58 tomcat_threads_busy="${lines[2]}"
59 tomcat_accesses="${lines[3]}"
60 tomcat_volume="${lines[4]}"
65 # _create is called once, to create the charts
68 CHART tomcat.accesses '' "tomcat requests" "requests/s" statistics tomcat.accesses area $((tomcat_priority + 8)) $tomcat_update_every
69 DIMENSION accesses '' incremental
70 CHART tomcat.volume '' "tomcat volume" "KB/s" volume tomcat.volume area $((tomcat_priority + 5)) $tomcat_update_every
71 DIMENSION volume '' incremental divisor ${tomcat_decimal_KB_detail}
72 CHART tomcat.threads '' "tomcat threads" "current threads" statistics tomcat.threads line $((tomcat_priority + 6)) $tomcat_update_every
73 DIMENSION current '' absolute 1
74 DIMENSION busy '' absolute 1
75 CHART tomcat.jvm '' "JVM Free Memory" "MB" statistics tomcat.jvm area $((tomcat_priority + 8)) $tomcat_update_every
76 DIMENSION jvm '' absolute 1 ${tomcat_decimal_detail}
81 # _update is called continiously, to collect the values
84 # the first argument to this function is the microseconds since last update
85 # pass this parameter to the BEGIN statement (see bellow).
87 # do all the work to collect / calculate the values
89 # remember: KEEP IT SIMPLE AND SHORT
91 tomcat_get || return 1
93 # write the result of the work.
95 BEGIN tomcat.accesses $1
96 SET accesses = $((tomcat_accesses))
98 BEGIN tomcat.volume $1
99 SET volume = $((tomcat_volume))
101 BEGIN tomcat.threads $1
102 SET current = $((tomcat_threads))
103 SET busy = $((tomcat_threads_busy))
106 SET jvm = $((tomcat_jvm_freememory))