Hi,
da ich nun schon eine Weile meine FHEM-Daten mit Graphite logge habe ich das Ganze mal in ein Modul verpackt.
Wer Graphite nicht kennt: Graphite ist eine Software, welche Daten entgegennimmt und diese dann in beliebigen Diagrammen darstellen kann. Wird z.B. oft verwendet um Serverstatistiken zu generieren. Das schöne dabei ist, dass es diverse Frontends gibt und man sich seine Reports und Diagramme schön zusammenklicken kann. Zugegriffen und geloggt wird über Netzwerk. D.h. der Graphite-Server kann getrennt von FHEM laufen. Mehr infos: http://graphiteapp.org/
Anbei noch ein Screenshot wie das aussieht.
Und hier die aktuelle Commandref:
GRAPHITE
- Provides the possibility to log stats via graphite:
Definedefine <name> GRAPHITE <graphite_server> <graphite_port> <send_interval>
Example:
define GRAPHITE graphite.example.com 2003 60
Set
- forceSend: will immediately send to graphite.
Attributes
- graphiteBasePath: The prefix path for the graphite namespace. This path will be in front of all logged values. Defaults to "fhem".
- graphiteIncludeRooms: Automatically include the rooms of the device into the graphite namespace. If a device is in multiple rooms this will log the value multiple times. Can be 0 or 1. Defaults to 0.
- graphiteIgnoreRooms: Comma separated list of rooms that will be ignored if graphiteIncludeRooms is used. Defaults to "";
- graphiteValueList: Comma separated list of value definitions. Basically a value definition consists of a colon separated list, where the first element is the device, the second element is the reading to log, the third element is the graphite namespace to use and the fourth element is a custom parser function. The graphite namespace can be empty and defaults to the device name plus the value to log. Also the custom parser function is normally optional as numeric values and on/off values are automatically parsed. You only need a custom method if you want to do something special. E.g. logging 1 for "day" and 0 for "night". Example: Bad.Thermostat_Climate:measured-temp:Temperatur.Ist,KM271:Brenner_Ansteuerung::GraphiteParseKessel
Additional information
- It is possible to create multiple graphite instance.
- The perl library Net::Graphite must be installed on the system.
Edit:
29.12.2016 - Neue Version 0.0.2
- Better error handling.
- Allow setting protocol and timeout.
Muss man dafür noch was installieren, auf dem pi oder so?
Von mobil gesendet daher kurze Antwort
Also für das Modul braucht man nur Net::Graphite.
Aber du brauchst natürlich einen Graphite-Server, der besteht aus dem Logging-Backend (Carbon), der Datenbank (Whisper) und einem Web-Frontend (mitgeliefert wird Graphite-Web). Das kann man alles auf einem Pi installieren. Das ist aber ziemlich langsam beim Diagramme rendern (ich weiss allerdings nicht wie das im Vergleich zu den FHEM-eigenen Plots ist, da ich die nie ausprobiert habe).
Bei mir ist es so, dass ich Graphite sowieso auf einem "echte" Server in einem Rechenzentrum für diverse Web-Server etc. betreibe, FHEM loggt dort einfach auch hin.
Gruss Frieder
Habe eine neue Version hinzugefügt, mit besserem Errorhandling und der Möglichkeit das Protokoll sowie den Timeout für Graphite einzustellen.
Neue Version hängt im ersten Post.
Gruss farion
Hallo Frieder,
klasse Modul. Hat auf anhieb funktioniert und ist bei mir nun fester Logging-Bestandteil!
VG Texel
Hallo nochmals,
bei mir kommt ein Fehler, dass die Routine Blocking nicht gefunden wird.
Lösung:
require 'Blocking.pm';
explizit angeben..
package main;
use strict;
use warnings;
use POSIX;
use Net::Graphite;
use Scalar::Util qw(looks_like_number);
require 'Blocking.pm';
VG Texel