Module: check_mk
Branch: master
Commit: d907571692a4c09ef05f6b8e0706a059fbfc2f9d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d907571692a4c0…
Author: Sebastian Herbord <sh(a)mathias-kettner.de>
Date: Thu Apr 21 15:21:03 2016 +0200
3124 FIX workaround for overrunnig counters in a couple of wmi checks
Please note that this is just a workaround, it will still produce wrong output at some
point.
There doesn't seem to be a correct way to work with a wrap in performance counters.
---
.werks/3124 | 11 +++++++++++
ChangeLog | 1 +
checks/wmi.include | 18 ++++++++++++------
3 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/.werks/3124 b/.werks/3124
new file mode 100644
index 0000000..8735db0
--- /dev/null
+++ b/.werks/3124
@@ -0,0 +1,11 @@
+Title: workaround for overrunnig counters in a couple of wmi checks
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.9i1
+Date: 1461243484
+
+Please note that this is just a workaround, it will still produce wrong output at some
point.
+There doesn't seem to be a correct way to work with a wrap in performance counters.
diff --git a/ChangeLog b/ChangeLog
index 3444ad8..29b051d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -166,6 +166,7 @@
NOTE: Please refer to the migration notes!
* 3387 FIX: ps: Fixed crash during service discovery on AIX hosts having defunct
processes
* 3417 FIX: wmi_cpuload: fix exception in case of missing NumberOfLogicalProcessors
on some OS versions
+ * 3124 FIX: workaround for overrunnig counters in a couple of wmi checks...
Multisite:
* 3187 notification view: new filter for log command via regex
diff --git a/checks/wmi.include b/checks/wmi.include
index 7795213..6dcb798 100644
--- a/checks/wmi.include
+++ b/checks/wmi.include
@@ -267,11 +267,11 @@ def wmi_yield_raw_counter(table, row, column, label, perfvar,
levels=None):
[wmi_make_perfvar(perfvar, value, levels)])
-def wmi_calculate_raw_average(table, row, column):
+def wmi_calculate_raw_average(table, row, column, factor):
if row == "":
row = 0
- time_spent_total = int(table.get(row, column))
+ measure = int(table.get(row, column)) * factor
base = int(table.get(row, column + "_Base"))
if base < 0:
@@ -283,13 +283,20 @@ def wmi_calculate_raw_average(table, row, column):
if base == 0:
return 0.0
- return float(time_spent_total) / base
+ # This is a total counter which can overflow on long-running systems
+ # (great choice of datatype, microsoft!)
+ # the following forces the counter into a range of 0.0-1.0, but there is no way to
know
+ # how often the counter overran, so this bay still be wrong
+ while (base * factor) < measure:
+ base += 1 << 32
+
+ return float(measure) / base
def wmi_yield_raw_average(table, row, column, label, perfvar, levels=None):
levels = wmi_fix_levels(levels)
- average = wmi_calculate_raw_average(table, row, column)
+ average = wmi_calculate_raw_average(table, row, column, 1)
return (
wmi_determine_status(average, levels),
@@ -301,7 +308,7 @@ def wmi_yield_raw_average(table, row, column, label, perfvar,
levels=None):
def wmi_yield_raw_fraction(table, row, column, label, perfvar, levels=None):
levels = wmi_fix_levels(levels)
- average = wmi_calculate_raw_average(table, row, column) * 100
+ average = wmi_calculate_raw_average(table, row, column, 100)
status = wmi_determine_status(average, levels)
return (
@@ -310,6 +317,5 @@ def wmi_yield_raw_fraction(table, row, column, label, perfvar,
levels=None):
[wmi_make_perfvar(perfvar, average, levels, 0, 100)]
)
-
#.