This file is indexed.

/usr/share/doc/collectd-core/examples/collection3/lib/Collectd/Graph/Type/JavaMemory.pm is in collectd-core 5.4.0-3ubuntu2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
package Collectd::Graph::Type::JavaMemory;

# Copyright (C) 2008,2009  Florian octo Forster <octo at verplant.org>
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; only version 2 of the License is applicable.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

use strict;
use warnings;
use base ('Collectd::Graph::Type');

use Collectd::Graph::Common (qw($ColorCanvas $ColorFullBlue $ColorHalfBlue
  group_files_by_plugin_instance ident_to_filename sanitize_type_instance
  get_faded_color sort_idents_by_type_instance));

return (1);

sub getGraphsNum
{
  my $obj = shift;
  my $group = group_files_by_plugin_instance (@{$obj->{'files'}});

  return (scalar (keys %$group));
}

sub getRRDArgs
{
  my $obj = shift;
  my $index = shift;

  my $group = group_files_by_plugin_instance (@{$obj->{'files'}});
  my @group = sort (keys %$group);

  my $rrd_opts = $obj->{'rrd_opts'} || [];
  my $format = $obj->{'rrd_format'} || '%5.1lf';

  my $idents = $group->{$group[$index]};
  my %type_instance = ();

  my $ds = $obj->getDataSources ();
  if (!$ds)
  {
    confess ("obj->getDataSources failed.");
  }
  if (@$ds != 1)
  {
    confess ("I can only work with RRD files that have "
      . "exactly one data source!");
  }
  my $data_source = $ds->[0];

  my $rrd_title = $idents->[0]{'plugin_instance'};
  $rrd_title =~ s/^memory_pool-//;
  $rrd_title = "Memory pool \"$rrd_title\"";

  my $ds_names =
  {
    max       => 'Max      ',
    committed => 'Committed',
    used      => 'Used     ',
    init      => 'Init     '
  };

  my $colors =
  {
    max       => '00ff00',
    committed => 'ff8000',
    used      => 'ff0000',
    init      => '0000f0',
    'head-committed'    => '000000',
    'head-init'         => '000000',
    'head-max'          => '000000',
    'head-used'         => '000000',
    'nonhead-committed' => '000000',
    'nonhead-init'      => '000000',
    'nonhead-max'       => '000000',
    'nonhead-used'      => '000000'
  };
  my @ret = ('-t', $rrd_title, @$rrd_opts);

  if (defined $obj->{'rrd_vertical'})
  {
    push (@ret, '-v', $obj->{'rrd_vertical'});
  }
  else
  {
    push (@ret, '-v', "Bytes");
  }

  for (@$idents)
  {
    my $ident = $_;
    if ($ident->{'type_instance'})
    {
      $type_instance{$ident->{'type_instance'}} = $ident;
    }
  }

  if (exists ($type_instance{'committed'})
    && exists ($type_instance{'init'})
    && exists ($type_instance{'max'})
    && exists ($type_instance{'used'}))
  {
    for (qw(max committed init used))
    {
      my $inst = $_;
      my $file = ident_to_filename ($type_instance{$inst});
      my $color = $colors->{$inst};
      my $name = $ds_names->{$inst};
      push (@ret,
	"DEF:${inst}_min=${file}:value:MIN",
	"DEF:${inst}_avg=${file}:value:AVERAGE",
	"DEF:${inst}_max=${file}:value:MAX",
	"AREA:${inst}_avg#${color}10",
	"LINE1:${inst}_avg#${color}:${name}",
	"GPRINT:${inst}_min:MIN:%5.1lf\%sB Min,",
	"GPRINT:${inst}_avg:AVERAGE:%5.1lf\%sB Avg,",
	"GPRINT:${inst}_max:MAX:%5.1lf\%sB Max,",
	"GPRINT:${inst}_avg:LAST:%5.1lf\%sB Last\\l");
    }
    return (\@ret);
  }
  else
  {
    require Collectd::Graph::Type::GenericStacked;
    return (Collectd::Graph::Type::GenericStacked::getRRDArgs ($obj, $index));
  }
} # getRRDArgs

sub getGraphArgs
{
  my $obj = shift;
  my $index = shift;

  my $group = group_files_by_plugin_instance (@{$obj->{'files'}});
  my @group = sort (keys %$group);

  my $idents = $group->{$group[$index]};

  my @args = ();
  for (qw(hostname plugin plugin_instance type))
  {
    if (defined ($idents->[0]{$_}))
    {
      push (@args, $_ . '=' . $idents->[0]{$_});
    }
  }

  return (join (';', @args));
} # getGraphArgs

# vim: set shiftwidth=2 softtabstop=2 tabstop=8 :