Browse Source

Initial commit of p1-metrics.py

Michael Honkoop 7 months ago
parent
commit
6d6b25d71a
1 changed files with 68 additions and 0 deletions
  1. 68 0
      p1-metrics.py

+ 68 - 0
p1-metrics.py

@@ -0,0 +1,68 @@
+#!/usr/bin/env python3
+#
+# This file is for combining metrics of a P1 Meter from https://www.homewizard.com/ in Checkmk (https://checkmk.com). 
+#
+
+from cmk.gui.i18n import _
+from cmk.gui.plugins.metrics.utils import graph_info, metric_info
+
+# .
+#   .--Metrics-------------------------------------------------------------.
+#   |                   __  __      _        _                             |
+#   |                  |  \/  | ___| |_ _ __(_) ___ ___                    |
+#   |                  | |\/| |/ _ \ __| '__| |/ __/ __|                   |
+#   |                  | |  | |  __/ |_| |  | | (__\__ \                   |
+#   |                  |_|  |_|\___|\__|_|  |_|\___|___/                   |
+#   |                                                                      |
+#   +----------------------------------------------------------------------+
+#   |  Definitions of metrics                                              |
+#   '----------------------------------------------------------------------'
+
+# Title are always lower case - except the first character!
+# Colors: See indexed_color() in cmk/gui/plugins/metrics/utils.py
+
+metric_info["active_power_w"] = {
+    "title": _("Total active power"),
+    "unit": "W",
+    "color": "31/a",
+}
+
+metric_info["active_power_l1_w"] = {
+    "title": _("Active power L1"),
+    "unit": "w",
+    "color": "#40a0b0",
+}
+
+metric_info["active_power_l2_w"] = {
+    "title": _("Active power L2"),
+    "unit": "w",
+    "color": "#ff6000",
+}
+
+metric_info["active_power_l3_w"] = {
+    "title": _("Active power L3"),
+    "unit": "w",
+    "color": "43/a",
+}
+
+# .
+#   .--Graphs--------------------------------------------------------------.
+#   |                    ____                 _                            |
+#   |                   / ___|_ __ __ _ _ __ | |__  ___                    |
+#   |                  | |  _| '__/ _` | '_ \| '_ \/ __|                   |
+#   |                  | |_| | | | (_| | |_) | | | \__ \                   |
+#   |                   \____|_|  \__,_| .__/|_| |_|___/                   |
+#   |                                  |_|                                 |
+#   +----------------------------------------------------------------------+
+#   |  Definitions of time series graphs                                   |
+#   '----------------------------------------------------------------------'
+
+graph_info["p1_power"] = {
+    "title": _l("P1 Power"),
+    "metrics": [
+        ("active_power_w", "stack"),
+        ("active_power_l1_w", "stack"),
+        ("active_power_l2_w", "stack"),
+        ("active_power_l3_w", "stack"),
+    ],
+}