/var/lib/pcp/testsuite/src/memcachestats.pl is in pcp-testsuite 4.0.1-1.
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 | #!/usr/bin/env perl
#
# liberally borrowed from memcache-top at
# https://code.google.com/p/memcache-top/
#
use warnings;
use strict;
use IO::Socket;
use Getopt::Long;
my (@default_instances, @instances, $remote, $default_port);
# List of servers/ ports to query.
@default_instances = ( '127.0.0.1:11211' );
# Default port to connect to, if not specified
$default_port = "11211";
if (@ARGV) {
GetOptions (
'instances=s' => \@instances,
'port=i' => \$default_port,
);
if (@instances) {
@instances = split(/,/,join(',',@instances));
} else {
@instances = @default_instances;
}
}
else {
@instances = @default_instances;
}
foreach my $instance (@instances) {
my ($server);
my @split = split(/:/,$instance);
unless ( $split[1] ) {
$instance = $instance . ":" . $default_port;
}
$remote = IO::Socket::INET->new($instance);
unless ( defined($remote) ) {
print "no cigar: $!\n";
exit(1);
}
$remote->autoflush(1);
my @commands = ("stats", "stats slabs", "stats items" );
foreach my $command (@commands) {
print $remote "$command\n";
LINE: while ( defined ( my $line = <$remote> ) ) {
last LINE if ( $line =~ /^END/ );
chomp $line;
$line =~ s/^STAT //;
$line =~ s/
//;
print $line . "\n";
next LINE;
}
}
close $remote;
}
|