root / plugins / memcached / memcached_ext_traffic_ @ 09b88141
Historique | Voir | Annoter | Télécharger (1,56 ko)
| 1 |
#!/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 |
[memcached_traffic_1] |
| 15 |
env.server 127.0.0.1:11211 |
| 16 |
env.label "first local server" |
| 17 |
|
| 18 |
[memcached_traffic_2] |
| 19 |
env.server /var/run/memcached/memcached.sock |
| 20 |
env.label "second local server" |
| 21 |
|
| 22 |
=cut |
| 23 |
|
| 24 |
my $label = exists $ENV{'label'} ? $ENV{'label'} : '';
|
| 25 |
unless( $label ){
|
| 26 |
|
| 27 |
if( $0 =~ /memcached_ext_traffic_([\w\d]+)$/ ){
|
| 28 |
$label = $1; |
| 29 |
} |
| 30 |
} |
| 31 |
|
| 32 |
|
| 33 |
my $cmd = shift || ''; |
| 34 |
if ($cmd eq 'config') {
|
| 35 |
print "graph_title Memcached network traffic on $label\n"; |
| 36 |
print "graph_args --base 1000 -l 0\n"; |
| 37 |
print "graph_vlabel bits per \${graph_period}\n";
|
| 38 |
print "graph_category memory\n"; |
| 39 |
print "graph_info This graph monitors the network traffic of the memcached server.\n"; |
| 40 |
print "up.label bits in\n"; |
| 41 |
print "up.info Traffic received by memcached\n"; |
| 42 |
print "up.min 0\n"; |
| 43 |
print "up.cdef up,8,*\n"; |
| 44 |
print "up.type COUNTER\n"; |
| 45 |
print "up.draw AREA\n"; |
| 46 |
print "down.label bits out\n"; |
| 47 |
print "down.info Traffic sent by memcached\n"; |
| 48 |
print "down.min 0\n"; |
| 49 |
print "down.cdef down,8,*\n"; |
| 50 |
print "down.type COUNTER\n"; |
| 51 |
exit 0; |
| 52 |
} |
| 53 |
|
| 54 |
my $server = exists $ENV{'server'} ? $ENV{'server'} : '127.0.0.1:11211';
|
| 55 |
|
| 56 |
my $memd = new Cache::Memcached { 'servers' => [$server] };
|
| 57 |
my $memstats = $memd->stats(['misc']); |
| 58 |
|
| 59 |
print "up.value " . $memstats->{hosts}->{$server}->{misc}->{bytes_read} . "\n";
|
| 60 |
print "down.value " . $memstats->{hosts}->{$server}->{misc}->{bytes_written} . "\n";
|
