File: //lib/python2.7/site-packages/lap/redis_check.py
import redis
import yaml
def __run__(params):
REDIS_HOST = params.get('host','localhost')
REDIS_PORT = int(params.get('port',6379))
REDIS_DB = int(params.get('db',0))
try:
r = redis.Redis(host=REDIS_HOST,port=REDIS_PORT,db=REDIS_DB)
check = r.set('check_redis','0')
result = r.get('check_redis')
if not r.exists('check_redis'):
return [2, "CRITICAL - Error: Redis key not found"]
else:
return [0, "OK - OK: Redis working"]
clear = r.delete('check_redis')
except Exception, e:
return [2, "CRITICAL - Error: %s" % repr(e)]