From 8a804130f6ebf45784cacf3d6f87f61ed9195481 Mon Sep 17 00:00:00 2001 From: "Stian B. Lindhom" Date: Thu, 15 Apr 2010 19:29:25 +0200 Subject: [PATCH] Initial version --- plugins/other/tomcatthreads | 46 +++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100755 plugins/other/tomcatthreads diff --git a/plugins/other/tomcatthreads b/plugins/other/tomcatthreads new file mode 100755 index 00000000..ea2128ad --- /dev/null +++ b/plugins/other/tomcatthreads @@ -0,0 +1,46 @@ +#!/usr/bin/env groovy +/* + * Reports tomcat thread status from the tomcat manager application + * + * Stian B. Lindhom 2010 + */ + +def username = '' +def password = '' +def addr = 'http://localhost:8080/manager/status?XML=true' +def connector = 'http-8080' + +def authString = (username + ":" + password).getBytes().encodeBase64() +def conn = addr.toURL().openConnection() + +def maxthreads +def threadsBusy +def threadCount +conn.setRequestProperty("Authorization", "Basic ${authString}") +if (conn.responseCode == 200) { + def doc = new XmlParser().parseText(conn.content.text) + httpConnector = doc.connector.findAll{ it.'@name'.contains(connector) }[0] + maxthreads = Integer.parseInt(httpConnector.threadInfo.'@maxThreads'.text()) + threadsBusy = Integer.parseInt(httpConnector.threadInfo.'@currentThreadsBusy'.text()) + threadCount = Integer.parseInt(httpConnector.threadInfo.'@currentThreadCount'.text()) +} + +if (args && args[0] == 'config') { + warningThreshold = (Integer) (maxthreads - (maxthreads* 0.2)) + criticalThreshold = (Integer) (maxthreads - (maxthreads * 0.05)) + + println """graph_category Tomcat +graph_title Tomcat threads +graph_info The number of busy threads describes how many HTTP requests are being processed at the moment +graph_vlabel Threads +currentThreadCount.label currentThreadCount +currentThreadsBusy.label currentThreadsBusy +maxThreads.label maxThreads +currentThreadCount.warning ${warningThreshold} +currentThreadCount.critical ${criticalThreshold}""" + return; +} + +println """currentThreadCount.value ${threadCount} +currentThreadsBusy.value ${threadsBusy} +maxThreads.value ${maxthreads}"""