You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
606 B

#!/usr/bin/python
import socket
import json
import time
while True:
try:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(('', 6000))
data = sock.recv(10000)
sock.close()
#print data
stats = json.loads(data)
for k in stats:
v = stats[k]
if type(v) is list:
for i in range(0,len(v)):
print "%s[%d]: %f" % (k, i, v[i]['percent'])
else :
print "%s: %f" % (k,v['percent'])
print "----"
time.sleep(1)
except KeyboardInterrupt:
print "\nExiting..."
break
# except Exception as err:
# print "\nError ", type(err), ': ', err, "..."
# break