Just what I needed.

Here's a simple patch to clear the screen and allow servers on the command line. When you have dozens of memcache servers it might be nice to gather the output first and then redraw.


 diff -u memcache-top-0.3.orig memcache-top
--- memcache-top-0.3.orig       2009-04-22 12:44:22.993210000 -0700
+++ memcache-top        2009-04-22 13:02:10.579094000 -0700
@@ -49,30 +49,26 @@
 );
 #
 # Default time to sleep in-between refreshes.
-$sleep = 3;
+my $default_sleep = 3;
 #
 # List of servers/ ports to query.
 @servers = (
-  '1.2.3.4:11211',
-  '1.2.3.5:11211',
-  '1.2.3.5:11212',
 );
 # END CONFIGURATION
##################################################################################
-
-if (defined(@ARGV)) {
-  if ( $ARGV[0] =~ /^\d+$/ ) {
-    $sleep = $ARGV[0];
-  }
-  else {
- die "USAGE: memcache-top.pl <optional number of seconds to sleep> \n";
-  }
+$sleep = shift @ARGV;
+if (!($sleep && $sleep =~ /^\d+$/)) {
+   $sleep = $default_sleep;
 }
+
+push(@servers, @ARGV);

 my $i = 1;

-while ($i) {
+my $CLEAR = `clear`;

+while ($i) {
+  print $CLEAR;
   print "\033[2J" if $usecolor;
   print color 'bold' if $usecolor;
print "\nMEMCACHE STATS\t\t\t\t\t\t (refresh: $sleep seconds)\n \n";



On Apr 22, 2009, at 2:16 PM, Mat Williams wrote:


hi,

i like the idea for this project, nice work nicholas. i have looked at
the output and it seems like it will be a useful tool for me too.

gf, can you please tell me why this code is not good - should i be
worried about running it against production servers?


thanks,
m...@.


On Wed, 2009-04-22 at 13:00 -0700, gf wrote:
Hi. It's really good idea, but your code is not good, IMHO.
I've started the same project now..
It will be released soon.

On 22 апр, 23:34, ntang <nicholast...@gmail.com> wrote:
Hey all.  First post...

We've been using memcached for a while, but we've never really done
much to monitor it past making sure the servers were up and running.
Anyways, we recently had some issues that looked like they might have
been related to memcached performance/ usage, and I figured it was
about time that we started taking a look at it.  We've added graphs
for various stats so we can track them over time, and added nagios
checks for the stats as well, but I also wanted a quick way to see the
immediate state of the cluster.

So I wrote a little tool. Hopefully people will find it useful. It's
mostly configured by editing a config block up top, sue me.  It's
cheesy but works.  The first time you run it, you'll need (at a
minimum) to populate @servers.

It's here:http://code.google.com/p/memcache-top/

(In retrospect I should've named it memcached-top, but such is life.
I think people will be able to figure it out, and maybe if I put out
another 'release' (*cough*) I'll rename it.  ;)  )

Thanks,
Nicholas


Reply via email to