memcached_hits
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
# | |
# Copyright (C) 2008 Rodolphe Quiedeville <rodolphe@quiedeville.org> | |
# | |
# This program is free software; you can redistribute it and/or | |
# modify it under the terms of the GNU General Public License | |
# as published by the Free Software Foundation; version 2 dated June, | |
# 1991. | |
# | |
# This program is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
# GNU General Public License for more details. | |
# | |
# You should have received a copy of the GNU General Public License | |
# along with this program; if not, write to the Free Software | |
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
# | |
# If you improve this script please send your version to my email address | |
# with the copyright notice upgrade with your name. | |
# | |
# | |
# $Log$ | |
# Revision 1.1 2008/08/08 10:40:01 rodo | |
# Created by Rodolphe Quiedeville | |
# | |
#%# family=memcached | |
#%# capabilities=autoconf | |
use strict; | |
my $ret = undef; | |
if (! eval "require Net::Telnet;") | |
{ | |
$ret = "Net::Telnet not found"; | |
} | |
my $host = exists $ENV{'host'} ? $ENV{'host'} : "127.0.0.1"; | |
my $port = exists $ENV{'port'} ? $ENV{'port'} : "11211"; | |
if ($ARGV[0] and $ARGV[0] eq "autoconf") | |
{ | |
my $pop = new Net::Telnet (Timeout => 5, | |
Telnetmode => 0, | |
Errmode => "return"); | |
if ($pop->open(Host => $host, Port => $port)) { | |
print "yes\n"; | |
} else { | |
print "no\n"; | |
} | |
exit 0; | |
} | |
if ($ARGV[0] and $ARGV[0] eq "config") | |
{ | |
print "graph_title Memcached hits/misses\n"; | |
print "graph_args --base 1000 -l 0\n"; | |
print "graph_vlabel hits\n"; | |
print "graph_category memcached\n"; | |
print 'graph_info Plugin available at <a href="http://rodolphe.quiedeville.org/hack/munin/">http://rodolphe.quiedeville.org/hack/munin/</a>'."\n"; | |
print "hits.draw AREA\n"; | |
print "hits.label hits\n"; | |
print "misses.draw STACK\n"; | |
print "misses.label misses\n"; | |
exit 0; | |
} | |
my $pop = new Net::Telnet (Telnetmode => 0); | |
$pop->open(Host => $host, Port => $port); | |
## Send command. | |
$pop->print("stats"); | |
my ($result,$line,$stats); | |
while (($line = $pop->getline) and ($line !~ /END/o)) | |
{ | |
$result = $line if $line =~ /STAT/; | |
my $nb = (split ' ',$result)[2]; | |
my $data = (split ' ',$result)[1]; | |
$stats->{$data} = $nb; | |
} | |
## Closing connection properly | |
$pop->print("quit"); | |
## output values | |
printf "hits.value %d\n",$stats->{get_hits}; | |
printf "misses.value %d\n",$stats->{get_misses}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment