Redis server
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
README.md
monitor.py
requirements.txt

README.md

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

TL;DR;

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
...

Contents

Download

Download one liner:

git clone https://github.com/ninjapenguin/redis-monitor-server.git

Installation

To install dependencies

pip install -r requirements.txt

Quickstart

Option 1: Bootstrapping via python RedisMonitor class

from monitor import RedisMonitor

rm = RedisMonitor(redis_ports=[6997,6998])

# do a test
rm.get_last_command()	# returns the last command run across 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()

Option 2: Run the server manually and connect externally

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:

Python

import zmq
context = zmq.Context()

socket = context.socket(zmq.REQ)
socket.connect("tcp://localhost:5559")
socket.send('last')
response = socket.recv()
# response == u'keys *'

Lua

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()

PHP

$context = new ZMQContext();

$socket = new ZMQSocket($context, ZMQ::SOCKET_REQ);
$socket->connect("tcp://localhost:5559");
$socket->send("last");
$response = $socket->recv();