Redis Monitor Server
Redis Monior is a stand alone server written to monitor one or multiple redis servers. Its primary use is to allow you to automate the testing of applications that interface directly with Redis
from monitor import RedisMonitor
rm = RedisMonitor(redis_ports=[6370])
# execute your code..
rm.get_last_command() # return the last command run against the redis server
rm.get_all_commands() # return all commands run against the redis server
rm.reset() # reset the command history
...
Download one liner:
git clone https://github.com/ninjapenguin/redis-monitor-server.git
To install dependencies
pip install -r requirements.txt
from monitor import RedisMonitor
rm = RedisMonitor(redis_ports=[6997,6998])
# do a test
rm.get_last_command() # returns the last command run accross all instances
rm.get_last_command_by_instance(6997) # returns the last command run on instance @ port 6997
rm.get_all_commands() # returns all commands run to date
rm.get_command_counts() # returns a dict of port => number of commands recorded
rm.reset() # reset the current lists..
# do another test...
rm.shutdown()
To start the redis monitoring server listening on two local ports:
python monitor.py --redis_port 6997 6998
You are then able to communicate with server using zmq REQ socket directly:
import zmq
context = zmq.Context()
socket = context.socket(zmq.REQ)
socket.connect("tcp://localhost:5559")
socket.send('last')
response = socket.recv()
# response == u'keys *'
require "zmq"
local context = zmq.init(1)
local socket = context:socket(zmq.REQ)
socket:connect("tcp://localhost:5559")
socket:send('last')
local response = socket:recv()
$context = new ZMQContext();
$socket = new ZMQSocket($context, ZMQ::SOCKET_REQ);
$socket->connect("tcp://localhost:5559");
$socket->send("last");
$response = $socket->recv();