summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAndrey Niakhaichyk <andrey@niakhaichyk.org>2012-10-19 13:45:28 +0300
committerdormando <dormando@rydia.net>2013-12-19 19:40:53 -0800
commitba6d5705b4857f9f8ef92af6b66577e29f3f771e (patch)
tree15bcd662586bb24e3634f710f873c52105682312 /scripts
parent9c9a33cafe0570da53500f2e3b0bc46d2a530e7d (diff)
downloadmemcached-ba6d5705b4857f9f8ef92af6b66577e29f3f771e.tar.gz
Implement settings and sizes stats. Show information about empty slabs.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/memcached-tool56
1 files changed, 55 insertions, 1 deletions
diff --git a/scripts/memcached-tool b/scripts/memcached-tool
index bae4efd..82c6c3c 100755
--- a/scripts/memcached-tool
+++ b/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;
}
}