Module: check_mk
Branch: master
Commit: e31e99cbbc328736b9aecb2b3263fa83c311c652
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e31e99cbbc3287…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Mar 27 11:33:14 2015 +0100
#2170 FIX jolokia_metrics_gc: Fixed exception when GC time not reported by server
---
.werks/2170 | 10 ++++++
ChangeLog | 1 +
checks/jolokia_metrics | 80 +++++++++++++++++++-----------------------------
3 files changed, 43 insertions(+), 48 deletions(-)
diff --git a/.werks/2170 b/.werks/2170
new file mode 100644
index 0000000..3c2a71b
--- /dev/null
+++ b/.werks/2170
@@ -0,0 +1,10 @@
+Title: jolokia_metrics_gc: Fixed exception when GC time not reported by server
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i1
+Date: 1427452368
+
+
diff --git a/ChangeLog b/ChangeLog
index dc9c923..9e4da13 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -288,6 +288,7 @@
* 2163 FIX: printer_supply: Now auto detects whether or not a supply is consumable or
filling up...
* 2164 FIX: printer_supply: Fixed handling different capacities than percentage when
used upturned levels
* 2169 FIX: jolokia_metrics.threads: Fixed graph template...
+ * 2170 FIX: jolokia_metrics_gc: Fixed exception when GC time not reported by server
Multisite:
* 1758 Improved exception hander: Shows details without additional debug request,
added mailto link for error report...
diff --git a/checks/jolokia_metrics b/checks/jolokia_metrics
index fbddb46..bc83312 100644
--- a/checks/jolokia_metrics
+++ b/checks/jolokia_metrics
@@ -523,65 +523,49 @@ def check_jolokia_metrics_bea_threads(item, _no_params, info):
def check_jolokia_metrics_gc(item, params, info):
gc = jolokia_metrics_gc(info, item.split())
if gc == None:
- return(3,"data not found in agent output")
-
- if params != None:
- if 'CollectionTime' in params:
- twarn, tcrit = params['CollectionTime']
- else:
- twarn, tcrit = (None, None)
+ return
- if 'CollectionCount' in params:
- cwarn, ccrit = params['CollectionCount']
- else:
- cwarn, ccrit = (None, None)
+ if params:
+ cwarn, ccrit = params.get('CollectionCount', (None, None))
- status = 0
- perf = []
-
- trate = get_rate("jvm.gc.time.%s" % (item), \
- time.time(), saveint(gc['CollectionTime']))
crate = get_rate("jvm.gc.count.%s" % (item), \
- time.time(), saveint(gc['CollectionCount']))
-
- trate = trate * 60.0
+ time.time(), int(gc['CollectionCount']))
crate = crate * 60.0
- ttext = ""
- ctext = ""
-
- if params != None:
- if cwarn != None and ccrit != None:
- if crate >= int(ccrit):
- status = 2
- ctext = "((!!) Level %s) " % ccrit
- elif crate >= int(cwarn):
- if status != 2:
- status = 1
- ctext = "((!) Level %s) " % cwarn
-
- perf.append(('CollectionCount',crate,cwarn,ccrit))
- else:
- perf.append(('CollectionCount',crate))
-
+ ctext = ''
+ status = 0
+ if cwarn != None and ccrit != None:
+ if crate >= int(ccrit):
+ status = 2
+ ctext = " (Level %s) " % ccrit
+ elif crate >= int(cwarn):
+ status = 1
+ ctext = " (Level %s) " % cwarn
+
+ yield status, "%.2f GC Count/minute%s" % (crate, ctext), \
+ [('CollectionCount', crate, cwarn, ccrit)]
+
+ if 'CollectionTime' in gc:
+ if params:
+ twarn, tcrit = params.get('CollectionTime', (None, None))
+
+ trate = get_rate("jvm.gc.time.%s" % (item), \
+ time.time(), int(gc['CollectionTime']))
+ trate = trate * 60.0
+
+ ttext = ''
+ status = 0
if twarn != None and tcrit != None:
if trate >= int(tcrit):
status = 2
- ttext = "((!!) Level %s) " % tcrit
+ ttext = "(Level %s) " % tcrit
elif trate >= int(twarn):
- if status != 2:
- status = 1
- ttext = "((!) Level %s) " % twarn
+ status = 1
+ ttext = "(Level %s) " % twarn
- perf.append(('CollectionTime', '%sms' % trate,twarn,tcrit))
- else:
- perf.append(('CollectionTime', '%sms' %trate))
- else:
- perf = [('CollectionCount',crate), ('CollectionTime',
'%sms' %trate)]
+ yield status, "%.2f GC ms/minute%s" % (trate, text), \
+ [('CollectionTime', trate, twarn, tcrit)]
- output = "%.2f GC Count/minute %sand %.2f GC ms/minute %s" % (crate, \
- ctext, trate, ttext)
- return (status, output, perf)
def check_jolokia_metrics_tp(item, params, info):
tp = jolokia_metrics_tp(info, item.split())