Module: check_mk
Branch: master
Commit: 367284b9e6da81571216ccfa195c22f707dac821
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=367284b9e6da81…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Jul 25 15:03:40 2011 +0200
New checks j4p_performance.threads and j4p_performance.uptime which
track the number of threads and the uptime of a JMX process
---
ChangeLog | 4 ++-
checks/j4p_performance | 53 +++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 53 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 05ad575..0fd749d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -26,7 +26,9 @@
* mk_oracle: EXCLUDE_<sid>=ALL or EXCLUDE_<sid>=oracle_sessions can be
used to exclude specific checks now
* mk_oracle: Added optional configuration file to configure the new options
- * j4p_performance: Supports basic/digest auth now
+ * j4p_performance agent plugin: Supports basic/digest auth now
+ * New checks j4p_performance.threads and j4p_performance.uptime which
+ track the number of threads and the uptime of a JMX process
Multisite:
* FIX: make non-Ascii characters in services names work again
diff --git a/checks/j4p_performance b/checks/j4p_performance
index a7740f7..801574d 100644
--- a/checks/j4p_performance
+++ b/checks/j4p_performance
@@ -25,6 +25,8 @@
# Boston, MA 02110-1301 USA.
j4p_performance_mem_default_levels = ( 1000, 2000 ) # MB
+j4p_performance_threads_default_levels = ( 80, 100 ) # Number of threads
+
def j4p_performance_parse(info):
parsed = {}
@@ -34,9 +36,15 @@ def j4p_performance_parse(info):
entry[var] = value
return parsed
-def inventory_j4p_performance_mem(checktype, info):
+
+def inventory_j4p_performance(checktype, info):
parsed = j4p_performance_parse(info)
- return [ (k, "j4p_performance_mem_default_levels") for k in parsed ]
+ if checktype == 'j4p_performance.mem':
+ levels = 'j4p_performance_mem_default_levels'
+ elif checktype == 'j4p_performance.threads':
+ levels = 'j4p_performance_threads_default_levels'
+ return [ (k, levels) for k in parsed ]
+
def check_j4p_performance_mem(item, params, info):
warn, crit = params
@@ -59,5 +67,44 @@ def check_j4p_performance_mem(item, params, info):
return (0, "OK - " + infotext, perfdata)
-check_info["j4p_performance.mem"] = ( check_j4p_performance_mem, "JMX %s
Memory", 1, inventory_j4p_performance_mem )
+def check_j4p_performance_threads(item, params, info):
+ warn, crit = params
+ parsed = j4p_performance_parse(info)
+ if item not in parsed:
+ return (3, "UNKNOWN - data not found in agent output")
+ d = parsed[item]
+
+ perfdata = []
+ output = []
+ status = 0
+ for key in [ 'ThreadCount', 'DeamonThreadCount',
'PeakThreadCount', 'TotalStartedThreadCount' ]:
+ val = saveint(d[key])
+ if key == 'ThreadCount':
+ if val >= crit:
+ status = 2
+ elif val >= warn:
+ status = 1
+ perfdata.append((key, val))
+ output.append('%s: %d' % (key, val))
+ return (status, '%s - %s' % (nagios_state_names[status], ',
'.join(output)), perfdata)
+
+
+def check_j4p_performance_uptime(item, _unused, info):
+ parsed = j4p_performance_parse(info)
+ if item not in parsed:
+ return (3, "UNKNOWN - data not found in agent output")
+ uptime = saveint(parsed[item]['Uptime']) / 1000
+
+ seconds = uptime % 60
+ rem = uptime / 60
+ minutes = rem % 60
+ hours = (rem % 1440) / 60
+ days = rem / 1440
+ now = int(time.time())
+ since = time.strftime("%c", time.localtime(now - uptime))
+ return (0, "OK - up since %s (%dd %02d:%02d:%02d)" % (since, days, hours,
minutes, seconds), [ ("uptime", uptime) ])
+
+check_info["j4p_performance.mem"] = (check_j4p_performance_mem,
"JMX %s Memory", 1, inventory_j4p_performance)
+check_info["j4p_performance.threads"] = (check_j4p_performance_threads,
"JMX %s Threads", 1, inventory_j4p_performance)
+check_info["j4p_performance.uptime"] = (check_j4p_performance_uptime,
"JMX %s Uptime", 1, inventory_j4p_performance)