This file is indexed.

/usr/bin/memcached_top is in ruby-memcache-client 1.8.5-3.

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
#!/usr/bin/env ruby

require 'optparse'
require 'ostruct'
require 'socket'

@options = OpenStruct.new
@options.hostname = 'localhost'
@options.port = 11211

op = OptionParser.new do |opts|
	opts.banner = "View memcached server statistics\nUsage: #{$0} [options]"
	opts.separator "General Options:"
	opts.on("-h HOSTNAME", "--hostname=HOSTNAME", "Hostname [default: localhost]") do |h|
		@options.hostname = h
	end
	opts.on("-p PORT", "--port=PORT", Integer, "Port [default: 11211]") do |p|
		@options.port = p
	end
	opts.on_tail("--help", "Show this message") do
		puts opts
		exit
	end
end
op.parse!

def stats_data
  data = ''
  sock = TCPSocket.new(@options.hostname, @options.port)
  sock.print("stats\r\n")
  sock.flush
  # memcached does not close the socket once it is done writing
  # the stats data.  We need to read line by line until we detect
  # the END line and then stop/close on our side.
  stats = sock.gets
  while true
    data += stats
    break if stats.strip == 'END'
    stats = sock.gets
  end
  sock.close
  data
end

def parse(stats_data)
  stats = []
  stats_data.each_line do |line|
    stats << "#{$1}: #{$2}" if line =~ /STAT (\w+) (\S+)/
  end
  stats.sort
end

stats = parse(stats_data)
stats.each do |stat|
  puts stat
end