1
0
This commit is contained in:
root
2018-05-03 20:27:22 +02:00
commit 3ca191dd2f
10 changed files with 767 additions and 0 deletions

37
pollstatus.py Executable file
View File

@@ -0,0 +1,37 @@
#!/usr/bin/python3
import socket
import sys
from getopt import getopt
options, args = getopt(sys.argv[1:], "h:p:")
HOST = "localhost"
PORT = 9999
for o,a in options:
if o == "-h":
HOST = a
elif o == "-p":
PORT = int(a)
else:
print("unrecognized argument")
exit(2)
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
s.sendall(b"status\n")
answer = s.recv(50).decode("ascii")
s.close()
if answer.strip() == "Running":
print("OK: received 'Running'")
exit(0)
elif answer.strip() == "Not running":
print("ERROR: received 'Not Running'")
exit(2)
else:
print("ERROR: received '"+answer.strip()+"'")
exit(2)
except OSError as err:
print("ERROR: Network Error")
print(err)
exit(2)