2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00
contrib-munin/plugins/other/memcached_requests_
2011-12-18 15:10:09 +01:00

39 lines
1.0 KiB
Perl
Executable File

#!/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 requests\n";
print "graph_args --base 1000 -l 0\n";
print "graph_vlabel requests\n";
print "graph_category memcached\n";
print "graph_info This graph monitors the number of get and set requests.\n";
print "gets.label gets\n";
print "gets.info Number of get requests\n";
print "gets.min 0\n";
print "gets.type DERIVE\n";
print "gets.draw AREA\n";
print "sets.label sets\n";
print "sets.info Number of set requests\n";
print "sets.min 0\n";
print "sets.type DERIVE\n";
print "sets.draw STACK\n";
exit 0;
}
$0 =~ /memcached_requests_(\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 "gets.value " . $memstats->{hosts}->{$address}->{misc}->{cmd_get} . "\n";
print "sets.value " . $memstats->{hosts}->{$address}->{misc}->{cmd_set} . "\n";