Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
memcache checker
#!/usr/bin/python
# memcache_checker.py
#
# checks a list of memcache servers for a given key
# usage: memcache_checker.py <key>
import sys
import socket
# a list of (host, port) tuples
servers = (
# YOUR SERVERS HERE
# ('127.0.0.1', 11211),
)
def netcat(hostname, port, content):
# from http://stackoverflow.com/questions/1908878/netcat-implementation-in-python/1909355#1909355
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((hostname, port))
s.sendall(content)
s.shutdown(socket.SHUT_WR)
while 1:
data = s.recv(1024)
if data == "":
break
return data
s.close()
for server in servers:
command = "get %s\nquit"%sys.argv[1]
print "server %s:"%(server,)
print netcat(server[0], server[1], command)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.