1 package Collectd::Graph::Type::ArcCounts;
3 # Copyright (C) 2009 Anthony Dewhurst <dewhurst at gmail>
4 #
5 # This program is available software; you can redistribute it and/or modify it under
6 # the terms of the GNU General Public License as published by the available Software
7 # Foundation; only version 2 of the License is applicable.
8 #
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
12 # details.
13 #
14 # You should have received a copy of the GNU General Public License along with
15 # this program; if not, write to the available Software Foundation, Inc.,
16 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 use strict;
19 use warnings;
20 use base ('Collectd::Graph::Type');
22 use Collectd::Graph::Common (qw(ident_to_filename get_faded_color));
24 return (1);
26 sub getDataSources
27 {
28 return ([qw(available usedbydatasetbydataset usedbysnapshots usedbyrefres usedbychildren)]);
29 } # getDataSources
31 sub new
32 {
33 my $pkg = shift;
34 my $obj = Collectd::Graph::Type->new (@_);
35 $obj->{'data_sources'} = [qw(demand_data demand_metadata prefetch_data prefetch_metadata)];
36 $obj->{'rrd_opts'} = [];
37 $obj->{'rrd_title'} = 'ARC {type_instance} on {hostname}';
39 return (bless ($obj, $pkg));
40 } # new
42 sub getRRDArgs
43 {
44 my $obj = shift;
45 my $index = shift;
47 my $ident = $obj->{'files'}[$index];
48 if (!$ident)
49 {
50 cluck ("Invalid index: $index");
51 return;
52 }
53 my $filename = ident_to_filename ($ident);
54 $filename =~ s#:#\\:#g;
56 my $legend = $ident->{'type_instance'};
59 my $faded_green = get_faded_color ('00ff00');
60 my $faded_blue = get_faded_color ('0000ff');
61 my $faded_red = get_faded_color ('ff0000');
62 my $faded_cyan = get_faded_color ('00ffff');
64 my @ret = @{$obj->{'rrd_opts'}};
66 push @ret, '-t', $obj->getTitle($ident);
67 push @ret, '-v', ucfirst($ident->{'type_instance'});
69 my $ds = {
70 demand_data => { legend => "Demand data ", color => "00ff00" },
71 demand_metadata => { legend => "Demand metadata", color => "0000ff" },
72 prefetch_data => { legend => "Prefetch data ", color => "ff0000" },
73 prefetch_metadata => { legend => "Prefetch meta ", color => "ff00ff" },
74 };
76 foreach (qw(demand_data demand_metadata prefetch_data prefetch_metadata))
77 {
78 push @ret,
79 "DEF:${_}_min=${filename}:${_}:MIN",
80 "DEF:${_}_avg=${filename}:${_}:AVERAGE",
81 "DEF:${_}_max=${filename}:${_}:MAX";
82 }
84 {
85 push @ret,
86 "CDEF:stack_prefetch_metadata=prefetch_metadata_avg",
87 "CDEF:stack_prefetch_data=prefetch_data_avg,stack_prefetch_metadata,+",
88 "CDEF:stack_demand_metadata=demand_metadata_avg,stack_prefetch_data,+",
89 "CDEF:stack_demand_data=demand_data_avg,stack_demand_metadata,+",
90 "AREA:stack_demand_data#${faded_green}",
91 "AREA:stack_demand_metadata#${faded_blue}",
92 "AREA:stack_prefetch_data#${faded_red}",
93 "AREA:stack_prefetch_metadata#${faded_cyan}",
94 }
96 foreach (qw(demand_data demand_metadata prefetch_data prefetch_metadata))
97 {
98 push @ret,
99 "LINE1:stack_${_}#" . $ds->{$_}->{color} . ":" . $ds->{$_}->{legend},
100 "GPRINT:${_}_min:MIN:%5.1lf Min,",
101 "GPRINT:${_}_avg:AVERAGE:%5.1lf Avg,",
102 "GPRINT:${_}_max:MAX:%5.1lf Max,",
103 "GPRINT:${_}_avg:LAST:%5.1lf Last\l";
104 }
106 return \@ret;
108 } # getRRDArgs
110 # vim: set shiftwidth=2 softtabstop=2 tabstop=8 :