--- /dev/null
+#!/usr/bin/env python3
+"""
+=head1 NAME
+
+mon_pc - Monitor meteocontrol weblog pro direktvermarkter interface limits
+
+=head1 CONFIGURATION
+
+Usage: place in /etc/munin/plugins/ or link it there
+
+Parameters understood:
+
+ config (required)
+
+=head1 AUTHORS
+
+Copyright 2022 Sven Hoexter <sven@stormbind.net>
+
+=head1 MAGIC MARKERS
+
+ #%# family=manual
+
+=cut
+"""
+
+import sys
+import os
+import xml.etree.ElementTree as ET
+import requests
+
+#initialize configuration env vars and set defaults
+host = os.environ.get('host', 'localhost')
+port = os.environ.get('port', '8888')
+req = os.environ.get(
+ 'req',
+ '/GetDmiValue.cgi?q=M_AC_P+PC_P_PERC_ABS+PC_P_PERC_GRIDOP+PC_P_PERC_DMI')
+
+
+def fetchDmi(host, port, req):
+ # download DMI XML data
+ try:
+ r = requests.get('http://' + host + ':' + port + req)
+ except requests.exceptions.RequestException as e:
+ raise SystemExit(e)
+
+ root = ET.fromstring(r.text)
+ for child in root:
+ print(
+ f"{child.attrib['name'].lower()}.value {int(float(child.attrib['value']))}"
+ )
+
+
+def main():
+ if len(sys.argv) > 1:
+ if sys.argv[1] == "config":
+ print("graph_title Wirkleistungsbegrenzung")
+ print("graph_vlabel %")
+ print("pc_p_perc_dmi.label Begrenzung Direktvermarkter")
+ print("pc_p_perc_gridop.label Begrenzung Netzbetreiber")
+ print("pc_p_perc_abs.label Begrenzung Absolut")
+ print("graph_args --base 1000 -r -u 100 -l 0")
+ print("graph_scale no")
+ print("graph yes")
+ print("graph_category pv")
+ print("graph_info Statistics from the Dmi Interface.")
+ sys.exit()
+
+ # no args
+ fetchDmi(host, port, req)
+
+
+main()