aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2013-08-28 10:01:28 +0200
committerGuido Günther <agx@sigxcpu.org>2013-08-29 13:29:53 +0200
commit1834dd5a15852a653efdacc8c18431976b294c09 (patch)
tree8bfbb31ecdc9830f25a611832604fb7360638712
Initial commit
-rw-r--r--README23
-rwxr-xr-xpellematic-temp149
2 files changed, 172 insertions, 0 deletions
diff --git a/README b/README
new file mode 100644
index 0000000..6110148
--- /dev/null
+++ b/README
@@ -0,0 +1,23 @@
+This is a simple munin plugin to monitor the values of a Ökofen Pellematic with
+a Pelletronic Touch Online.
+
+It's currently very limited as it doesnt' determine the attached Pellematics or
+heating circuits but fetches a hard coded list of items.
+
+To setup the plugin copy it to /etc/munin/plugins and set the address of your
+Pellematic:::
+
+ cat <<EOF > /etc/munin/plugin-conf.d/pellematic
+ [pellematic-*]
+ env.address 192.168.0.5
+ env.username foo
+ env.password bar
+
+Then test it via:
+
+ munin-run pellematic-temp
+
+You should now see the temperature values printed on stdout. If this works restart your
+munin node:
+
+ service munin-node restart
diff --git a/pellematic-temp b/pellematic-temp
new file mode 100755
index 0000000..8fe25c5
--- /dev/null
+++ b/pellematic-temp
@@ -0,0 +1,149 @@
+#!/usr/bin/python
+# vim: set fileencoding=utf-8 :
+#
+# Munin plugin to monitor the temperature values
+# of a pelletronic/pelletronic touch 2.0
+#
+# Copyright 2013 Guido Guenther <agx@sigxcpu.org>
+#
+# Licesnse: GPLv3
+#
+# depends: python-requests
+#
+# FIXME: This currently doesn't probe the connected systems
+#
+#%# capabilities=autoconf
+#%# family=contrib
+
+import requests
+import os
+import re
+import sys
+import json
+
+username = os.getenv('username', 'oekofen')
+password = os.getenv('password', username)
+debug = os.getenv('debug')
+
+# The items we want to plot:
+items = [# Outside temperature sensor (X2)
+ "CAPPL:LOCAL.L_aussentemperatur_ist",
+ # 1. Pelletronic
+ "CAPPL:FA[0].L_kesseltemperatur",
+ "CAPPL:FA[0].L_kesseltemperatur_soll_anzeige",
+ #"CAPPL:FA[0].L_feuerraumtemperatur",
+ #"CAPPL:FA[0].L_feuerraumtemperatur_soll",
+ # 1. Buffer
+ # TPO (X7)
+ "CAPPL:LOCAL.L_pu[0].ausschaltfuehler_ist",
+ "CAPPL:LOCAL.L_pu[0].ausschaltfuehler_soll",
+ # TPM (X8)
+ "CAPPL:LOCAL.L_pu[0].einschaltfuehler_ist",
+ "CAPPL:LOCAL.L_pu[0].einschaltfuehler_soll",
+ # 1. Heating circuit
+ # VL1 (X4)
+ "CAPPL:LOCAL.L_hk[0].vorlauftemp_ist",
+ ]
+
+def canon(name):
+ return re.sub(r"[^a-zA-Z0-9_]", "_", name)
+
+def print_config(url):
+ print """graph_title Pellematic Temperature values
+graph_vlabel Temperature in Degree Celsius
+graph_category Heating
+graph_info This graph shows different temperture values as displayed by a Pelletronic Touch 2.0 by Ökofen"""
+
+ out = fetch_raw(url)
+ for item in out:
+ if item['name'] in items:
+ name = item['shortText']
+ print "%s.label %s" % (canon(name), name)
+ print "%s.type GAUGE" % canon(name)
+ thickness = 1 if item['name'].endswith('soll') else 2
+ print "%s.draw LINE%d" % (canon(name), thickness)
+
+def degree_celsius(val):
+ return float(int(val['value'])) / float(val['divisor'])
+
+def fetch_raw(url):
+ # Perform authentication and get the cookie
+ auth_formdata = {'language': 'en',
+ 'username': username,
+ 'password': password,
+ 'submit': 'Login',
+ }
+ r = requests.post(url, data=auth_formdata)
+
+ pksession = r.cookies['pksession']
+ cookies = { 'pksession': pksession,
+ 'language': 'en' }
+ params = { 'action': 'get',
+ 'attr': '1',
+ }
+
+ # These are the headers used by the supplied application
+ # It mostly doesn't matter what we pass but the backend
+ # breaks with a lua error without a Accept-Language header:
+ headers = {'Accept': 'application/json',
+ 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
+ 'Accept-Language': 'en',
+ }
+
+ # The items to fetch are passed as simple json string
+ payload = json.dumps(items)
+ r = requests.post(url,
+ data=payload,
+ params=params,
+ cookies=cookies,
+ headers=headers)
+
+ if hasattr(r.json, '__call__'):
+ ret = r.json()
+ else: # in requests 0.12 json isn't a callable
+ ret = r.json
+
+ if debug:
+ print >>sys.stderr, ret
+
+ return ret
+
+def fetch_values(url):
+ out = fetch_raw(url)
+ for item in out:
+ if item['name'] in items:
+ print "%s.value %.2f" % (canon(item['shortText']),
+ degree_celsius(item))
+
+
+def main(args):
+ target = os.getenv('address')
+ if not target:
+ print >>sys.stderr, "No ip address configured"
+ return 1
+ url = 'http://%s' % target
+ if len(args) > 1:
+ if args[1] in [ 'autoconf', 'detect' ]:
+ try:
+ fetch_raw(url)
+ print "yes"
+ return 0
+ except:
+ print "no"
+ return 1
+ elif args[1] == 'config':
+ try:
+ print_config(url)
+ except Exception as e:
+ print >>sys.stderr, "Failed to fetch config: '%s'" % e
+ return 1
+ return 0
+ try:
+ fetch_values(url)
+ except Exception as e:
+ print >>sys.stderr, "Failed to fetch values: '%s'" % e
+ return 1
+ return 0
+
+if __name__ == "__main__":
+ sys.exit(main(sys.argv))