105 Commits

Author SHA1 Message Date
antirez
fbbc8f30e1 redis-cli: check argument existence for --pattern. 2014-02-25 12:38:29 +01:00
antirez
a803a0effa redis-cli: --intrinsic-latency run mode added. 2014-02-25 12:37:52 +01:00
antirez
dca8162093 redis-cli: added comments to split program in parts. 2014-02-25 12:24:45 +01:00
Matt Stancliff
33569106bc 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
a166f49794 redis-cli --help output improved with --scan and periods. 2014-01-22 12:07:42 +01:00
antirez
d97e8ccd5c redis-cli: support for --scan option. 2014-01-22 12:04:08 +01:00
Michel Martens
17ce9a8da0 Document the redis-cli --csv option. 2013-09-26 10:12:46 +02:00
antirez
ee99df2d59 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
b08b0beb04 Wrap IPv6 in brackets in the prompt. 2013-07-11 17:47:55 +02:00
antirez
01430e6599 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
703cd738dc 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
cb2d627e8d 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
80b47765af redis-cli: --latency-history mode implemented. 2013-04-11 13:11:41 +02:00
antirez
5ee22f70e7 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
2e0f6a0a0c redis-cli --bigkeys: don't crash with empty DBs. 2013-03-12 09:58:00 +01:00
antirez
987c4c9567 redis-cli: use sdsfreesplitres() instead of hand-coding it. 2013-03-06 12:38:32 +01:00
antirez
824879435c redis-cli: use keepalive socket option.
This should improve things in two ways:

1) Prevent timeouts caused by the execution of long commands.
2) Improve detection of real connection errors.

This is mostly effective only on Linux because of the bogus default
keepalive settings. In Linux we have OS-specific calls to set the
keepalive interval to reasonable values.
2013-03-04 11:14:32 +01:00
antirez
751b523fb8 redis-cli: update prompt on cluster redirection. 2013-02-14 18:49:08 +01:00
antirez
ba7a3e1b79 redis-cli --bigkeys output is now simpler to understand. 2013-01-21 19:15:58 +01:00
guiquanz
df7a5b7157 Fixed many typos. 2013-01-19 10:59:44 +01:00
Salvatore Sanfilippo
188ad22ff7 Merge pull request #887 from charsyam/redis-cli-prompt
redis-cli prompt bug fix
2013-01-19 01:32:28 -08:00
Salvatore Sanfilippo
cff7e102bb Merge pull request #895 from badboy/catch_con_error
redis-cli: always exit if connection fails.
2013-01-19 01:27:56 -08:00
Jan-Erik Rediger
2d31425356 Always exit if connection fails.
This avoids unnecessary core dumps. Fixes antirez/redis#894
2013-01-18 10:13:10 +01:00
Nathan Parry
49ea5589c0 redis-cli --rdb fails if server sends a ping
Redis pings slaves in "pre-synchronization stage" with newlines. (See
https://github.com/antirez/redis/blob/2.6.9/src/replication.c#L814)
However, redis-cli does not expect this - it sees the newline as the end
of the bulk length line, and ends up returning 0 as bulk the length.
This manifests as the following when running redis-cli:

    $ ./src/redis-cli --rdb some_file
    SYNC sent to master, writing 0 bytes to 'some_file'
    Transfer finished with success.

With this commit, we just ignore leading newlines while reading the bulk
length line.

To reproduce the problem, load enough data into Redis so that the
preparation of the RDB snapshot takes long enough for a ping to occur
while redis-cli is waiting for the data.
2013-01-18 00:10:58 -05:00
charsyam
5596ba6ede redis-cli prompt bug fix 2013-01-16 17:20:54 -08:00
antirez
64c7380fa4 redis-cli: save an RDB dump from remote server to local file. 2013-01-16 19:44:37 +01:00
antirez
1d235fa5ad Fix overflow in mstime() in redis-cli and benchmark.
The problem does not exist in the Redis server implementation of mstime()
but is only limited to redis-cli and redis-benchmark.

Thix fixes issue #839.
2012-12-20 15:20:55 +01:00
antirez
a32d1ddff6 BSD license added to every C source and header file. 2012-11-08 18:31:32 +01:00
Steeve Lennmark
16609e29b4 Check that we have connection before enabling pipe mode 2012-07-15 14:35:02 +02:00
Ted Nyman
a5ca4519ad Standardize punctuation in redis-cli help.
Right there is a mix of help entries ending with periods or
without periods. This standardizes the end of command as without
periods, which seems to be the general custom in most unix tools,
at least.
2012-06-12 22:35:00 -07:00
antirez
b19eaa4b29 Added time.h include in redis-cli.
redis-cli.c uses the time() function to seed the PRNG, but time.h was
not included. This was not noticed since sys/time.h is included and was
enough in most systems (but not correct). With Ubuntu 12.04 GCC
generates a warning that made us aware of the issue.
2012-05-14 17:35:51 +02:00
antirez
a7be5ac4fe redis-cli pipe mode: handle EINTR properly as well so that SIGSTOP/SIGCONT are handled correctly. 2012-05-11 16:08:57 +02:00
antirez
0e122a8022 redis-cli pipe mode: handle EAGAIN while writing to socket. 2012-05-11 10:45:12 +02:00
antirez
7ba8e7081c redis-cli --pipe for mass import. 2012-05-07 16:37:18 +02:00
antirez
6c6d6d8194 A few compiler warnings suppressed. 2012-04-24 11:11:55 +02:00
antirez
743282429d redis-cli --bigkeys output modified to be simpler to read.. 2012-04-18 20:53:37 +02:00
antirez
fbe8b2f6d3 redis-cli --bigkeys 2012-04-18 20:33:02 +02:00
antirez
4f615b696c Suppress warnings compiling redis-cli with certain gcc versions. 2012-03-19 19:28:49 +01:00
antirez
caa58bc830 redis-cli: CSV output added, used for the --slave mode. 2012-02-29 17:43:06 +01:00
antirez
6f484a0704 Initial implementation of redis-cli --slave support. 2012-02-29 17:10:21 +01:00
antirez
ff804069d4 Fix for issue #306, thanks to tchajed (on github) for the pull request. The original patch was reworked a bit. 2012-02-22 16:07:06 +01:00
antirez
520490dd25 Redis-cli should accept help command even if there is no connection to the server. 2012-02-22 15:16:11 +01:00
antirez
921feadb64 redis-cli --eval implemented 2011-12-13 16:22:28 +01:00
antirez
8efbbaf821 Fixed a memory leak in redis-cli.c 2011-10-28 17:43:04 +02:00
antirez
5d78296230 Totally hackish and dirty, but working, support for Redis Cluster in redis-cli 2011-10-05 19:55:33 +02:00
Salvatore Sanfilippo
bcbb91e6e3 Merge pull request #97 from jvain/redis-cli
redis-cli segfaults with single numeric argument greater than zero
2011-09-21 13:32:24 -07:00
Juri M. Vainonen
2d52506bc2 fixed a small bug that caused redis-cli to segfault when given single numeric parameter greater that zero. 2011-09-21 23:22:14 +03:00
antirez
68c4acd91b Fixed a bug in the average latency metering of redis-cli --latency 2011-09-15 19:33:24 +02:00
antirez
84c42e7da3 Implemented --latency in redis-cli 2011-09-15 19:28:00 +02:00
antirez
e257c6bd24 redis-cli: -i (interval) implemented, to wait the specified number of seconds (decimal digits are allowed) between commands. 2011-05-28 15:41:08 +02:00