Module: check_mk
Branch: master
Commit: 655322b1df52c83ecb5bc2332c0badb86e62662e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=655322b1df52c8…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Mar 23 15:30:13 2015 +0100
#2155 siemens_plc_counter: added new check for monitoring increasing counter values
---
.werks/2155 | 9 ++++
ChangeLog | 1 +
checks/siemens_plc | 71 +++++++++++++++++++++++++------
web/plugins/wato/check_parameters.py | 33 +++++++++++++-
web/plugins/wato/datasource_programs.py | 18 +++++---
5 files changed, 112 insertions(+), 20 deletions(-)
diff --git a/.werks/2155 b/.werks/2155
new file mode 100644
index 0000000..a4b29a3
--- /dev/null
+++ b/.werks/2155
@@ -0,0 +1,9 @@
+Title: siemens_plc_counter: added new check for monitoring increasing counter values
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.7i1
+Date: 1427120998
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index f480917..94a7a9c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -138,6 +138,7 @@
* 2153 siemens_plc.duration siemens_plc.flag siemens_plc.info: New Checks for Siemens
PLC devices
* 2063 winperf_if: now also able to detect the interface port state
'lowerLayerDown'...
* 2154 Interface-Checks: Separate traffic thresholds for in and out are now
possible...
+ * 2155 siemens_plc_counter: added new check for monitoring increasing counter values
* 1457 FIX: logins: new check renamed from "users" check...
NOTE: Please refer to the migration notes!
* 1762 FIX: lnx_thermal: Now ignoring trip points with level 0...
diff --git a/checks/siemens_plc b/checks/siemens_plc
index 0ec362b..913e4ea 100644
--- a/checks/siemens_plc
+++ b/checks/siemens_plc
@@ -29,19 +29,19 @@
# PFT01 flag Testbit True
# PFT01 flag Testbit2 False
# RGB01 temp Gesamt 123
-# RGB01 hours Fahren 56
-# RGB01 hours Hub 48
+# RGB01 seconds Fahren 56
+# RGB01 seconds Hub 48
+# RGB01 seconds LAM1 13
# RGB01 temp Extern 18.7000007629
# RGB01 temp RBG_SCH1 0.0
# RGB01 temp RBG_SCH2 0.0
-# RGB01 None Fahren 31450
-# RGB01 None Hub 8100
-# RGB01 None LAM 5002
-# RGB01 hours LAM1 13
-# RGB01 None Lastzyklen 78
-# RGB01 None LAM1_Zyklen 115
-# RGB01 hours Service 109
-# RGB01 hours Serviceintervall 700
+# RGB01 counter Fahren 31450
+# RGB01 counter Hub 8100
+# RGB01 counter LAM 5002
+# RGB01 counter Lastzyklen 78
+# RGB01 counter LAM1_Zyklen 115
+# RGB01 seconds Service 109
+# RGB01 seconds Serviceintervall 700
# RGB01 text Testtext HRL01-0001-0010-02-07
#.
@@ -132,14 +132,17 @@ check_info['siemens_plc.flag'] = {
# '----------------------------------------------------------------------'
def inventory_siemens_plc_duration(info):
- return [ (l[0]+" "+l[2], {}) for l in info if
l[1].startswith("hours") ]
+ return [ (l[0]+" "+l[2], {}) for l in info if
l[1].startswith("hours")
+ or l[1].startswith("seconds") ]
def check_siemens_plc_duration(item, params, info):
for line in info:
- if line[1].startswith("hours") and line[0]+" "+line[2] ==
item:
+ if (line[1].startswith("hours") or
line[1].startswith("seconds")) and line[0]+" "+line[2] == item:
if line[1].startswith("hours"):
seconds = int(line[-1])*3600
+ else:
+ seconds = int(line[-1])
key = 'siemens_plc.duration.%s' % item
if key in g_counters and g_counters[key] < seconds:
@@ -166,6 +169,50 @@ check_info['siemens_plc.duration'] = {
}
#.
+# .--Counter-------------------------------------------------------------.
+# | ____ _ |
+# | / ___|___ _ _ _ __ | |_ ___ _ __ |
+# | | | / _ \| | | | '_ \| __/ _ \ '__| |
+# | | |__| (_) | |_| | | | | || __/ | |
+# | \____\___/ \__,_|_| |_|\__\___|_| |
+# | |
+# +----------------------------------------------------------------------+
+# | |
+# '----------------------------------------------------------------------'
+
+def inventory_siemens_plc_counter(info):
+ return [ (l[0]+" "+l[2], {}) for l in info if
l[1].startswith("counter") ]
+
+
+def check_siemens_plc_counter(item, params, info):
+ for line in info:
+ if line[1].startswith("counter") and line[0]+" "+line[2] ==
item:
+ value = int(line[-1])
+
+ key = 'siemens_plc.counter.%s' % item
+ if key in g_counters and g_counters[key] < value:
+ return 2, 'Reduced from %s to %s' % (g_counters[key], value)
+ g_counters[key] = value
+
+ state = 0
+ warn, crit = params.get('levels', (None, None))
+ if crit != None and value >= crit:
+ state = 2
+ elif warn != None and value >= warn:
+ state = 1
+
+ return state, '%d' % value, [(line[1], value)]
+
+
+check_info['siemens_plc.counter'] = {
+ "inventory_function" : inventory_siemens_plc_counter,
+ "check_function" : check_siemens_plc_counter,
+ "service_description" : "Counter %s",
+ "has_perfdata" : True,
+ "group" : "siemens_plc_counter",
+}
+
+#.
# .--Info----------------------------------------------------------------.
# | ___ __ |
# | |_ _|_ __ / _| ___ |
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index ef277ec..1da968f 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -8611,7 +8611,38 @@ register_check_parameters(
],
help = _("This rule is used to configure thresholds for duration values read
from "
"Siemens PLC devices."),
- title = _("Expected flag state"),
+ title = _("Duration levels"),
+ ),
+ TextAscii(
+ title = _("Device Name and Value Ident"),
+ help = _("You need to concatenate the device name which is configured in the
special agent "
+ "for the PLC device separated by a space with the ident of the
value which is also "
+ "configured in the special agent."),
+ ),
+ None
+)
+
+register_check_parameters(
+ subgroup_environment,
+ "siemens_plc_counter",
+ _("Siemens PLC Counter"),
+ Dictionary(
+ elements = [
+ ('levels', Tuple(
+ title = _("Counter level"),
+ elements = [
+ Integer(
+ title = _("Warning at"),
+ ),
+ Integer(
+ title = _("Critical at"),
+ ),
+ ]
+ )),
+ ],
+ help = _("This rule is used to configure thresholds for counter values read
from "
+ "Siemens PLC devices."),
+ title = _("Counter levels"),
),
TextAscii(
title = _("Device Name and Value Ident"),
diff --git a/web/plugins/wato/datasource_programs.py
b/web/plugins/wato/datasource_programs.py
index 4f30f3a..2bc9236 100644
--- a/web/plugins/wato/datasource_programs.py
+++ b/web/plugins/wato/datasource_programs.py
@@ -511,13 +511,17 @@ _siemens_plc_value = [
DropdownChoice(
title = _("Type of the value"),
choices = [
- (None, _("Unclassified")),
- ("temp", _("Temperature")),
- ("hours_operation", _("Hours of operation")),
- ("hours_since_service", _("Hours since service")),
- ("hours", _("Hours")),
- ("flag", _("State flag (on/off)")),
- ("text", _("Text")),
+ (None, _("Unclassified")),
+ ("temp", _("Temperature")),
+ ("hours_operation", _("Hours of operation")),
+ ("hours_since_service", _("Hours since service")),
+ ("hours", _("Hours")),
+ ("seconds_operation", _("Seconds of operation")),
+ ("seconds_since_service", _("Seconds since service")),
+ ("seconds", _("Seconds")),
+ ("counter", _("Increasing counter")),
+ ("flag", _("State flag (on/off)")),
+ ("text", _("Text")),
],
sorted = True,
),