Overview

REDIS MONITOR

Parse & generate alerts from Redis real-time MONITOR output

The class will parse the MONITOR output from a Redis server and call one or more listener callbacks for each command received.

The signature of the listener callback is:

f(verb,key,args,data)
  • Listener callbacks are attached using the add_listener(f) method.
  • If a listener raises 'Unregister' it will be unregistered
  • If a listener raises 'ExitLoop' the asyncore loop will be terminated (even if there are other active listeners)

Basic Usage:

def debug_listener(verb,key,args,data):
print (verb,key,args,data)

m = RedisMonitor() m.add_listener(debug_listener) asyncore.loop()

To listen & return specific data it is easiest to use a class with an appropriate __call__ method (KeyListener provides an example which listens for updates a specific key):

m = RedisMonitor() l = KeyListener('xxx') m.add_listener(l) asyncore.loop() print l.cmd