1 package Collectd::Graph::Type::Wirkleistung;
3 # Copyright (C) 2009 Stefan Pfab <spfab at noris.net>
5 # This program is free software; you can redistribute it and/or modify it under
6 # the terms of the GNU General Public License as published by the Free Software
7 # Foundation; only version 2 of the License is applicable.
9 # This program is distributed in the hope that it will be useful, but WITHOUT
10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 # You should have received a copy of the GNU General Public License along with
15 # this program; if not, write to the Free Software Foundation, Inc.,
16 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 use base ('Collectd::Graph::Type');
22 use Collectd::Graph::Common (qw(ident_to_filename get_faded_color));
28 return ([qw(wirkleistung)]);
34 my $obj = Collectd::Graph::Type->new (@_);
35 $obj->{'data_sources'} = [qw(wirkleistung)];
36 $obj->{'rrd_opts'} = ['-v', 'Watt'];
37 $obj->{'rrd_title'} = 'Wirkleistung ({type_instance})';
38 $obj->{'rrd_format'} = '%5.1lf%s W';
39 $obj->{'colors'} = [qw(000000 f00000)];
41 return (bless ($obj, $pkg));
49 my $ident = $obj->{'files'}[$index];
52 cluck ("Invalid index: $index");
55 my $filename = ident_to_filename ($ident);
56 $filename =~ s#:#\\:#g;
58 my $faded_green = get_faded_color ('00ff00');
59 my $faded_red = get_faded_color ('ff0000');
61 return (['-t', 'Wirkleistung (' . $ident->{'type_instance'} . ')', '-v', 'Watt', '-l', '0',
62 "DEF:min0=${filename}:kWh:MIN",
63 "DEF:avg0=${filename}:kWh:AVERAGE",
64 "DEF:max0=${filename}:kWh:MAX",
67 'CDEF:watt_avg0=avg0,36000,*,',
68 'CDEF:watt_min0=min0,36000,*,',
69 'CDEF:watt_max0=max0,36000,*,',
70 'CDEF:watt_total=avg0,10,*,',
71 'VDEF:total=watt_total,TOTAL',
72 'VDEF:first=watt_total,FIRST',
73 'VDEF:last=watt_total,LAST',
74 #'CDEF:first_value=first,POP',
75 #'CDEF:first_time=first,POP',
76 'LINE1:watt_avg0#000000:W',
78 'GPRINT:watt_min0:MIN:%4.1lfW Min,',
79 'GPRINT:watt_avg0:AVERAGE:%4.1lfW Avg,',
80 'GPRINT:watt_max0:MAX:%4.1lfW Max,',
81 'GPRINT:watt_avg0:LAST:%4.1lfW Last\l',
82 'GPRINT:total:%4.1lf%sWh Gesamtverbrauch im angezeigten Zeitraum\l',
83 'GPRINT:first:erster Wert %c:strftime',
84 'GPRINT:last:letzter Wert %c:strftime']);
90 # vim: set shiftwidth=2 softtabstop=2 tabstop=8 :