Module: check_mk
Branch: master
Commit: b96dacaa484c334e620b443e893c46cd404549f7
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b96dacaa484c33…
Author: Sebastian Herbord <sh(a)mathias-kettner.de>
Date: Tue Aug 18 15:47:37 2015 +0200
esx_vsphere_counters and siemens_plc now use the new API to store state
---
checks/esx_vsphere_counters | 6 +++---
checks/siemens_plc | 17 +++++++----------
2 files changed, 10 insertions(+), 13 deletions(-)
diff --git a/checks/esx_vsphere_counters b/checks/esx_vsphere_counters
index 60a1ae6..28631ce 100644
--- a/checks/esx_vsphere_counters
+++ b/checks/esx_vsphere_counters
@@ -296,14 +296,14 @@ def convert_esx_counters_if(parsed):
if ctr_name.startswith("bytes"):
ctr_value *= 1024
countername = "vmnic." + name + "." + ctr_name
- if countername in g_counters:
- last_time, last_value = g_counters[countername]
+ last_time, last_value = get_item_state(countername, (None, None))
+ if last_time or last_value:
new_value = last_value + ((this_time - last_time) * ctr_value)
else:
last_time = this_time - 60
last_value = 0
new_value = ctr_value * 60
- g_counters[countername] = (this_time, new_value)
+ set_item_state(countername, (this_time, new_value))
entry[ti] = str(int(new_value))
return converted
diff --git a/checks/siemens_plc b/checks/siemens_plc
index 56eb9d9..3c44729 100644
--- a/checks/siemens_plc
+++ b/checks/siemens_plc
@@ -147,13 +147,12 @@ def check_siemens_plc_duration(item, params, info):
perfdata = [(line[1], seconds)]
key = 'siemens_plc.duration.%s' % item
- if key in g_counters and g_counters[key] > seconds:
- old_seconds = g_counters[key]
- g_counters[key] = seconds
+ old_seconds = get_item_state(key, None)
+ if old_seconds is not None and old_seconds > seconds:
return 2, 'Reduced from %s to %s' %
(get_age_human_readable(old_seconds),
get_age_human_readable(seconds)),
perfdata
- else:
- g_counters[key] = seconds
+
+ set_item_state(key, seconds)
state = 0
warn, crit = params.get('duration', (None, None))
@@ -196,12 +195,10 @@ def check_siemens_plc_counter(item, params, info):
perfdata = [(line[1], value)]
key = 'siemens_plc.counter.%s' % item
- if key in g_counters and g_counters[key] > value:
- old_value = g_counters[key]
- g_counters[key] = value
+ old_value = get_item_state(key, None)
+ if old_value is not None and old_value > value:
return 2, 'Reduced from %s to %s' % (old_value, value), perfdata
- else:
- g_counters[key] = value
+ set_item_state(key, value)
state = 0
warn, crit = params.get('levels', (None, None))