diff options
Diffstat (limited to 'scripts/memcached-tool')
-rwxr-xr-x | scripts/memcached-tool | 56 |
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; } } |