2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00
contrib-munin/plugins/memcached/memcached_ext_requests_
dipohl 78b99b8595 Category Tree: Reduce number of categories
memcached -> memory (memcached)
2017-02-27 00:25:28 +01:00

60 lines
1.5 KiB
Perl
Executable File

#!/usr/bin/env perl
# ex:ts=4
use strict;
use warnings;
use Cache::Memcached;
# Based on original plugin, extended to unix socket use
# https://github.com/western, westroads@gmail.com
=head1 example config for /plugin-conf.d/munin-node
[memcached_requests_1]
env.server 127.0.0.1:11211
env.label "first local server"
[memcached_requests_2]
env.server /var/run/memcached/memcached.sock
env.label "second local server"
=cut
my $label = exists $ENV{'label'} ? $ENV{'label'} : '';
unless( $label ){
if( $0 =~ /memcached_ext_requests_([\w\d]+)$/ ){
$label = $1;
}
}
my $cmd = shift || '';
if ($cmd eq 'config') {
print "graph_title Memcached requests on $label\n";
print "graph_args --base 1000 -l 0\n";
print "graph_vlabel requests\n";
print "graph_category memory\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;
}
my $server = exists $ENV{'server'} ? $ENV{'server'} : '127.0.0.1:11211';
my $memd = new Cache::Memcached { 'servers' => [$server] };
my $memstats = $memd->stats(['misc']);
print "gets.value " . $memstats->{hosts}->{$server}->{misc}->{cmd_get} . "\n";
print "sets.value " . $memstats->{hosts}->{$server}->{misc}->{cmd_set} . "\n";