root / plugins / memcached / memcached_traffic_ @ ef960abc
Historique | Voir | Annoter | Télécharger (1,12 ko)
| 1 | 5c30a639 | Maxime Henrion | #!/usr/bin/env perl |
|---|---|---|---|
| 2 | # ex:ts=4 |
||
| 3 | |||
| 4 | use strict; |
||
| 5 | use warnings; |
||
| 6 | |||
| 7 | use Cache::Memcached; |
||
| 8 | |||
| 9 | my $cmd = shift || ''; |
||
| 10 | if ($cmd eq 'config') {
|
||
| 11 | print "graph_title Memcached network traffic\n"; |
||
| 12 | print "graph_args --base 1000 -l 0\n"; |
||
| 13 | print "graph_vlabel bits per \${graph_period}\n";
|
||
| 14 | print "graph_category memcached\n"; |
||
| 15 | print "graph_info This graph monitors the network traffic of the memcached server.\n"; |
||
| 16 | print "up.label bits in\n"; |
||
| 17 | print "up.info Traffic received by memcached\n"; |
||
| 18 | print "up.min 0\n"; |
||
| 19 | print "up.cdef up,8,*\n"; |
||
| 20 | print "up.type COUNTER\n"; |
||
| 21 | print "up.draw AREA\n"; |
||
| 22 | print "down.label bits out\n"; |
||
| 23 | print "down.info Traffic sent by memcached\n"; |
||
| 24 | print "down.min 0\n"; |
||
| 25 | print "down.cdef down,8,*\n"; |
||
| 26 | print "down.type COUNTER\n"; |
||
| 27 | exit 0; |
||
| 28 | } |
||
| 29 | |||
| 30 | $0 =~ /memcached_traffic_(\d+_\d+_\d+_\d+)_(\d+)$/; |
||
| 31 | my ($ip, $port) = ($1, $2); |
||
| 32 | $ip =~ s/_/./g; |
||
| 33 | my $address = "$ip:$port"; |
||
| 34 | |||
| 35 | my $memd = new Cache::Memcached { 'servers' => [$address] };
|
||
| 36 | my $memstats = $memd->stats(['misc']); |
||
| 37 | |||
| 38 | print "up.value " . $memstats->{hosts}->{$address}->{misc}->{bytes_read} . "\n";
|
||
| 39 | print "down.value " . $memstats->{hosts}->{$address}->{misc}->{bytes_written} . "\n"; |
