From 4c7e197ebb775870ba350171dac91ce99d7d1b0a Mon Sep 17 00:00:00 2001 From: Robert Sander Date: Sun, 13 Nov 2022 00:15:11 +0100 Subject: [PATCH 1/3] renamed to package name --- .../mkp/_agent_based/co2welectronic.py | 0 .../mkp/_web/plugins/wato/co2welectronic_parameters.py | 0 mkp/{watterott_co2_ampel => watterott_CO2_ampel}/mkp/info | 0 mkp/{watterott_co2_ampel => watterott_CO2_ampel}/mkp/info.json | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename mkp/{watterott_co2_ampel => watterott_CO2_ampel}/mkp/_agent_based/co2welectronic.py (100%) rename mkp/{watterott_co2_ampel => watterott_CO2_ampel}/mkp/_web/plugins/wato/co2welectronic_parameters.py (100%) rename mkp/{watterott_co2_ampel => watterott_CO2_ampel}/mkp/info (100%) rename mkp/{watterott_co2_ampel => watterott_CO2_ampel}/mkp/info.json (100%) diff --git a/mkp/watterott_co2_ampel/mkp/_agent_based/co2welectronic.py b/mkp/watterott_CO2_ampel/mkp/_agent_based/co2welectronic.py similarity index 100% rename from mkp/watterott_co2_ampel/mkp/_agent_based/co2welectronic.py rename to mkp/watterott_CO2_ampel/mkp/_agent_based/co2welectronic.py diff --git a/mkp/watterott_co2_ampel/mkp/_web/plugins/wato/co2welectronic_parameters.py b/mkp/watterott_CO2_ampel/mkp/_web/plugins/wato/co2welectronic_parameters.py similarity index 100% rename from mkp/watterott_co2_ampel/mkp/_web/plugins/wato/co2welectronic_parameters.py rename to mkp/watterott_CO2_ampel/mkp/_web/plugins/wato/co2welectronic_parameters.py diff --git a/mkp/watterott_co2_ampel/mkp/info b/mkp/watterott_CO2_ampel/mkp/info similarity index 100% rename from mkp/watterott_co2_ampel/mkp/info rename to mkp/watterott_CO2_ampel/mkp/info diff --git a/mkp/watterott_co2_ampel/mkp/info.json b/mkp/watterott_CO2_ampel/mkp/info.json similarity index 100% rename from mkp/watterott_co2_ampel/mkp/info.json rename to mkp/watterott_CO2_ampel/mkp/info.json From 0d6fd6aa20a307c3adf55238f29983af67316326 Mon Sep 17 00:00:00 2001 From: Robert Sander Date: Sun, 13 Nov 2022 00:19:27 +0100 Subject: [PATCH 2/3] rewrites the check plugin uses check function from .util and known metric names --- mkp/watterott_CO2_ampel/info | 37 ++++ mkp/watterott_CO2_ampel/info.json | 1 + .../plugins/agent_based/co2welectronic.py | 177 ++++++++++++++++++ .../watterott_CO2_ampel-0.2.mkp | Bin 0 -> 3542 bytes .../web/plugins/metrics/co2welectronic.py | 23 +++ .../plugins/wato/co2welectronic_parameters.py | 62 ++++++ 6 files changed, 300 insertions(+) create mode 100644 mkp/watterott_CO2_ampel/info create mode 100644 mkp/watterott_CO2_ampel/info.json create mode 100644 mkp/watterott_CO2_ampel/lib/check_mk/base/plugins/agent_based/co2welectronic.py create mode 100644 mkp/watterott_CO2_ampel/watterott_CO2_ampel-0.2.mkp create mode 100644 mkp/watterott_CO2_ampel/web/plugins/metrics/co2welectronic.py create mode 100644 mkp/watterott_CO2_ampel/web/plugins/wato/co2welectronic_parameters.py diff --git a/mkp/watterott_CO2_ampel/info b/mkp/watterott_CO2_ampel/info new file mode 100644 index 0000000..12273a6 --- /dev/null +++ b/mkp/watterott_CO2_ampel/info @@ -0,0 +1,37 @@ +{'author': 'Mattias Schlenker ', + 'description': 'Background: The Watterott CO2 Ampel ("CO2 traffic light") is ' + 'a networkble sensor board, primarily made for monitoring CO2, ' + 'but includes other sensors as temperature and humidity as ' + 'well. It is open hardware and uses an open source firmware. ' + 'https://learn.watterott.com/breakouts/co2-ampel/ \n' + '\n' + 'The factory firmware includes a simple Checkmk agent via ' + 'HTTP/REST-API: http://12.34.56.78/cmk-agent\n' + '\n' + 'Since the agent is only available via HTTP, the monitoring ' + 'has to be configured using "individual program call instead ' + 'of agent access", see\n' + '\n' + 'https://docs.checkmk.com/latest/en/datasource_programs.html\n' + '\n' + 'The output includes one local check that creates a service ' + 'immediately after discovery. However this takes thresholds ' + 'from the EPROM of the boards which makes central ' + 'administration difficult. This plugin adds discovery for all ' + 'other sensors. Since different versions of the board have ' + 'differect sensors, individual discovery is needed.\n' + '\n' + 'German users: See ASR3.5 and ASR3.6 (Germany) for thresholds ' + 'on CO2/temperature/humidity in working environments. Only CO2 ' + 'is quite fixed at 1000ppm. If no quick exchange of air is ' + 'possible, lower thresholds from 1000/1200 to 900/1000.\n', + 'download_url': 'https://github.com/mschlenker/checkmk-snippets/', + 'files': {'agent_based': ['co2welectronic.py'], + 'web': ['plugins/wato/co2welectronic_parameters.py', + 'plugins/metrics/co2welectronic.py']}, + 'name': 'watterott_CO2_ampel', + 'title': 'Watterott CO2 Ampel', + 'version': '0.2', + 'version.min_required': '2.1.0', + 'version.packaged': '2.1.0p16', + 'version.usable_until': '2.2.999'} diff --git a/mkp/watterott_CO2_ampel/info.json b/mkp/watterott_CO2_ampel/info.json new file mode 100644 index 0000000..84b9e5e --- /dev/null +++ b/mkp/watterott_CO2_ampel/info.json @@ -0,0 +1 @@ +{"author": "Mattias Schlenker ", "description": "Background: The Watterott CO2 Ampel (\"CO2 traffic light\") is a networkble sensor board, primarily made for monitoring CO2, but includes other sensors as temperature and humidity as well. It is open hardware and uses an open source firmware. https://learn.watterott.com/breakouts/co2-ampel/ \n\nThe factory firmware includes a simple Checkmk agent via HTTP/REST-API: http://12.34.56.78/cmk-agent\n\nSince the agent is only available via HTTP, the monitoring has to be configured using \"individual program call instead of agent access\", see\n\nhttps://docs.checkmk.com/latest/en/datasource_programs.html\n\nThe output includes one local check that creates a service immediately after discovery. However this takes thresholds from the EPROM of the boards which makes central administration difficult. This plugin adds discovery for all other sensors. Since different versions of the board have differect sensors, individual discovery is needed.\n\nGerman users: See ASR3.5 and ASR3.6 (Germany) for thresholds on CO2/temperature/humidity in working environments. Only CO2 is quite fixed at 1000ppm. If no quick exchange of air is possible, lower thresholds from 1000/1200 to 900/1000.\n", "download_url": "https://github.com/mschlenker/checkmk-snippets/", "files": {"agent_based": ["co2welectronic.py"], "web": ["plugins/wato/co2welectronic_parameters.py", "plugins/metrics/co2welectronic.py"]}, "name": "watterott_CO2_ampel", "title": "Watterott CO2 Ampel", "version": "0.2", "version.min_required": "2.1.0", "version.packaged": "2.1.0p16", "version.usable_until": "2.2.999"} \ No newline at end of file diff --git a/mkp/watterott_CO2_ampel/lib/check_mk/base/plugins/agent_based/co2welectronic.py b/mkp/watterott_CO2_ampel/lib/check_mk/base/plugins/agent_based/co2welectronic.py new file mode 100644 index 0000000..1c3a932 --- /dev/null +++ b/mkp/watterott_CO2_ampel/lib/check_mk/base/plugins/agent_based/co2welectronic.py @@ -0,0 +1,177 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# © 2022 Mattias Schlenker for tribe29 GmbH +# +# Background: The Watterott CO2 Ampel ("CO2 traffic light") is a networkabale +# sensor board, primarily made for monitoring CO2. It is open hardware and uses +# an open source firmware. +# +# https://learn.watterott.com/breakouts/co2-ampel/ +# +# The factory firmware includes a simple Checkmk agent via HTTP/REST-API: +# +# http://12.34.56.78/cmk-agent +# +# <<>> +# AgentOS: arduino +# <<>> +# co2 521 +# temp 19.3 +# humidity 51.8 +# lighting 976 +# temp2 19.4 +# pressure 1022.0 +# <<>> +# P "CO2 level (ppm)" co2ppm=521;1000;1200 CO2/ventilation control with Watterott CO2-Ampel, thresholds taken from sensor board. +# +# Since the agent is only available via HTTP, the monitoring has to be configured +# using "individual program call instead of agent access", see +# +# https://docs.checkmk.com/latest/en/datasource_programs.html +# +# The result looks like: +# +# curl http://$_HOSTADDRESS_4$/cmk-agent +# +# The local check creates a service immediately after discovery. However this +# takes thresholds from the EPROM of the boards which makes central administration +# difficult. This plugin adds discovery for all other sensors. Since different +# versions of the board have differect sensors, individual discovery is needed. +# +# See ASR3.5 and ASR3.6 (Germany) for thresholds on CO2/temperature/humidity in +# working environments. Only CO2 is quite fixed at 1000ppm. If no quick exchange +# of air is possible, lower thresholds from 1000/1200 to 900/1000. + +from .agent_based_api.v1 import * +from .agent_based_api.v1.type_defs import CheckResult, DiscoveryResult, StringTable +from .utils.temperature import check_temperature +from .utils.humidity import check_humidity + +def parse_co2ampel(string_table: StringTable): + parsed = {} + + for key, value in string_table: + try: + parsed[key] = int(value) + except ValueError: + parsed[key] = float(value) + + if key == "pressure": + parsed[key] *= 100 + if key == "lighting": + parsed[key] = parsed[key] * 100.0 / 1024.0 + + return parsed + +register.agent_section( + name="watterott_co2ampel_plugin", + parse_function=parse_co2ampel, +) + +def discover_co2ampel_temp(section) -> DiscoveryResult: + for key in section: + if key.startswith("temp"): + yield Service(item=key) + +def check_co2ampel_temp(item, params, section) -> CheckResult: + if item in section: + yield from check_temperature( + reading = section[item], + params = params, + unique_name = item, + value_store = get_value_store(), + ) + +register.check_plugin( + name="watterott_co2ampel_temp", + sections=["watterott_co2ampel_plugin"], + service_name="Temperature %s", + discovery_function=discover_co2ampel_temp, + check_function=check_co2ampel_temp, + check_ruleset_name="temperature", + check_default_parameters={ + "levels" : (23.0, 26.0), + "levels_lower" : (17.0, 13.0), + }, +) + +def discover_co2ampel_humidity(section) -> DiscoveryResult: + if "humidity" in section: + yield Service(item="Humidity") + +def check_co2ampel_humidity(item, params, section) -> CheckResult: + if "humidity" in section: + yield from check_humidity(section["humidity"], params) + +register.check_plugin( + name="watterott_co2ampel_humidity", + sections=["watterott_co2ampel_plugin"], + service_name="%s", + discovery_function=discover_co2ampel_humidity, + check_function=check_co2ampel_humidity, + check_ruleset_name="humidity", + check_default_parameters={ + "levels" : (60.0, 65.0), + "levels_lower" : (35.0, 30.0), + }, +) + +def discover_co2ampel_co2(section) -> DiscoveryResult: + if "co2" in section: + yield Service() + +def check_co2ampel_co2(params, section) -> CheckResult: + if "co2" in section: + value = section["co2"] + levels = params["levels"] + yield Metric(name="co2ppm", + value=value, + levels=levels) + if value > levels[1]: + yield Result(state=State.CRIT, + summary=f"CO₂ level is too high at {value}ppm") + elif value > levels[0]: + yield Result(state=State.WARN, + summary=f"CO₂ level is slightly too high at {value}ppm") + else: + yield Result(state=State.OK, summary=f"CO₂ level is acceptable at {value}ppm") + +register.check_plugin( + name="watterott_co2ampel_co2", + sections=["watterott_co2ampel_plugin"], + service_name="CO₂ level", + discovery_function=discover_co2ampel_co2, + check_function=check_co2ampel_co2, + check_ruleset_name="watterott_co2ampel_plugin", + check_default_parameters={ + "levels" : (1000, 1200), + }, +) + +def discover_co2ampel_sensors(section) -> DiscoveryResult: + for key in section: + if key in ["humidity", "co2"]: + continue + if key.startswith("temp"): + continue + yield Service(item=key) + +def check_co2ampel_sensors(item, section) -> CheckResult: + if item in section: + value = section[item] + yield Metric(name=item, + value=value) + if item == "pressure": + value = "%0.2fhPa" % (value / 100.0) + if item == "lighting": + value = "%0.1f%%" % value + yield Result(state=State.OK, summary=f"Sensor info: {value}") + +register.check_plugin( + name="watterott_co2ampel_sensors", + sections=["watterott_co2ampel_plugin"], + service_name="Sensor %s", + discovery_function=discover_co2ampel_sensors, + check_function=check_co2ampel_sensors, +) diff --git a/mkp/watterott_CO2_ampel/watterott_CO2_ampel-0.2.mkp b/mkp/watterott_CO2_ampel/watterott_CO2_ampel-0.2.mkp new file mode 100644 index 0000000000000000000000000000000000000000..3bbf1494cae33028c569950d81dc30acf8fb9345 GIT binary patch literal 3542 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 Date: Tue, 22 Nov 2022 09:24:06 +0100 Subject: [PATCH 3/3] removes old code --- .../mkp/_agent_based/co2welectronic.py | 133 ------------------ .../plugins/wato/co2welectronic_parameters.py | 114 --------------- mkp/watterott_CO2_ampel/mkp/info | 36 ----- mkp/watterott_CO2_ampel/mkp/info.json | 1 - 4 files changed, 284 deletions(-) delete mode 100644 mkp/watterott_CO2_ampel/mkp/_agent_based/co2welectronic.py delete mode 100644 mkp/watterott_CO2_ampel/mkp/_web/plugins/wato/co2welectronic_parameters.py delete mode 100644 mkp/watterott_CO2_ampel/mkp/info delete mode 100644 mkp/watterott_CO2_ampel/mkp/info.json diff --git a/mkp/watterott_CO2_ampel/mkp/_agent_based/co2welectronic.py b/mkp/watterott_CO2_ampel/mkp/_agent_based/co2welectronic.py deleted file mode 100644 index 0ed0638..0000000 --- a/mkp/watterott_CO2_ampel/mkp/_agent_based/co2welectronic.py +++ /dev/null @@ -1,133 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -# -# © 2022 Mattias Schlenker for tribe29 GmbH -# -# Background: The Watterott CO2 Ampel ("CO2 traffic light") is a networkabale -# sensor board, primarily made for monitoring CO2. It is open hardware and uses -# an open source firmware. -# -# https://learn.watterott.com/breakouts/co2-ampel/ -# -# The factory firmware includes a simple Checkmk agent via HTTP/REST-API: -# -# http://12.34.56.78/cmk-agent -# -# <<>> -# AgentOS: arduino -# <<>> -# co2 521 -# temp 19.3 -# humidity 51.8 -# lighting 976 -# temp2 19.4 -# pressure 1022.0 -# <<>> -# P "CO2 level (ppm)" co2ppm=521;1000;1200 CO2/ventilation control with Watterott CO2-Ampel, thresholds taken from sensor board. -# -# Since the agent is only available via HTTP, the monitoring has to be configured -# using "individual program call instead of agent access", see -# -# https://docs.checkmk.com/latest/en/datasource_programs.html -# -# The result looks like: -# -# curl http://$_HOSTADDRESS_4$/cmk-agent -# -# The local check creates a service immediately after discovery. However this -# takes thresholds from the EPROM of the boards which makes central administration -# difficult. This plugin adds discovery for all other sensors. Since different -# versions of the board have differect sensors, individual discovery is needed. -# -# See ASR3.5 and ASR3.6 (Germany) for thresholds on CO2/temperature/humidity in -# working environments. Only CO2 is quite fixed at 1000ppm. If no quick exchange -# of air is possible, lower thresholds from 1000/1200 to 900/1000. - -from .agent_based_api.v1 import * - -def discover_co2_level(section): - for key, _value in section: - yield Service(item=key) - -def check_co2_level(item, params, section): - for key, value in section: - # The Sensirion CO2 sensor - if key == "co2" and key == item: - yield Metric(name="co2", value=int(value), boundaries=(0, 10000), levels=params["co2"]) - if int(value) > params["co2"][1]: - yield Result(state=State.CRIT, summary=f"CO2 level is too high at {value}ppm (threshold from plugin)") - return - elif int(value) > params["co2"][0]: - yield Result(state=State.WARN, summary=f"CO2 level is slightly too high at {value}ppm (threshold from plugin)") - return - yield Result(state=State.OK, summary=f"CO2 level is acceptable at {value}ppm (threshold from plugin)") - # Temperature senosr on the Sensirion - elif key == "temp" and key == item: - yield Metric(name="temp", value=float(value), boundaries=(-20.0, 80.0), levels=params["temp_upper"]) - if float(value) > params["temp_upper"][1]: - yield Result(state=State.CRIT, summary=f"Temperature is too high at {value}°C (threshold from plugin)") - return - elif float(value) > params["temp_upper"][0]: - yield Result(state=State.WARN, summary=f"Temperature is slightly too high at {value}°C (threshold from plugin)") - return - elif float(value) < params["temp_lower"][1]: - yield Result(state=State.CRIT, summary=f"Temperature is too low at {value}°C (threshold from plugin)") - return - elif float(value) < params["temp_lower"][0]: - yield Result(state=State.WARN, summary=f"Temperature is slightly too low at {value}°C (threshold from plugin)") - return - yield Result(state=State.OK, summary=f"Temperature is acceptable at {value}°C (threshold from plugin)") - # Boards with pressure sensors have a second temperature sensor as part of the pressure sensor - elif key == "temp2" and key == item: - yield Metric(name="temp_2", value=float(value), boundaries=(-20.0, 80.0), levels=params["temp_upper"]) - if float(value) > params["temp_upper"][1]: - yield Result(state=State.CRIT, summary=f"Temperature (sensor 2) is too high at {value}°C (threshold from plugin)") - return - elif float(value) > params["temp_upper"][0]: - yield Result(state=State.WARN, summary=f"Temperature (sensor 2) is slightly too high at {value}°C (threshold from plugin)") - return - elif float(value) < params["temp_lower"][1]: - yield Result(state=State.CRIT, summary=f"Temperature (sensor 2) is too low at {value}°C (threshold from plugin)") - return - elif float(value) < params["temp_lower"][0]: - yield Result(state=State.WARN, summary=f"Temperature (sensor 2) is slightly too low at {value}°C (threshold from plugin)") - return - yield Result(state=State.OK, summary=f"Temperature (sensor 2) is acceptable at {value}°C (threshold from plugin)") - # The humidity sensor - elif key == "humidity" and key == item: - yield Metric(name="humidity", value=float(value), levels=params["humidity_upper"]) - if float(value) > params["humidity_upper"][1]: - yield Result(state=State.CRIT, summary="Humidity is too humid at " + value + "% (threshold from plugin)") - return - elif float(value) > params["humidity_upper"][0]: - yield Result(state=State.WARN, summary="Humidity is slightly too humid at " + value + "% (threshold from plugin)") - return - elif float(value) < params["humidity_lower"][1]: - yield Result(state=State.CRIT, summary="Humidity is too dry at " + value + "% (threshold from plugin)") - return - elif float(value) < params["humidity_lower"][0]: - yield Result(state=State.CRIT, summary="Humidity is slightly too dry at " + value + "% (threshold from plugin)") - return - yield Result(state=State.OK, summary="Humidity is acceptable at " + value + "°C (threshold from plugin)") - # For ambient lighting and pressure (if available) we just create services that are always OK - elif key == item: - yield Metric(name=key, value=float(value)) - yield Result(state=State.OK, summary="Sensor " + key + " value " + value + " for informational purpose only, always OK") - -register.check_plugin( - name = "watterott_co2ampel_plugin", - service_name = "CO2 board %s", - discovery_function = discover_co2_level, - check_function = check_co2_level, - check_ruleset_name = "watterott_co2ampel_plugin", - # Define some thresholds, the CO2 values are taken according German Arbeitsstättenrichtlinie ASR3.6 - # Change temperatures for the respective work environmen, see ASR A3.5 - check_default_parameters = { - "co2" : (1000, 1200), - "temp_upper" : (23.0, 26.0), - "temp_lower" : (17.0, 13.0), - "humidity_upper" : (60.0, 65.0), - "humidity_lower" : (35.0, 30.0) - } -) - diff --git a/mkp/watterott_CO2_ampel/mkp/_web/plugins/wato/co2welectronic_parameters.py b/mkp/watterott_CO2_ampel/mkp/_web/plugins/wato/co2welectronic_parameters.py deleted file mode 100644 index c7b5f22..0000000 --- a/mkp/watterott_CO2_ampel/mkp/_web/plugins/wato/co2welectronic_parameters.py +++ /dev/null @@ -1,114 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -# -# © 2022 Mattias Schlenker for tribe29 GmbH -# -# Background: The Watterott CO2 Ampel ("CO2 traffic light") is a networkabale -# sensor board, primarily made for monitoring CO2. It is open hardware and uses -# an open source firmware. -# -# This GUI plugin creates the inputs for setting thresholds. Remember: -# -# 1. Both temperature sensors (if present) use the same thresholds (use -# the most precise one if they are running apart) -# 2. For temperature and humidity corridors can be applied, the graphing -# system however only accepts upper boundaries -# 3. Currently no thresholds for atmospheric pressure and ambient lighting -# are used - -from cmk.gui.valuespec import ( - Dictionary, - Tuple, - Percentage, - Integer, - Float, -) -from cmk.gui.plugins.wato import ( - CheckParameterRulespecWithoutItem, - rulespec_registry, - RulespecGroupCheckParametersApplications, - RulespecGroupCheckParametersEnvironment, -) - -def _parameter_valuespec_co2_levels(): - return Dictionary( - elements=[ - ("co2", Tuple( - title=_("CO2 levels"), - elements=[ - Integer( - title=_("Warning above"), - default_value=1000, - ), - Integer( - title=_("Critical above"), - default_value=1200, - ), - ], - )), - ("temp_upper", Tuple( - title=_("Temperature upper"), - elements=[ - Float( - title=_("Warning above"), - default_value=23.0, - ), - Float( - title=_("Critical above"), - default_value=26.0, - ), - ], - )), - ("temp_lower", Tuple( - title=_("Temperature lower"), - elements=[ - Float( - title=_("Warning below"), - default_value=17.0, - ), - Float( - title=_("Critical below"), - default_value=13.0, - ), - ], - )), - ("humidity_upper", Tuple( - title=_("Humidity upper"), - elements=[ - Percentage( - title=_("Warning above"), - default_value=60.0, - ), - Percentage( - title=_("Critical above"), - default_value=65.0, - ), - ], - )), - ("humidity_lower", Tuple( - title=_("Humidity lower"), - elements=[ - Percentage( - title=_("Warning below"), - default_value=35.0, - ), - Percentage( - title=_("Critical below"), - default_value=30.0, - ), - ], - )) - ], - ) - -rulespec_registry.register( - CheckParameterRulespecWithoutItem( - # as defined in your check in share/check_mk/checks/ - check_group_name = "watterott_co2ampel_plugin", - group = RulespecGroupCheckParametersEnvironment, - match_type = "dict", - # the function above to issue default parameters - parameter_valuespec = _parameter_valuespec_co2_levels, - title=lambda: _("Sensor levels from Watterott CO2 traffic light"), - )) - diff --git a/mkp/watterott_CO2_ampel/mkp/info b/mkp/watterott_CO2_ampel/mkp/info deleted file mode 100644 index 1432065..0000000 --- a/mkp/watterott_CO2_ampel/mkp/info +++ /dev/null @@ -1,36 +0,0 @@ -{'author': 'Mattias Schlenker ', - 'description': 'Background: The Watterott CO2 Ampel ("CO2 traffic light") is ' - 'a networkble sensor board, primarily made for monitoring CO2, ' - 'but includes other sensors as temperature and humidity as ' - 'well. It is open hardware and uses an open source firmware. ' - 'https://learn.watterott.com/breakouts/co2-ampel/ \n' - '\n' - 'The factory firmware includes a simple Checkmk agent via ' - 'HTTP/REST-API: http://12.34.56.78/cmk-agent\n' - '\n' - 'Since the agent is only available via HTTP, the monitoring ' - 'has to be configured using "individual program call instead ' - 'of agent access", see\n' - '\n' - 'https://docs.checkmk.com/latest/en/datasource_programs.html\n' - '\n' - 'The output includes one local check that creates a service ' - 'immediately after discovery. However this takes thresholds ' - 'from the EPROM of the boards which makes central ' - 'administration difficult. This plugin adds discovery for all ' - 'other sensors. Since different versions of the board have ' - 'differect sensors, individual discovery is needed.\n' - '\n' - 'German users: See ASR3.5 and ASR3.6 (Germany) for thresholds ' - 'on CO2/temperature/humidity in working environments. Only CO2 ' - 'is quite fixed at 1000ppm. If no quick exchange of air is ' - 'possible, lower thresholds from 1000/1200 to 900/1000.\n', - 'download_url': 'https://github.com/mschlenker/checkmk-snippets/', - 'files': {'agent_based': ['co2welectronic.py'], - 'web': ['plugins/wato/co2welectronic_parameters.py']}, - 'name': 'watterott_CO2_ampel', - 'title': 'Watterott CO2 Ampel', - 'version': '0.1.2', - 'version.min_required': '2.1.0', - 'version.packaged': '2.1.0p12', - 'version.usable_until': '2.2.999'} \ No newline at end of file diff --git a/mkp/watterott_CO2_ampel/mkp/info.json b/mkp/watterott_CO2_ampel/mkp/info.json deleted file mode 100644 index d79c992..0000000 --- a/mkp/watterott_CO2_ampel/mkp/info.json +++ /dev/null @@ -1 +0,0 @@ -{"author": "Mattias Schlenker ", "description": "Background: The Watterott CO2 Ampel (\"CO2 traffic light\") is a networkble sensor board, primarily made for monitoring CO2, but includes other sensors as temperature and humidity as well. It is open hardware and uses an open source firmware. https:\/\/learn.watterott.com\/breakouts\/co2-ampel\/ \n\nThe factory firmware includes a simple Checkmk agent via HTTP\/REST-API: http:\/\/12.34.56.78\/cmk-agent\n\nSince the agent is only available via HTTP, the monitoring has to be configured using \"individual program call instead of agent access\", see\n\nhttps:\/\/docs.checkmk.com\/latest\/en\/datasource_programs.html\n\nThe output includes one local check that creates a service immediately after discovery. However this takes thresholds from the EPROM of the boards which makes central administration difficult. This plugin adds discovery for all other sensors. Since different versions of the board have differect sensors, individual discovery is needed.\n\nGerman users: See ASR3.5 and ASR3.6 (Germany) for thresholds on CO2\/temperature\/humidity in working environments. Only CO2 is quite fixed at 1000ppm. If no quick exchange of air is possible, lower thresholds from 1000\/1200 to 900\/1000.\n", "download_url": "https:\/\/github.com\/mschlenker\/checkmk-snippets\/", "files": {"agent_based": ["co2welectronic.py"], "web": ["plugins\/wato\/co2welectronic_parameters.py"]}, "name": "watterott_CO2_ampel", "title": "Watterott CO2 Ampel", "version": "0.1.2", "version.min_required": "2.1.0", "version.packaged": "2.1.0p12", "version.usable_until": "2.2.999"} \ No newline at end of file