redis3.0集群状态监控for zabbix 需要python2.7
2015-11-06 20:32
966 查看
#coding=utf-8 __author__ = 'yuan.ran@msxf.com' '''This scripte use to monitor online redis cluster status and nodes status! need python 2.7''' import os,sys,time,traceback from rediscluster import StrictRedisCluster cluster_nodes = [{"host":"Redis1.xxxxx.db","port":"7000"},{"host":"Redis1.xxxxx.db","port":"7001"},{"host":"Redis2.xxxxx.db","port":"7002"}, {"host":"Redis2.xxxxx.db","port":"7003"},{"host":"Redis3.xxxxx.db","port":"7004"},{"host":"Redis3.xxxxx.db","port":"7005"}] try: rc = StrictRedisCluster(startup_nodes=cluster_nodes, decode_responses=True) except Exception, err: print err print 'failed to connect redis cluster!' sys.exit(0) def getClusterStatus(): cs = rc.execute_command('cluster','info') clusterstatus = cs.split('\r')[0].split(':') if clusterstatus[1] == 'ok': rediscluster = 0 else: rediscluster = 1 print rediscluster def getClusterNode(): cn = rc.execute_command('cluster','nodes') nodescount1 = cn.count("connected") nodescount2 = cn.count("disconnected") nodescount = nodescount1 - nodescount2 print nodescount if __name__ == '__main__': if str(sys.argv[1]) == 'nodes': getClusterNode() elif str(sys.argv[1]) == 'status': getClusterStatus()
相关文章推荐
- redis3.0集群状态监控脚本用于zabbix监控需要python2.6
- redis常用命令
- java对redis各种数据类型的基本操作
- redis集群实战
- 使用HAProxy、PHP、Redis和MySQL支撑10亿请求每周架构细节
- Ubuntu下安装redis及php扩展
- ubuntu 安装redis
- Redis
- java redis
- Redis微博推的实现
- redis bitmap实现签到
- 用Redis存储Tomcat集群的Session
- Redis常用命令操作
- Redis服务器搭建/配置/及Jedis客户端的使用方法
- Redis缓存服务器的配置
- 内存数据库Redis小Demo 包括持久性测试
- Redis常用命令
- Using Redis to store php session
- redis 学习笔记(1)-编译、启动、停止
- redis 学习笔记(2)-client端示例代码