0gb.us wrote:Is there any way we could get a copy of the software you use to detect sever status? It would be very helpful for restarting servers after crashes.
Even if no, thank you!
#!/usr/bin/python
import socket,sys
def check(host, port):
try:
try:
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.settimeout(0.5)
buf = "\x4f\x45\x74\x03\x00\x00\x00\x01"
sock.sendto(buf, (host, port))
data, addr = sock.recvfrom(1000)
if data:
peer_id = data[12:14]
buf = "\x4f\x45\x74\x03" + peer_id + "\x00\x00\x03"
sock.sendto(buf, (host, port))
sock.close()
return True
except socket.timeout:
return False
except Exception:
return False
if __name__ == "__main__":
host, port = sys.argv[1], int(sys.argv[2])
print(check(host, port))
Users browsing this forum: No registered users and 9 guests