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'});
99 if ($ident->{'type_instance'})
101 $type_instance{$ident->{'type_instance'}} = $ident;
105 if (exists ($type_instance{'committed'})
106 && exists ($type_instance{'init'})
107 && exists ($type_instance{'max'})
108 && exists ($type_instance{'used'}))
110 for (qw(max committed init used))
113 my $file = ident_to_filename ($type_instance{$inst});
114 my $color = $colors->{$inst};
115 my $name = $ds_names->{$inst};
117 "DEF:${inst}_min=${file}:value:MIN",
118 "DEF:${inst}_avg=${file}:value:AVERAGE",
119 "DEF:${inst}_max=${file}:value:MAX",
120 "AREA:${inst}_avg#${color}10",
121 "LINE1:${inst}_avg#${color}:${name}",
122 "GPRINT:${inst}_min:MIN:%5.1lf\%sB Min,",
123 "GPRINT:${inst}_avg:AVERAGE:%5.1lf\%sB Avg,",
124 "GPRINT:${inst}_max:MAX:%5.1lf\%sB Max,",
125 "GPRINT:${inst}_avg:LAST:%5.1lf\%sB Last\\l");
131 require Collectd::Graph::Type::GenericStacked;
132 return (Collectd::Graph::Type::GenericStacked::getRRDArgs ($obj, $index));
141 my $group = group_files_by_plugin_instance (@{$obj->{'files'}});
142 my @group = sort (keys %$group);
144 my $idents = $group->{$group[$index]};
147 for (qw(hostname plugin plugin_instance type))
149 if (defined ($idents->[0]{$_}))
151 push (@args, $_ . '=' . $idents->[0]{$_});
155 return (join (';', @args));
158 # vim: set shiftwidth=2 softtabstop=2 tabstop=8 :