Created
October 14, 2008 12:51
-
-
Save bastos/16708 to your computer and use it in GitHub Desktop.
Some scripts to get memcached statistics. Choose your flavor! Usage: memcached.script ip port
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 | |
# Thanks to http://lists.danga.com/pipermail/memcached/2003-October/000354.html | |
use IO::Socket; | |
my $socket = IO::Socket::INET->new( PeerAddr => $ARGV[0], | |
PeerPort => $ARGV[1], | |
Proto => "tcp", | |
Type => SOCK_STREAM) | |
or die($@); | |
print $socket "stats\n"; | |
$out = <$socket> | |
while ($out ne "END\r\n") { | |
if ($out =~ m/STAT (\w+) ([0-9.]+)/) { | |
print "$1 $2\n"; | |
} | |
$out = <$socket> | |
} | |
close($socket); |
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/ruby | |
require 'socket' | |
out = TCPSocket.open($*[0],$*[1]) do |socket| | |
socket.puts 'stats' | |
socket.puts 'quit' | |
socket.read | |
end | |
out.each { |line| print line.gsub(/STAT /,"") if line =~ /STAT (\w+) ([0-9.]+)/ } |
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
#!/bin/sh | |
# Thanks to Matela, "usa netcat cara!" ;) | |
echo -e 'stats\nquit' | netcat $1 $2 | grep STAT | sed -e "s/STAT //" -e "s/ /\\t/" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment