Skip to content
Browse files

Implement settings and sizes stats. Show information about empty slabs.

  • Loading branch information...
1 parent 9c9a33c commit ba6d5705b4857f9f8ef92af6b66577e29f3f771e @gnomeby gnomeby committed with dormando Oct 19, 2012
Showing with 55 additions and 1 deletion.
  1. +55 −1 scripts/memcached-tool
View
56 scripts/memcached-tool
@@ -6,6 +6,9 @@
# Author:
# Brad Fitzpatrick <brad@danga.com>
#
+# Contributor:
+# Andrey Niakhaichyk <andrey@niakhaichyk.org>
+#
# License:
# public domain. I give up all rights to this
# tool. modify and copy at will.
@@ -30,6 +33,10 @@ if ($mode eq "display") {
;
} elsif ($mode eq 'stats') {
;
+} elsif ($mode eq 'settings') {
+ ;
+} elsif ($mode eq 'sizes') {
+ ;
} else {
undef $mode;
}
@@ -41,7 +48,15 @@ die
memcached-tool 10.0.0.5:11211 display # shows slabs
memcached-tool 10.0.0.5:11211 # same. (default is display)
memcached-tool 10.0.0.5:11211 stats # shows general stats
+ memcached-tool 10.0.0.5:11211 settings # shows settings stats
+ memcached-tool 10.0.0.5:11211 sizes # shows sizes stats
memcached-tool 10.0.0.5:11211 dump # dumps keys and values
+
+WARNING! sizes is a development command.
+As of 1.4 it is still the only command which will lock your memcached instance for some time.
+If you have many millions of stored items, it can become unresponsive for several minutes.
+Run this at your own risk. It is roadmapped to either make this feature optional
+or at least speed it up.
" unless $addr && $mode;
@@ -129,6 +144,45 @@ if ($mode eq 'stats') {
exit;
}
+if ($mode eq 'settings') {
+ my %items;
+
+ print $sock "stats settings\r\n";
+
+ while (<$sock>) {
+ last if /^END/;
+ chomp;
+ if (/^STAT\s+(\S*)\s+(.*)/) {
+ $items{$1} = $2;
+ }
+ }
+ printf ("#%-17s %5s %11s\n", $addr, "Field", "Value");
+ foreach my $name (sort(keys(%items))) {
+ printf ("%24s %12s\n", $name, $items{$name});
+ }
+ exit;
+}
+
+
+if ($mode eq 'sizes') {
+ my %items;
+
+ print $sock "stats sizes\r\n";
+
+ while (<$sock>) {
+ last if /^END/;
+ chomp;
+ if (/^STAT\s+(\S*)\s+(.*)/) {
+ $items{$1} = $2;
+ }
+ }
+ printf ("#%-17s %5s %11s\n", $addr, "Size", "Count");
+ foreach my $name (sort(keys(%items))) {
+ printf ("%24s %12s\n", $name, $items{$name});
+ }
+ exit;
+}
+
# display mode:
my %items; # class -> { number, age, chunk_size, chunks_per_page,
@@ -141,7 +195,6 @@ while (<$sock>) {
last if /^END/;
if (/^STAT items:(\d+):(\w+) (\d+)/) {
$items{$1}{$2} = $3;
- $max = $1;
}
}
@@ -150,6 +203,7 @@ while (<$sock>) {
last if /^END/;
if (/^STAT (\d+):(\w+) (\d+)/) {
$items{$1}{$2} = $3;
+ $max = $1;
}
}

0 comments on commit ba6d570

Please sign in to comment.
Something went wrong with that request. Please try again.