Révision 8a804130
Initial version
| plugins/other/tomcatthreads | ||
|---|---|---|
| 1 |
#!/usr/bin/env groovy |
|
| 2 |
/* |
|
| 3 |
* Reports tomcat thread status from the tomcat manager application |
|
| 4 |
* |
|
| 5 |
* Stian B. Lindhom <stian@lindhom.no> 2010 |
|
| 6 |
*/ |
|
| 7 |
|
|
| 8 |
def username = '' |
|
| 9 |
def password = '' |
|
| 10 |
def addr = 'http://localhost:8080/manager/status?XML=true' |
|
| 11 |
def connector = 'http-8080' |
|
| 12 |
|
|
| 13 |
def authString = (username + ":" + password).getBytes().encodeBase64() |
|
| 14 |
def conn = addr.toURL().openConnection() |
|
| 15 |
|
|
| 16 |
def maxthreads |
|
| 17 |
def threadsBusy |
|
| 18 |
def threadCount |
|
| 19 |
conn.setRequestProperty("Authorization", "Basic ${authString}")
|
|
| 20 |
if (conn.responseCode == 200) {
|
|
| 21 |
def doc = new XmlParser().parseText(conn.content.text) |
|
| 22 |
httpConnector = doc.connector.findAll{ it.'@name'.contains(connector) }[0]
|
|
| 23 |
maxthreads = Integer.parseInt(httpConnector.threadInfo.'@maxThreads'.text()) |
|
| 24 |
threadsBusy = Integer.parseInt(httpConnector.threadInfo.'@currentThreadsBusy'.text()) |
|
| 25 |
threadCount = Integer.parseInt(httpConnector.threadInfo.'@currentThreadCount'.text()) |
|
| 26 |
} |
|
| 27 |
|
|
| 28 |
if (args && args[0] == 'config') {
|
|
| 29 |
warningThreshold = (Integer) (maxthreads - (maxthreads* 0.2)) |
|
| 30 |
criticalThreshold = (Integer) (maxthreads - (maxthreads * 0.05)) |
|
| 31 |
|
|
| 32 |
println """graph_category Tomcat |
|
| 33 |
graph_title Tomcat threads |
|
| 34 |
graph_info The number of busy threads describes how many HTTP requests are being processed at the moment |
|
| 35 |
graph_vlabel Threads |
|
| 36 |
currentThreadCount.label currentThreadCount |
|
| 37 |
currentThreadsBusy.label currentThreadsBusy |
|
| 38 |
maxThreads.label maxThreads |
|
| 39 |
currentThreadCount.warning ${warningThreshold}
|
|
| 40 |
currentThreadCount.critical ${criticalThreshold}"""
|
|
| 41 |
return; |
|
| 42 |
} |
|
| 43 |
|
|
| 44 |
println """currentThreadCount.value ${threadCount}
|
|
| 45 |
currentThreadsBusy.value ${threadsBusy}
|
|
| 46 |
maxThreads.value ${maxthreads}"""
|
|
Formats disponibles : Unified diff