1 package Collectd::Graph::Type::JavaMemory;
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($ColorCanvas $ColorFullBlue $ColorHalfBlue
23 group_files_by_plugin_instance ident_to_filename sanitize_type_instance
24 get_faded_color sort_idents_by_type_instance));
31 my $group = group_files_by_plugin_instance (@{$obj->{'files'}});
33 return (scalar (keys %$group));
41 my $group = group_files_by_plugin_instance (@{$obj->{'files'}});
42 my @group = sort (keys %$group);
44 my $rrd_opts = $obj->{'rrd_opts'} || [];
45 my $format = $obj->{'rrd_format'} || '%5.1lf';
47 my $idents = $group->{$group[$index]};
48 my %type_instance = ();
50 my $ds = $obj->getDataSources ();
53 confess ("obj->getDataSources failed.");
57 confess ("I can only work with RRD files that have "
58 . "exactly one data source!");
60 my $data_source = $ds->[0];
62 my $rrd_title = $idents->[0]{'plugin_instance'};
63 $rrd_title =~ s/^memory_pool-//;
64 $rrd_title = "Memory pool \"$rrd_title\"";
69 committed => 'Committed',
77 committed => 'ff8000',
80 'head-committed' => '000000',
81 'head-init' => '000000',
82 'head-max' => '000000',
83 'head-used' => '000000',
84 'nonhead-committed' => '000000',
85 'nonhead-init' => '000000',
86 'nonhead-max' => '000000',
87 'nonhead-used' => '000000'
89 my @ret = ('-t', $rrd_title, @$rrd_opts);
91 if (defined $obj->{'rrd_vertical'})
93 push (@ret, '-v', $obj->{'rrd_vertical'});
97 push (@ret, '-v', "Bytes");
103 if ($ident->{'type_instance'})
105 $type_instance{$ident->{'type_instance'}} = $ident;
109 if (exists ($type_instance{'committed'})
110 && exists ($type_instance{'init'})
111 && exists ($type_instance{'max'})
112 && exists ($type_instance{'used'}))
114 for (qw(max committed init used))
117 my $file = ident_to_filename ($type_instance{$inst});
118 my $color = $colors->{$inst};
119 my $name = $ds_names->{$inst};
121 "DEF:${inst}_min=${file}:value:MIN",
122 "DEF:${inst}_avg=${file}:value:AVERAGE",
123 "DEF:${inst}_max=${file}:value:MAX",
124 "AREA:${inst}_avg#${color}10",
125 "LINE1:${inst}_avg#${color}:${name}",
126 "GPRINT:${inst}_min:MIN:%5.1lf\%sB Min,",
127 "GPRINT:${inst}_avg:AVERAGE:%5.1lf\%sB Avg,",
128 "GPRINT:${inst}_max:MAX:%5.1lf\%sB Max,",
129 "GPRINT:${inst}_avg:LAST:%5.1lf\%sB Last\\l");
135 require Collectd::Graph::Type::GenericStacked;
136 return (Collectd::Graph::Type::GenericStacked::getRRDArgs ($obj, $index));
145 my $group = group_files_by_plugin_instance (@{$obj->{'files'}});
146 my @group = sort (keys %$group);
148 my $idents = $group->{$group[$index]};
151 for (qw(hostname plugin plugin_instance type))
153 if (defined ($idents->[0]{$_}))
155 push (@args, $_ . '=' . $idents->[0]{$_});
159 return (join (';', @args));
162 # vim: set shiftwidth=2 softtabstop=2 tabstop=8 :