2007-11-26 16:53:48 +01:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
# ex:ts=4
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
use Cache::Memcached;
|
|
|
|
|
2012-02-01 11:29:20 +01:00
|
|
|
$0 =~ /memcached_hits_(\d+_\d+_\d+_\d+)_(\d+)$/;
|
|
|
|
my ($ip, $port) = ($1, $2);
|
|
|
|
$ip =~ s/_/./g;
|
|
|
|
my $address = "$ip:$port";
|
|
|
|
|
|
|
|
my $title = $ENV{title} || $address;
|
|
|
|
|
2007-11-26 16:53:48 +01:00
|
|
|
my $cmd = shift || '';
|
|
|
|
if ($cmd eq 'config') {
|
2012-02-01 11:29:20 +01:00
|
|
|
print "graph_title Memcached cache hits and misses -- $title\n";
|
2007-11-26 16:53:48 +01:00
|
|
|
print "graph_args --base 1000 -l 0\n";
|
|
|
|
print "graph_vlabel requests\n";
|
2017-02-27 00:25:28 +01:00
|
|
|
print "graph_category memory\n";
|
2007-11-26 16:53:48 +01:00
|
|
|
print "graph_info This graph monitors the number of cache hits and misses.\n";
|
|
|
|
print "hits.label hits\n";
|
|
|
|
print "hits.info Number of cache hits\n";
|
|
|
|
print "hits.min 0\n";
|
|
|
|
print "hits.type DERIVE\n";
|
|
|
|
print "misses.label misses\n";
|
|
|
|
print "misses.info Number of cache misses\n";
|
|
|
|
print "misses.min 0\n";
|
|
|
|
print "misses.type DERIVE\n";
|
|
|
|
print "misses.draw AREA\n";
|
|
|
|
exit 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
my $memd = new Cache::Memcached { 'servers' => [$address] };
|
|
|
|
my $memstats = $memd->stats(['misc']);
|
|
|
|
|
|
|
|
print "hits.value " . $memstats->{hosts}->{$address}->{misc}->{get_hits} . "\n";
|
|
|
|
print "misses.value " .
|
|
|
|
$memstats->{hosts}->{$address}->{misc}->{get_misses} . "\n";
|