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 # _update_every is a special variable - it holds the number of seconds
10 # between the calls of the _update() function
15 # convert tomcat floating point values
16 # to integer using this multiplier
17 # this only affects precision - the values
18 # will be in the proper units
19 tomcat_decimal_detail=1000000
21 # used by volume chart to convert bytes to KB
22 tomcat_decimal_KB_detail=1000
26 require_cmd xmlstarlet || return 1
31 echo >&2 "tomcat: cannot find stub_status on URL '${tomcat_url}'. Please set tomcat_url='http://<user>:<password>@localhost:8080/manager/status?XML=true'"
36 # - 0 to enable the chart
37 # - 1 to disable the chart
43 # Collect tomcat values
44 mapfile -t lines < <(curl -s "$tomcat_url" | xmlstarlet sel -t -m "/status/jvm/memory" -v @free -n -m "/status/connector[@name='\"http-bio-8080\"']/threadInfo" -v @currentThreadCount -n -v @currentThreadsBusy -n -m "/status/connector[@name='\"http-bio-8080\"']/requestInfo" -v @requestCount -n -v @bytesSent -n -)
46 tomcat_jvm_freememory="${lines[0]}"
47 tomcat_threads="${lines[1]}"
48 tomcat_threads_busy="${lines[2]}"
49 tomcat_accesses="${lines[3]}"
50 tomcat_volume="${lines[4]}"
55 # _create is called once, to create the charts
58 CHART tomcat.accesses '' "tomcat requests" "requests/s" statistics tomcat.accesses area $[tomcat_priority + 8] $tomcat_update_every
59 DIMENSION accesses '' incremental
60 CHART tomcat.volume '' "tomcat volume" "KB/s" volume tomcat.volume area $[tomcat_priority + 5] $tomcat_update_every
61 DIMENSION volume '' incremental divisor ${tomcat_decimal_KB_detail}
62 CHART tomcat.threads '' "tomcat threads" "current threads" statistics tomcat.threads line $[tomcat_priority + 6] $tomcat_update_every
63 DIMENSION current '' absolute 1
64 DIMENSION busy '' absolute 1
65 CHART tomcat.jvm '' "JVM Free Memory" "MB" statistics tomcat.jvm area $[tomcat_priority + 8] $tomcat_update_every
66 DIMENSION jvm '' absolute 1 ${tomcat_decimal_detail}
71 # _update is called continiously, to collect the values
74 # the first argument to this function is the microseconds since last update
75 # pass this parameter to the BEGIN statement (see bellow).
77 # do all the work to collect / calculate the values
79 # remember: KEEP IT SIMPLE AND SHORT
81 tomcat_get || return 1
83 # write the result of the work.
85 BEGIN tomcat.accesses $1
86 SET accesses = $[tomcat_accesses]
88 BEGIN tomcat.volume $1
89 SET volume = $[tomcat_volume]
91 BEGIN tomcat.threads $1
92 SET current = $[tomcat_threads]
93 SET busy = $[tomcat_threads_busy]
96 SET jvm = $[tomcat_jvm_freememory]