#!/usr/bin/python #-*- coding:utf-8 -*- # by MO #DATA 2018-08-02 import redis import datetime RedisHostMessage={ 'test':[{'Host':'***', 'Port':6379, 'Pwd':None}], } #查询slowlog def SlowlogGet(*args): slowlog = connect.slowlog_get() for msg in slowlog: print(Host) for key in msg: if key == 'start_time': print(key, ':', datetime.datetime.fromtimestamp(msg[key])) #进行时间转换,unix时间转换 continue print(key,':',msg[key]) print('----------ID-----------') # print(slowlog) #查询redis配置 def ConfigGet(*args): config = connect.config_get(pattern='slowlog*') for key in config: print(key,config[key]) #修改redis配置 def ConfigSet(*args): # connect.config_set('slowlog-log-slower-than',50000) #配置slowlog阈值时间50ms connect.slowlog_reset() #重置slowlog list for key in RedisHostMessage: for message in RedisHostMessage[key]: Host=message['Host'] Port=message['Port'] Pwd=message['Pwd'] connect = redis.Redis(host=Host, port=Port, password=Pwd) # print(Host,Port,Pwd) # SlowlogGet(connect) ConfigSet(connect) SlowlogGet(connect)
redis_config
原创
©著作权归作者所有:来自51CTO博客作者zmoke的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:zabbix_mongodb监控
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章