This file is indexed.

/usr/lib/perl5/PCP/server.pl is in libpcp-mmv-perl 3.8.12ubuntu1.

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

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
#!/usr/bin/perl
#
# Example server application that demonstrates use of the
# Perl PCP MMV module for runtime instrumentation.
#

use strict;
use warnings;
use PCP::MMV;
use Time::HiRes qw ( usleep );

my @db_instances = ( 0 => "tempdb", 1 => "datadb" );

my $db_indom = 1;
my @indoms = (
    [ $db_indom, \@db_instances,
	'Database instances',
	'An instance domain for each database used by this server.',
    ],
);

my @metrics = (
    [ 'response_time.requests',
	1, MMV_TYPE_U64, MMV_INDOM_NULL,
	mmv_units(0,0,1,0,0,MMV_COUNT_ONE), MMV_SEM_COUNTER,
	'Number of server requests processed', ''
    ],
    [ 'response_time.total',
	2, MMV_TYPE_U64, MMV_INDOM_NULL,
	mmv_units(0,0,1,0,0,MMV_COUNT_ONE), MMV_SEM_COUNTER,
	'Maximum observed response time in milliseconds', ''
    ],
    [ 'response_time.maximum',
	3, MMV_TYPE_DOUBLE, MMV_INDOM_NULL,
	mmv_units(0,1,0,0,MMV_TIME_MSEC,0), MMV_SEM_INSTANT,
	'Maximum observed response time in milliseconds', ''
    ],
    [ 'version',
	4, MMV_TYPE_STRING, MMV_INDOM_NULL,
	mmv_units(0,0,0,0,0,0), MMV_SEM_DISCRETE,
	'Version number of the server process', ''
    ],
    [ 'database.transactions.count',
	5, MMV_TYPE_U64, $db_indom,
	mmv_units(0,0,1,0,0,MMV_COUNT_ONE), MMV_SEM_COUNTER,
	'Number of requests issued to each database', ''
    ],
    [ 'database.transactions.time',
	6, MMV_TYPE_U64, $db_indom,
	mmv_units(0,1,0,0,MMV_TIME_MSEC,0), MMV_SEM_COUNTER,
	'Total time spent waiting for results from each database', ''
    ],
    [ 'idletime',
	7, MMV_TYPE_U64, MMV_INDOM_NULL,
	mmv_units(0,1,0,0,MMV_TIME_USEC,0), MMV_SEM_COUNTER,
	'Total time spent asleep, in-between requests', ''
    ],
);

my $handle = mmv_stats_init('server', 0, MMV_FLAG_PROCESS, \@metrics, \@indoms);
die("mmv_stats_init failed\n") unless (defined($handle));

mmv_stats_set_string($handle, 'version', '', '7.4.2-5');

my $maxtime = 0.0;	# milliseconds

for (;;) {

	my $idletime = 0.0;	# microseconds
	my $dbtime = 0.0;	# milliseconds
	my $response = 0.0;


	# start a request ...

	$dbtime = rand 1000;	# milliseconds
	$response += $dbtime;
	mmv_stats_inc($handle, 'database.transactions.count', 'tempdb');
	mmv_stats_add($handle, 'database.transactions.time', 'tempdb', $dbtime);

	# ... more work, involving a second DB request ...
	$dbtime = rand 1000;	# milliseconds
	$response += $dbtime;
	mmv_stats_inc($handle, 'database.transactions.count', 'datadb');
	mmv_stats_add($handle, 'database.transactions.time', 'datadb', $dbtime);

	# ... request completed


	$response += rand 42;	# milliseconds
	mmv_stats_inc($handle, 'response_time.requests', '');
	mmv_stats_add($handle, 'response_time.total', '', $response);
	if ($response > $maxtime) {
		$maxtime = $response;
		mmv_stats_set($handle, 'response_time.maximum', '', $maxtime);
	}

	$idletime = rand 50000;	# microseconds
	usleep($idletime);
	mmv_stats_add($handle, 'idletime', '', $idletime);
}