From d1d4d11a8d29f17dff15b039da6cacfd5db1a581 Mon Sep 17 00:00:00 2001 From: Stefan Pfab Date: Fri, 13 Mar 2009 15:49:02 +0100 Subject: [PATCH] contrib/collection3: Add "Wirkleistung" graph. --- contrib/collection3/etc/collection.conf | 8 ++ .../lib/Collectd/Graph/Type/Wirkleistung.pm | 90 ++++++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 contrib/collection3/lib/Collectd/Graph/Type/Wirkleistung.pm diff --git a/contrib/collection3/etc/collection.conf b/contrib/collection3/etc/collection.conf index 272ae68e..ec0124e5 100644 --- a/contrib/collection3/etc/collection.conf +++ b/contrib/collection3/etc/collection.conf @@ -514,4 +514,12 @@ GraphWidth 400 RRDFormat "%4.1lfV" Color value f00000 + + Module Wirkleistung + DataSources kWh + DSName value Wh + RRDTitle "Watt" + RRDVerticalLabel "W" + RRDFormat "%4.1lfW" + # vim: set sw=2 sts=2 et syntax=apache fileencoding=latin-1 : diff --git a/contrib/collection3/lib/Collectd/Graph/Type/Wirkleistung.pm b/contrib/collection3/lib/Collectd/Graph/Type/Wirkleistung.pm new file mode 100644 index 00000000..6d5234f8 --- /dev/null +++ b/contrib/collection3/lib/Collectd/Graph/Type/Wirkleistung.pm @@ -0,0 +1,90 @@ +package Collectd::Graph::Type::Wirkleistung; + +# Copyright (C) 2009 Stefan Pfab +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation; only version 2 of the License is applicable. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +use strict; +use warnings; +use base ('Collectd::Graph::Type'); + +use Collectd::Graph::Common (qw(ident_to_filename get_faded_color)); + +return (1); + +sub getDataSources +{ + return ([qw(wirkleistung)]); +} # getDataSources + +sub new +{ + my $pkg = shift; + my $obj = Collectd::Graph::Type->new (@_); + $obj->{'data_sources'} = [qw(wirkleistung)]; + $obj->{'rrd_opts'} = ['-v', 'Watt']; + $obj->{'rrd_title'} = 'Wirkleistung ({type_instance})'; + $obj->{'rrd_format'} = '%5.1lf%s W'; + $obj->{'colors'} = [qw(000000 f00000)]; + + return (bless ($obj, $pkg)); +} # new + +sub getRRDArgs +{ + my $obj = shift; + my $index = shift; + + my $ident = $obj->{'files'}[$index]; + if (!$ident) + { + cluck ("Invalid index: $index"); + return; + } + my $filename = ident_to_filename ($ident); + $filename =~ s#:#\\:#g; + + my $faded_green = get_faded_color ('00ff00'); + my $faded_red = get_faded_color ('ff0000'); + + return (['-t', 'Wirkleistung (' . $ident->{'type_instance'} . ')', '-v', 'Watt', '-l', '0', + "DEF:min0=${filename}:kWh:MIN", + "DEF:avg0=${filename}:kWh:AVERAGE", + "DEF:max0=${filename}:kWh:MAX", + 'AREA:max0#bfbfbf', + 'AREA:min0#FFFFFF', + 'CDEF:watt_avg0=avg0,36000,*,', + 'CDEF:watt_min0=min0,36000,*,', + 'CDEF:watt_max0=max0,36000,*,', + 'CDEF:watt_total=avg0,10,*,', + 'VDEF:total=watt_total,TOTAL', + 'VDEF:first=watt_total,FIRST', + 'VDEF:last=watt_total,LAST', + #'CDEF:first_value=first,POP', + #'CDEF:first_time=first,POP', + 'LINE1:watt_avg0#000000:W', + 'HRULE:190#ff0000', + 'GPRINT:watt_min0:MIN:%4.1lfW Min,', + 'GPRINT:watt_avg0:AVERAGE:%4.1lfW Avg,', + 'GPRINT:watt_max0:MAX:%4.1lfW Max,', + 'GPRINT:watt_avg0:LAST:%4.1lfW Last\l', + 'GPRINT:total:%4.1lf%sWh Gesamtverbrauch im angezeigten Zeitraum\l', + 'GPRINT:first:erster Wert %c:strftime', + 'GPRINT:last:letzter Wert %c:strftime']); + + # HRULE:190\ ff0000 + +} # getRRDArgs + +# vim: set shiftwidth=2 softtabstop=2 tabstop=8 : -- 2.11.0