Skip to content

Instantly share code, notes, and snippets.

@emre
Created January 7, 2014 20:47
Show Gist options
  • Save emre/8306628 to your computer and use it in GitHub Desktop.
Save emre/8306628 to your computer and use it in GitHub Desktop.
check nodes
import socket
import sys
def check_server(address, port):
s = socket.socket()
s.settimeout(2)
try:
s.connect((address, port))
return True
except socket.error, e:
return False
nodes = open("nodelist.txt").readlines()
healthy_list = []
for node in nodes:
node = node.replace("\n", "")
if check_server(node, 1968):
healthy_list.append(node)
print healthy_list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment