2015-07-13 00:38:54 +02:00
|
|
|
#!/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_connections_1]
|
|
|
|
env.server 127.0.0.1:11211
|
|
|
|
env.label "first local server"
|
|
|
|
|
|
|
|
[memcached_connections_2]
|
|
|
|
env.server /var/run/memcached/memcached.sock
|
|
|
|
env.label "second local server"
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
my $label = exists $ENV{'label'} ? $ENV{'label'} : '';
|
|
|
|
unless( $label ){
|
2018-08-02 02:03:42 +02:00
|
|
|
|
2015-07-13 00:38:54 +02:00
|
|
|
if( $0 =~ /memcached_ext_connections_([\w\d]+)$/ ){
|
|
|
|
$label = $1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
my $cmd = shift || '';
|
|
|
|
if ($cmd eq 'config') {
|
|
|
|
print "graph_title Memcached connections on $label\n";
|
|
|
|
print "graph_args --base 1000 -l 0\n";
|
|
|
|
print "graph_vlabel connections\n";
|
2017-02-27 00:25:28 +01:00
|
|
|
print "graph_category memory\n";
|
2015-07-13 00:38:54 +02:00
|
|
|
print "graph_info This graph monitors the connections to the memcached server.\n";
|
|
|
|
print "connections.label connections\n";
|
|
|
|
print "connections.info Number of connections to memcached\n";
|
|
|
|
print "connections.min 0\n";
|
|
|
|
print "connections.draw AREA\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 "connections.value " .
|
|
|
|
$memstats->{hosts}->{$server}->{misc}->{curr_connections} . "\n";
|