python2监控redis读取速度
1、主要是导入redis模块,如果不存在则执行pip install redis 安装。
#!/usr/bin/env python import redis import time ip=‘10.12.41.16‘ password=‘Tvgpg#cdz‘ r=redis.Redis(host=ip,password=password,port=16379,db=0) while True: localtime = time.asctime( time.localtime(time.time()) ) start_time = time.time() res=r.get(‘k1‘) end_time = time.time() time.sleep(5) running_time = end_time - start_time print("keys:%s running_time : %.5f sec localtime:%s" %(res,running_time,localtime))
2、放到后台运行并写入文件
[ redis_monitor]# nohup -u check_python.py >redis_out.txt &
相关推荐
王道革 2020-11-25
wangdonghello 2020-11-03
Langeldep 2020-11-16
chenhualong0 2020-11-16
聚合室 2020-11-16
koushr 2020-11-12
MRFENGG 2020-11-11
guoyanga 2020-11-10
fackyou00 2020-11-10
Orangesss 2020-11-03
dongCSDN 2020-10-31
rainandtear 2020-10-30
Quietboy 2020-10-30
liuyulong 2020-10-29
fansili 2020-10-29
温攀峰 2020-10-23
jackbon 2020-10-19
kaixinfelix 2020-10-04