Commit Graph

239 Commits

Author SHA1 Message Date
sskorgal 9dfd9d1412 Fix for redis_cli printing default DB when select command fails. 2016-07-01 10:42:22 +05:30
antirez 7c8f275a24 redis-cli: really connect to the right server.
I recently introduced populating the autocomplete help array with the
COMMAND command if available. However this was performed before parsing
the arguments, defaulting to instance 6379. After the connection is
performed it remains stable.

The effect is that if there is an instance running on port 6339,
whatever port you specify is ignored and 6379 is connected to instead.
The right port will be selected only after a reconnection.

Close #3314.
2016-06-16 17:23:31 +02:00
Jan-Erik Rediger 892565f924 Remove debug printing 2016-05-21 13:50:01 +02:00
antirez 8eb43bf72c redis-cli: integrate help.h with COMMAND output.
Use the COMMAND output to fill with partial information the built-in
help. This makes redis-cli able to at least complete commands that are
exported by the Redis server it is connected to, but were not available
in the help.h file when the redis-cli binary was compiled.
2016-05-07 13:03:25 +02:00
antirez 94dc71ff08 redis-cli: remove debugging message. 2016-05-05 18:05:37 +02:00
Salvatore Sanfilippo 7b90815fc3 Merge pull request #3008 from badboy/fix-2911
Fix nanosecond conversion
2016-05-05 16:21:21 +02:00
antirez 02db338a82 redis-cli: don't free historyfile, is used later. 2016-05-05 13:58:06 +02:00
Salvatore Sanfilippo a4df156872 Merge pull request #3077 from Palethorn/ipv6-redirect-parse
Fix for #3076 Reverse redirect address parse
2016-05-05 10:13:00 +02:00
antirez b632f7846b Minor redis-cli wording change in --help output. 2016-05-04 22:34:26 +02:00
Oran Agra f8909a2579 add DEBUG JEMALLC PURGE and JEMALLOC INFO cleanup 2016-04-25 16:47:42 +03:00
antirez e0eb5f6bbf redis-cli preferences and rc file support. 2016-04-13 14:20:41 +02:00
antirez d1ddf7e958 redis-cli hints. 2016-04-13 12:34:14 +02:00
David Cavar c30ffaab05 Reverse redirect address parse
Fix issue in case the redirect address is in ipv6 format. Parse from behind to extract last part of the response which represents actual port.
2016-02-09 15:04:42 +01:00
Jan-Erik Rediger 15dacfec6f Fix nanosecond conversion
1 microsecond = 1000 nanoseconds
1e3 = 1000
10e3 = 10000
2016-01-13 10:22:29 -07:00
antirez 7c1a5ff3ce Lua debugger: support direct calls to SCRIPT DEBUG in redis-cli.
Previously it was possible to activate a debugging session only using
the --ldb option in redis-cli. Now calling SCRIPT DEBUG can also
activate the debugging mode without putting the redis-cli in a
desynchronized state.

Related to #2952.
2016-01-08 09:43:16 +01:00
antirez 96628cc40d fix sprintf and snprintf format string
There are some cases of printing unsigned integer with %d conversion
specificator and vice versa (signed integer with %u specificator).

Patch by Sergey Polovko. Backported to Redis from Disque.
2015-11-28 09:05:41 +01:00
antirez 6604e04260 Lua debugger: redis-cli: allow restart after end of session. 2015-11-17 15:43:24 +01:00
antirez 58573f1dd2 Lua debugger: redis-cli can restart Lua debugging sessions. 2015-11-17 15:43:24 +01:00
antirez 0cc19174f9 Lua debugger: maxlen command implemented.
Let the user control the replies truncation.
2015-11-17 15:43:24 +01:00
antirez 22959e07dc Lua debugger: redis-cli: show compile errors in LDB mode. 2015-11-17 15:43:24 +01:00
antirez 6de2306add Lua debugger: redis-cli error when --ldb is without --eval.
Otherwise the result is a messed CLI without prompt.
Thanks to Itamar Haber for reporting this issue.
2015-11-17 15:43:23 +01:00
antirez e57cccdefb Lua debugger: use sds_malloc() to allocate eval cli array.
Redis-cli handles the debugger "eval" command in a special way since
sdssplitargs() would not be ok: we need to send the Redis debugger the
whole Lua script without any parsing. However in order to later free the
argument vector inside redis-cli using just sdsfreesplitres(), we need
to allocate the array of SDS pointers using the same allocator SDS is
using, that may differ to what Redis is using.

So now a newer version of SDS exports sds_malloc() and other allocator
functions to give access, to the program it is linked to, the allocator
used internally by SDS.
2015-11-17 15:43:23 +01:00
antirez 87672adee2 Lua debugger: better support for synchronous mode. 2015-11-17 15:43:22 +01:00
antirez 3ab0b4d6d0 Lua debugger: inform user changes are rolled back.
When redis-cli will support the synchronous mode, this will not be
printed.
2015-11-17 15:43:22 +01:00
antirez e386cd8ccf Lua debugger: clear end of session protocol.
When the debugger exits now it produces an <endsession> tag that informs
redis-cli (or other debugging clients) that the session terminated.
This way the client knows there is yet another reply to read (the one of
the EVAL script itself), and can switch to non-debugging mode ASAP.
2015-11-17 15:43:22 +01:00
antirez 7492237c3c Lua debugger: redis.debug() implemented. 2015-11-17 15:43:22 +01:00
antirez 23a4d70e56 Lua debugger: redis-cli, mark end of debugging session. 2015-11-17 15:43:22 +01:00
antirez 1f8fdafe65 Lua debugger: much better Lua values pretty printer. 2015-11-17 15:43:21 +01:00
antirez cf4700bda4 Lua debugger: output improvements, eval command. 2015-11-17 15:43:21 +01:00
antirez 1f8d614423 Lua debugger: breakpoints. 2015-11-17 15:43:21 +01:00
antirez 5417217c87 Lua debugger: log Redis commands. List command. 2015-11-17 15:43:21 +01:00
antirez d3d1fa9437 Lua debugger: initial REPL. 2015-11-17 15:43:20 +01:00
antirez c494db89b5 Lua debugger: foundations implemented. 2015-11-17 15:43:20 +01:00
antirez d1b6a17d1e redis-cli pipe mode: don't stay in the write loop forever.
The code was broken and resulted in redis-cli --pipe to, most of the
times, writing everything received in the standard input to the Redis
connection socket without ever reading back the replies, until all the
content to write was written.

This means that Redis had to accumulate all the output in the output
buffers of the client, consuming a lot of memory.

Fixed thanks to the original report of anomalies in the behavior
provided by Twitter user @fsaintjacques.
2015-09-30 16:24:21 +02:00
ubuntu 11381b09d9 SCAN iter parsing changed from atoi to chartoull 2015-09-07 11:20:52 +00:00
antirez 32f80e2f1b RDMF: More consistent define names. 2015-07-27 14:37:58 +02:00
Oran Agra f15df8ba5d sds size classes - memory optimization 2015-07-14 17:17:06 +02:00
antirez 0f64080dcb DEBUG HTSTATS <dbid> added.
The command reports information about the hash table internal state
representing the specified database ID.

This can be used in order to investigate rehashings, memory usage issues
and for other debugging purposes.
2015-07-14 17:15:37 +02:00
antirez f638f045ce redis-cli --latency-dist: one gray more, and --mono support. 2015-02-13 14:38:21 +01:00
antirez 3101d2bffb redis-cli --latency-dist, hopefully better palette.
Less grays: more readable palette since usually we have a non linear
distribution of percentages and very near gray tones are hard to take
apart. Final part of the palette is gradient from yellow to red. The red
part is hardly reached because of usual distribution of latencies, but
shows up mainly when latencies are very high because of the logarithmic
scale, this is coherent to what people expect: red = bad.
2015-02-13 12:52:46 +01:00
antirez 05841a6386 redis-cli --stat: show LOAD when loading. 2015-02-11 10:52:27 +01:00
antirez bd128f7969 redis-cli --lru-test implemented (cache workload simulator). 2015-02-09 11:06:55 +01:00
antirez ca23b2a6b7 redis-cli: interactive reconnection for latency modes.
--stat mode already used to reconnect automatically if the server is no
longer available. This is useful since this is an interactive mode used
for debugging, however the same applies to --latency and --latency-dist
modes, so now both use the reconnecting command execution as well.

The reconnection code was modified to use basic VT100 escape sequences
in order to play better with different kinds of output on the screen
when the reconnection happens, and to hide the reconnection attempt
output when finally the reconnection happens.
2015-02-08 23:28:27 +01:00
antirez cfe21852e7 redis-cli --latecy-dist reverted to gray scale.
So far not able to find a color palette within the 256 colors which is
not confusing. However I believe it is a possible task, so will try
better later.
2015-02-08 17:39:42 +01:00
antirez 2723412b7b redis-cli --latency-dist now uses a color palette.
Still not happy with the result but low grays are hard to see in certain
monitors with a non perfect gamma.
2015-02-07 20:15:40 +01:00
antirez ace1acc532 redis-cli latency dist: add new top HL. 2015-02-07 18:06:14 +01:00
antirez 414df143f5 Add missing latency-dest legend symbol. 2015-02-07 15:05:40 +01:00
antirez 2860cf4139 Initial implementation of redis-cli --latency-dist. 2015-02-07 15:00:38 +01:00
mattcollier 6ec5f1f780 Update redis-cli.c
Code was adding '\n'  (line 521) to the end of NIL values exlusively making csv output inconsistent.  Removed '\n'
2015-01-25 14:01:39 -05:00
Jan-Erik Rediger 04607b5350 Check that the whole first argument is a number
Fixes #2258
2015-01-07 22:31:45 +01:00
Matt Stancliff 27937c2821 Add DEBUG JEMALLOC INFO
Uses jemalloc function malloc_stats_print() to return
stats about what jemalloc has allocated internally.
2014-12-23 09:31:03 -05:00
antirez ce269ad3c5 AnetFormatIP(): renamed, commented, now sticks to IP:port format.
A few code style changes + consistent format: not nice for humans but
better for parsers.
2014-12-11 18:20:30 +01:00
Matt Stancliff 491881e13b Cleanup all IP formatting code
Instead of manually checking for strchr(n,':') everywhere,
we can use our new centralized IP formatting functions.
2014-12-11 10:12:18 -05:00
Salvatore Sanfilippo 599e52d93e Merge pull request #2106 from NanXiao/unstable
Fix function prototype in redis-cli.c.
2014-12-11 15:08:51 +01:00
Salvatore Sanfilippo 4ff365b34a Merge pull request #2114 from h0x91b/redis-cli-fix-cluster
Reconnect redis-cli when cluster return "moved"
2014-12-11 14:58:37 +01:00
Salvatore Sanfilippo 3da87b70dd Merge pull request #2133 from chooper/histfile-override
override histfile from env - fixes #831 and copies #833
2014-12-10 15:28:41 +01:00
Jan-Erik Rediger 7ecb880168 Only ignore sigpipe in interactive mode
This allows shell pipes to correctly end redis-cli.

Ref #2066
2014-12-09 00:58:42 +01:00
antirez e039791e39 Document redis-cli --stat in --help output. 2014-11-25 18:23:40 +01:00
Charles Hooper 3ab832193c override histfile from env - fixes #831 and copies #833 2014-11-10 22:40:25 -08:00
h0x91b 7fcfbea0f5 Reconnect redis-cli when cluster return "moved"
if redis works in cluster-mode and redis-cli was run with argv, reconnect if needs.
    example:
    ./redis-cli set foo bar

    if return is MOVED redis-cli just do nothing.
2014-10-30 21:07:07 +02:00
Matt Stancliff e10c5444e7 redis-cli: ignore SIGPIPE network errors
Closes #2066
2014-10-29 14:55:08 -04:00
Nan Xiao 2540736366 Fix function prototype in redis-cli.c.
Fix function prototype in redis-cli.c.
2014-10-27 17:53:12 +08:00
antirez 93eed9ae01 redis-cli: add missing newline in error message. 2014-10-15 09:21:02 +02:00
Dov Murik 233d24a737 redis-cli: fix prompt after shutdown command
Fix redis-cli prompt to state "not connected" after a SHUTDOWN command
is sent.
2014-08-18 11:05:36 +02:00
antirez edca2b14d2 Remove warnings and improve integer sign correctness. 2014-08-13 11:44:38 +02:00
charsyam 354119e4c5 Remove unused LINE_BUFLEN definition
Closes #1129
2014-08-08 14:05:02 +02:00
cubicdaiya 23f08510d5 Use 'void' for zero-argument functions
According to the C standard,
it is desirable to give the type 'void'
to functions have no argument.

Closes #1631
2014-08-08 10:05:32 +02:00
Kashif Rasul c49378fe3e Fix issues raised by clang analyzer
Modified by @antirez since the original fix to genInfoString() looked
weak. Probably the clang analyzer complained about `section` being
possibly NULL, and strcasecmp() called with a NULL pointer. In the
practice this can never happen, still for the sake of correctness
the right fix is not to modify only the first call, but to set `section`
to the value of "default" if it happens to be NULL.

Closes #1660
2014-08-07 17:08:11 +02:00
Jan-Erik Rediger 05676c5d16 redis-cli: fix latency result output
(Cleaned up a little by @mattsta)

Closes #1774
2014-08-07 12:26:45 +02:00
Matt Stancliff 426553164d redis-cli: Add --no-raw option
Some people need formatted output even when they have no
interactive tty.

Fixes #760
2014-08-07 12:07:01 +02:00
Matt Stancliff 0042fb0eb0 redis-cli: stop showing incorrectly selected DB
Previously redis-cli would happily show "-1" or "99999"
as valid DB choices.

Now, if the SELECT call returned an error, we don't update
the DB number in the CLI.

Inspired by @anupshendkar in #1313

Fixes #566, #1313
2014-08-07 12:04:33 +02:00
Matt Stancliff bbc1cd0bd9 redis-cli: Re-attach selected DB after auth
Previously, if you did SELECT then AUTH, redis-cli
would show your SELECT'd db even though it didn't
happen.

Note: running into this situation is a (hopefully) very limited
used case of people using multiple DBs and AUTH all at the same
time.

Fixes antirez#1639
2014-08-07 11:58:28 +02:00
antirez 2a232dfa9a LATENCY DOCTOR: initial draft and events summary output. 2014-07-08 11:31:46 +02:00
antirez aa16f87b87 LATENCY GRAPH implemented. 2014-07-02 16:31:22 +02:00
antirez 95b1979c32 No more trailing spaces in Redis source code. 2014-06-26 18:48:40 +02:00
Alex Suraci 9f8dcfe69a add missing signal.h include 2014-06-17 21:59:12 -07:00
Matt Stancliff 20c2a38ad0 Add SIGINT handler to cli --intrinsic-latency
If we run a long latency session and want to Ctrl-C out of it,
it's nice to still get the summary output at the end.
2014-06-17 10:12:57 -04:00
Andy Grunwald 94e3bb568a Fixed typo in word avarege in result message of --intrinsic-latency analyzer 2014-05-22 20:01:12 +02:00
antirez 429aff4ef4 Linenoise updated, multiline mode enabled in redis-cli. 2014-03-13 15:11:08 +01:00
michael-grunder 806788d009 Improved bigkeys with progress, pipelining and summary
This commit reworks the redis-cli --bigkeys command to provide more
information about our progress as well as output summary information
when we're done.

 - We now show an approximate percentage completion as we go
 - Hiredis pipelining is used for TYPE and SIZE retreival
 - A summary of keyspace distribution and overall breakout at the end
2014-02-27 12:01:57 -08:00
antirez 55e36e1132 Merge branch 'bigkeys_scan' of git://github.com/michael-grunder/redis into unstable 2014-02-25 14:59:57 +01:00
michael-grunder 013a4ce242 Update --bigkeys to use SCAN
This commit changes the findBigKeys() function in redis-cli.c to use the new
SCAN command for iterating the keyspace, rather than RANDOMKEY.  Because we
can know when we're done using SCAN, it will exit after exhausting the keyspace.
2014-02-25 05:41:30 -08:00
antirez a2c76ffb1c redis-cli: also remove useless uint8_t. 2014-02-25 13:47:37 +01:00
antirez ba993cc685 redis-cli: don't use uint64_t where actually not needed.
The computation is just something to take the CPU busy, no need to use a
specific type. Since stdint.h was not included this prevented
compilation on certain systems.
2014-02-25 13:44:31 +01:00
antirez 5580350a7b redis-cli: check argument existence for --pattern. 2014-02-25 12:38:29 +01:00
antirez c1d67ea9b4 redis-cli: --intrinsic-latency run mode added. 2014-02-25 12:37:52 +01:00
antirez dcac007b81 redis-cli: added comments to split program in parts. 2014-02-25 12:24:45 +01:00
Matt Stancliff 21648473aa Auto-enter slaveMode when SYNC from redis-cli
If someone asks for SYNC or PSYNC from redis-cli,
automatically enter slaveMode (as if they ran
redis-cli --slave) and continue printing the replication
stream until either they Ctrl-C or the master gets disconnected.
2014-02-10 11:10:31 -05:00
antirez 1cf532dc37 redis-cli --help output improved with --scan and periods. 2014-01-22 12:07:42 +01:00
antirez 994c5b26dd redis-cli: support for --scan option. 2014-01-22 12:04:08 +01:00
Michel Martens 347ab78e90 Document the redis-cli --csv option. 2013-09-26 10:12:46 +02:00
antirez 2debce325b redis-cli: fix big keys search when the key no longer exist.
The code freed a reply object that was never created, resulting in a
segfault every time randomkey returned a key that was deleted before we
queried it for size.
2013-09-04 10:35:53 +02:00
Jan-Erik Rediger 1b696dc07c Wrap IPv6 in brackets in the prompt. 2013-07-11 17:47:55 +02:00
antirez 1135e9faa2 redis-cli: introduced --pipe-timeout.
When in --pipe mode, after all the data transfer to the server is
complete, now redis-cli waits at max the specified amount of
seconds (30 by default, use 0 to wait forever) without receiving any
reply at all from the server. After this time limit the operation is
aborted with an error.

That's related to issue #681.
2013-07-03 12:22:03 +02:00
antirez fbb97c6b13 redis-cli --pipe: send final ECHO in a safer way.
If the protocol read from stdin happened to contain grabage (invalid
random chars), in the previous implementation it was possible to end
with something like:

dksfjdksjflskfjl*2\r\n$4\r\nECHO....

That is invalid as the *2 should start into a new line. Now we prefix
the ECHO with a CRLF that has no effects on the server but prevents this
issues most of the times.

Of course if the offending wrong sequence is something like:

$3248772349\r\n

No one is going to save us as Redis will wait for data in the context of
a big argument, so this fix does not cover all the cases.

This partially fixes issue #681.
2013-07-03 11:59:44 +02:00
antirez f8ae70cf7c redis-cli: raise error on bad command line switch.
Previously redis-cli never tried to raise an error when an unrecognized
switch was encountered, as everything after the initial options is to be
transmitted to the server.

However this is too liberal, as there are no commands starting with "-".
So the new behavior is to produce an error if there is an unrecognized
switch starting with "-". This should not break past redis-cli usages
but should prevent broken options to be silently discarded.

As far the first token not starting with "-" is encountered, all the
rest is considered to be part of the command, so you cna still use
strings starting with "-" as values, like in:

    redis-cli --port 6380 set foo --my-value
2013-04-11 13:17:25 +02:00
antirez 0280c2f252 redis-cli: --latency-history mode implemented. 2013-04-11 13:11:41 +02:00
antirez 09aa55a334 redis-cli --stat, stolen from redis-tools.
Redis-tools is a connection of tools no longer mantained that was
intented as a way to economically make sense of Redis in the pre-vmware
sponsorship era. However there was a nice redis-stat utility, this
commit imports one of the functionalities of this tool here in redis-cli
as it seems to be pretty useful.

Usage: redis-cli --stat

The output is similar to vmstat in the format, but with Redis specific
stuff of course.

From the point of view of the monitored instance, only INFO is used in
order to grab data.
2013-03-22 17:54:32 +01:00
antirez 91d3b487e7 redis-cli --bigkeys: don't crash with empty DBs. 2013-03-12 09:58:00 +01:00
antirez 8c193af696 redis-cli: use sdsfreesplitres() instead of hand-coding it. 2013-03-06 12:38:32 +01:00