1 package Collectd::Graph::Type::Df;
3 # Copyright (C) 2008,2009 Florian octo Forster <octo at verplant.org>
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(free used)]);
34 my $obj = Collectd::Graph::Type->new (@_);
35 $obj->{'data_sources'} = [qw(free used)];
36 $obj->{'rrd_opts'} = ['-v', 'Bytes'];
37 $obj->{'rrd_title'} = 'Disk space ({instance})';
38 $obj->{'rrd_format'} = '%5.1lf%sB';
39 $obj->{'colors'} = [qw(00b000 ff0000)];
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', $obj->getTitle ($ident), '-v', 'Bytes', '-l', '0',
62 "DEF:free_min=${filename}:free:MIN",
63 "DEF:free_avg=${filename}:free:AVERAGE",
64 "DEF:free_max=${filename}:free:MAX",
65 "DEF:used_min=${filename}:used:MIN",
66 "DEF:used_avg=${filename}:used:AVERAGE",
67 "DEF:used_max=${filename}:used:MAX",
68 "CDEF:both_avg=free_avg,used_avg,+",
69 "AREA:both_avg#${faded_green}",
70 "AREA:used_avg#${faded_red}",
71 'LINE1:both_avg#00ff00:Free',
72 'GPRINT:free_min:MIN:%5.1lf%sB Min,',
73 'GPRINT:free_avg:AVERAGE:%5.1lf%sB Avg,',
74 'GPRINT:free_max:MAX:%5.1lf%sB Max,',
75 'GPRINT:free_avg:LAST:%5.1lf%sB Last\l',
76 'LINE1:used_avg#ff0000:Used',
77 'GPRINT:used_min:MIN:%5.1lf%sB Min,',
78 'GPRINT:used_avg:AVERAGE:%5.1lf%sB Avg,',
79 'GPRINT:used_max:MAX:%5.1lf%sB Max,',
80 'GPRINT:used_avg:LAST:%5.1lf%sB Last\l']);
83 # vim: set shiftwidth=2 softtabstop=2 tabstop=8 :