2007-11-26 16:52:44 +01:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
# ex:ts=4
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
use Cache::Memcached;
|
|
|
|
|
|
|
|
my $cmd = shift || '';
|
|
|
|
if ($cmd eq 'config') {
|
|
|
|
print "graph_title Memcached bytes used\n";
|
|
|
|
print "graph_args --base 1024 -l 0\n";
|
|
|
|
print "graph_vlabel bytes\n";
|
2017-02-27 00:25:28 +01:00
|
|
|
print "graph_category memory\n";
|
2007-11-26 16:52:44 +01:00
|
|
|
print "graph_info This graph monitors the size of the memcached cache.\n";
|
|
|
|
print "bytes.label bytes used\n";
|
|
|
|
print "bytes.info Number of bytes currently used\n";
|
|
|
|
print "bytes.min 0\n";
|
|
|
|
print "bytes.draw AREA\n";
|
|
|
|
print "maxbytes.label maximum available\n";
|
|
|
|
print "maxbytes.info The configured cache size\n";
|
|
|
|
print "maxbytes.min 0\n";
|
|
|
|
exit 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
$0 =~ /memcached_bytes_(\d+_\d+_\d+_\d+)_(\d+)$/;
|
|
|
|
my ($ip, $port) = ($1, $2);
|
|
|
|
$ip =~ s/_/./g;
|
|
|
|
my $address = "$ip:$port";
|
|
|
|
|
|
|
|
my $memd = new Cache::Memcached { 'servers' => [$address] };
|
|
|
|
my $memstats = $memd->stats(['misc']);
|
|
|
|
|
|
|
|
print "bytes.value " . $memstats->{hosts}->{$address}->{misc}->{bytes} . "\n";
|
|
|
|
print "maxbytes.value " .
|
|
|
|
$memstats->{hosts}->{$address}->{misc}->{limit_maxbytes} . "\n";
|