1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env python
#author:taoyake
#date:2017-07-26
import redis
import sys
import socket
class Check_Redis:
def __init__(self,port,key):
self.host = 127.0.0.1
self.password = 123456
self.port = sys.argv[1]
self.key = sys.argv[2]
def Connect_Redis(self):
r = redis.Redis(host = self.host,port = self.port,password = self.password,db=0)
value = r.info()[self.key]
if value == "up":
print 1
elif value == "down":
print 0
else:
print value
Foo = Check_Redis('port','key')
Foo.Connect_Redis()