Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is there a way to get the client IP in redis?

Tags:

redis

I did a web search but found nothing on this. I am running redis on a cluster and would like to find out which machine is connecting to redis ( especially when no machine is supposed to be connecting, but redis still says some machine connected).

thanks in advance.

like image 525
qkhhly Avatar asked Jul 26 '12 02:07

qkhhly


People also ask

How do I find my Redis client?

To start Redis client, open the terminal and type the command redis-cli. This will connect to your local server and now you can run any command. In the above example, we connect to Redis server running on the local machine and execute a command PING, that checks whether the server is running or not.

What is client list in Redis?

Redis CLIENT LIST command returns the information and statistics about the client connections server in a human readable format.

What is Redis IP?

By default, redis-cli connects to the server at the address 127.0. 0.1 with port 6379.

How do I see active connections in Redis?

If you run the "client list" command against your Redis instance, you should be able to see the entire list of clients connected to your redis instance along with their IP addresses. You can then see which clients (services) have the highest number of connections to your Redis instance.


2 Answers

With MONITOR, only the clients actually sending traffic to Redis will be shown. If you just need to get a list of connected clients, you can use the CLIENT LIST command.

$ redis-cli client list

It will return a table whose fields are described there:

Redis "Client List" purpose and description

like image 105
Didier Spezia Avatar answered Sep 28 '22 00:09

Didier Spezia


Did you try the MONITOR command?

http://redis.io/commands/monitor

 $ redis-cli monitor
 1339518083.107412 [0 127.0.0.1:60866] "keys" "*"
 1339518087.877697 [0 127.0.0.1:60866] "dbsize"
 1339518090.420270 [0 127.0.0.1:60866] "set" "x" "6"
 1339518096.506257 [0 127.0.0.1:60866] "get" "x"
 1339518099.363765 [0 127.0.0.1:60866] "del" "x"
 1339518100.544926 [0 127.0.0.1:60866] "get" "x"
 Use SIGINT (Ctrl-C) to stop a MONITOR stream running via redis-cli.

 # OR 
 $ telnet localhost 6379
 Trying 127.0.0.1...
 Connected to localhost.
 Escape character is '^]'.
 MONITOR
 +OK
 +1339518083.107412 [0 127.0.0.1:60866] "keys" "*"
 +1339518087.877697 [0 127.0.0.1:60866] "dbsize"
 +1339518090.420270 [0 127.0.0.1:60866] "set" "x" "6"
 +1339518096.506257 [0 127.0.0.1:60866] "get" "x"
 +1339518099.363765 [0 127.0.0.1:60866] "del" "x"
 +1339518100.544926 [0 127.0.0.1:60866] "get" "x"
 QUIT
 +OK
 Connection closed by foreign host.
like image 45
Jeff Shelman Avatar answered Sep 28 '22 00:09

Jeff Shelman