Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / memcached / memcached_ext_connections_ @ 09b88141

Historique | Voir | Annoter | Télécharger (1,31 ko)

1 fb4914f7 Andrey (suse24)
#!/usr/bin/env perl
2
# ex:ts=4
3
4
use strict;
5
use warnings;
6
7
use Cache::Memcached;
8
9
# Based on original plugin, extended to unix socket use
10
# https://github.com/western, westroads@gmail.com
11
12
=head1 example config for /plugin-conf.d/munin-node
13
14 09b88141 Lars Kruse
 [memcached_connections_1]
15
 env.server 127.0.0.1:11211
16
 env.label "first local server"
17 fb4914f7 Andrey (suse24)
18 09b88141 Lars Kruse
 [memcached_connections_2]
19
 env.server /var/run/memcached/memcached.sock
20
 env.label "second local server"
21 fb4914f7 Andrey (suse24)
22
=cut
23
24
my $label = exists $ENV{'label'} ? $ENV{'label'} : '';
25
unless( $label ){
26 17f78427 Lars Kruse
27 fb4914f7 Andrey (suse24)
	if( $0 =~ /memcached_ext_connections_([\w\d]+)$/ ){
28
		$label = $1;
29
	}
30
}
31
32
my $cmd = shift || '';
33
if ($cmd eq 'config') {
34
	print "graph_title Memcached connections on $label\n";
35
	print "graph_args --base 1000 -l 0\n";
36
	print "graph_vlabel connections\n";
37 78b99b85 dipohl
	print "graph_category memory\n";
38 fb4914f7 Andrey (suse24)
	print "graph_info This graph monitors the connections to the memcached server.\n";
39
	print "connections.label connections\n";
40
	print "connections.info Number of connections to memcached\n";
41
	print "connections.min 0\n";
42
	print "connections.draw AREA\n";
43
	exit 0;
44
}
45
46
47
my $server = exists $ENV{'server'} ? $ENV{'server'} : '127.0.0.1:11211';
48
49
my $memd = new Cache::Memcached { 'servers' => [$server] };
50
my $memstats = $memd->stats(['misc']);
51
52
print "connections.value " .
53
	$memstats->{hosts}->{$server}->{misc}->{curr_connections} . "\n";