Module: check_mk
Branch: master
Commit: 8f271ffd9bc9c84735061a5bba473daf96d7c514
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8f271ffd9bc9c8…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Thu Dec 13 20:41:11 2018 +0100
6947 Poseidon devices: Input and temperature sensors
This werk adds checks for Poseidon temperature and
digital input sensors.
Change-Id: Ib70d99026e40ddde186edab0148f3d76f8e1a941
---
.werks/6947 | 11 +++++
checkman/poseidon_inputs | 15 ++++++
checkman/poseidon_temp | 15 ++++++
checks/poseidon_inputs | 57 ++++++++++++++++++++++
checks/poseidon_temp | 53 ++++++++++++++++++++
.../generictests/datasets/poseidon_inputs_1.py | 44 +++++++++++++++++
.../generictests/datasets/poseidon_temp_1.py | 15 ++++++
7 files changed, 210 insertions(+)
diff --git a/.werks/6947 b/.werks/6947
new file mode 100644
index 0000000..0897c46
--- /dev/null
+++ b/.werks/6947
@@ -0,0 +1,11 @@
+Title: Poseidon devices: Input and temperature sensors
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1544783204
+Class: feature
+
+This werk adds checks for Poseidon temperature and
+digital input sensors.
diff --git a/checkman/poseidon_inputs b/checkman/poseidon_inputs
new file mode 100644
index 0000000..21ecad0
--- /dev/null
+++ b/checkman/poseidon_inputs
@@ -0,0 +1,15 @@
+title: Input Sensors from HWgroup Poseidon devices
+agents: snmp
+catalog: hw/network/hwgroup
+license: GPL
+distribution: check_mk
+description:
+ This check monitors all digital inputs from Poseidon devices.
+
+item:
+ The name of the sensors
+
+
+inventory:
+ One separate service per sensor is being created.
+
diff --git a/checkman/poseidon_temp b/checkman/poseidon_temp
new file mode 100644
index 0000000..bb94041
--- /dev/null
+++ b/checkman/poseidon_temp
@@ -0,0 +1,15 @@
+title: Temperature sensors (HWgroup Poseidon devices)
+agents: snmp
+catalog: hw/network/hwgroup
+license: GPL
+distribution: check_mk
+description:
+ This check monitors all temperature sensors from Poseidon devices.
+
+item:
+ The name of the sensors
+
+
+inventory:
+ One separate service per sensor is being created.
+
diff --git a/checks/poseidon_inputs b/checks/poseidon_inputs
new file mode 100644
index 0000000..a982c49
--- /dev/null
+++ b/checks/poseidon_inputs
@@ -0,0 +1,57 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+
+
+def parse_poseidon_inputs(info):
+ parsed = {}
+ if info:
+ for line_number, line in enumerate(info, 1):
+ input_value, input_name, input_alarm_setup, input_alarm_state = line
+ if input_name == '':
+ input_name = 'Eingang %d' % line_number
+ try:
+ input_value = int(input_value)
+ except ValueError:
+ input_value = 3
+ try:
+ input_alarm_setup = int(input_alarm_setup)
+ except ValueError:
+ input_alarm_setup = 3
+ try:
+ input_alarm_state = int(input_alarm_state)
+ except ValueError:
+ input_alarm_state = 3
+ parsed[input_name] = {
+ 'input_value': input_value,
+ 'input_alarm_setup': input_alarm_setup,
+ 'input_alarm_state': input_alarm_state,
+ }
+ return parsed
+
+
+@get_parsed_item_data
+def check_poseidon_inputs(item, params, data):
+ alarm_setup = {0: 'inactive', 1: 'activeOff', 2: 'activeOn',
3: 'unkown'}
+ input_values = {0: 'off', 1: 'on', 3: 'unkown'}
+ alarm_states = {0: 'normal', 1: 'alarm', 3: 'unkown'}
+ txt = '%s: AlarmSetup: %s' % (item,
alarm_setup[data.get('input_alarm_setup', 3)])
+ yield 0, txt
+
+ state = data.get('input_alarm_state', 3)
+ txt = 'Alarm State: %s' % alarm_states[state]
+ if state == 1:
+ state = 2
+ yield state, txt
+
+ yield 0, "Values %s" % input_values.get(data.get('input_value', 3),
'unknown')
+
+
+check_info["poseidon_inputs"] = {
+ "parse_function": parse_poseidon_inputs,
+ "check_function": check_poseidon_inputs,
+ "inventory_function": discover(),
+ "service_description": "%s",
+ "has_perfdata": False,
+ "snmp_scan_function": lambda oid:
oid(".1.3.6.1.2.1.1.2.0").startswith('.1.3.6.1.4.1.21796.3'),
+ "snmp_info": (".1.3.6.1.4.1.21796.3.3.1.1", ['2',
'3', '4', '5']),
+}
diff --git a/checks/poseidon_temp b/checks/poseidon_temp
new file mode 100644
index 0000000..79e8344
--- /dev/null
+++ b/checks/poseidon_temp
@@ -0,0 +1,53 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+
+factory_settings["poseidon_temp_default_levels"] = {}
+
+
+def parse_poseidon_temp(info):
+ parsed = {}
+ if not info:
+ return
+ for name, state, value_string in info:
+ try:
+ temp = float(value_string.replace('C', ''))
+ except ValueError:
+ temp = None
+ parsed[name] = {'temp': temp, 'status': state}
+ return parsed
+
+
+@get_parsed_item_data
+def check_poseidon_temp(item, params, data):
+ sensor_states = {
+ '0': "invalid",
+ '1': "normal",
+ '2': "alarmstate",
+ '3': "alarm",
+ }
+ sensor_state_value = data.get('status')
+ sensor_state_txt = sensor_states.get(sensor_state_value)
+ mk_status = 0
+ if sensor_state_value != '1':
+ mk_status = 2
+ yield mk_status, "Sensor %s, State %s" % (item, sensor_state_txt)
+
+ temp = data.get('temp')
+ if temp:
+ yield check_temperature(temp, params, "poseidon_temp_%s" %
item.replace(" ", "_"))
+ else:
+ yield 3, "No data for Sensor %s found" % item
+
+
+check_info["poseidon_temp"] = {
+ "parse_function": parse_poseidon_temp,
+ "check_function": check_poseidon_temp,
+ "inventory_function": discover(),
+ "service_description": "Temperatur: %s",
+ "has_perfdata": True,
+ "group": "temperature",
+ "snmp_scan_function": lambda oid:
oid(".1.3.6.1.2.1.1.2.0").startswith('.1.3.6.1.4.1.21796.3'),
+ "snmp_info": (".1.3.6.1.4.1.21796.3.3.3.1", ['2',
'4', '5']),
+ "includes": ["temperature.include"],
+ "default_levels_variable": "poseidon_temp_default_levels",
+}
diff --git a/tests/unit/checks/generictests/datasets/poseidon_inputs_1.py
b/tests/unit/checks/generictests/datasets/poseidon_inputs_1.py
new file mode 100644
index 0000000..dcf099d
--- /dev/null
+++ b/tests/unit/checks/generictests/datasets/poseidon_inputs_1.py
@@ -0,0 +1,44 @@
+
+
+checkname = 'poseidon_inputs'
+
+
+info = [[u'1', u'Bezeichnung Eingang 1', u'1', u'0'],
+ [u'0', u'Bezeichnung Eingang 2', u'2', u'0'],
+ [u'0', u'Bezeichnung Eingang 3', u'1', u'1'],
+ [u'0', u'Bezeichnung Eingang 4', u'1', u'1'],
+ [u'0', u'Comm Monitor 1', u'0', u'0']]
+
+
+discovery = {'': [(u'Bezeichnung Eingang 1', {}),
+ (u'Bezeichnung Eingang 2', {}),
+ (u'Bezeichnung Eingang 3', {}),
+ (u'Bezeichnung Eingang 4', {}),
+ (u'Comm Monitor 1', {})]}
+
+
+checks = {'': [(u'Bezeichnung Eingang 1',
+ 'default',
+ [(0, u'Bezeichnung Eingang 1: AlarmSetup: activeOff', []),
+ (0, 'Alarm State: normal', []),
+ (0, 'Values on', [])]),
+ (u'Bezeichnung Eingang 2',
+ 'default',
+ [(0, u'Bezeichnung Eingang 2: AlarmSetup: activeOn', []),
+ (0, 'Alarm State: normal', []),
+ (0, 'Values off', [])]),
+ (u'Bezeichnung Eingang 3',
+ 'default',
+ [(0, u'Bezeichnung Eingang 3: AlarmSetup: activeOff', []),
+ (2, 'Alarm State: alarm', []),
+ (0, 'Values off', [])]),
+ (u'Bezeichnung Eingang 4',
+ 'default',
+ [(0, u'Bezeichnung Eingang 4: AlarmSetup: activeOff', []),
+ (2, 'Alarm State: alarm', []),
+ (0, 'Values off', [])]),
+ (u'Comm Monitor 1',
+ 'default',
+ [(0, u'Comm Monitor 1: AlarmSetup: inactive', []),
+ (0, 'Alarm State: normal', []),
+ (0, 'Values off', [])])]}
\ No newline at end of file
diff --git a/tests/unit/checks/generictests/datasets/poseidon_temp_1.py
b/tests/unit/checks/generictests/datasets/poseidon_temp_1.py
new file mode 100644
index 0000000..20a3eea
--- /dev/null
+++ b/tests/unit/checks/generictests/datasets/poseidon_temp_1.py
@@ -0,0 +1,15 @@
+
+
+checkname = 'poseidon_temp'
+
+
+info = [[u'Bezeichnung Sensor 1', u'1', u'16.8 C']]
+
+
+discovery = {'': [(u'Bezeichnung Sensor 1', {})]}
+
+
+checks = {'': [(u'Bezeichnung Sensor 1',
+ 'default',
+ [(0, u'Sensor Bezeichnung Sensor 1, State normal', []),
+ (0, u'16.8 \xb0C', [('temp', 16.8, None, None, None,
None)])])]}