forked from Qihoo360/huststore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathremote_status.py
35 lines (29 loc) · 882 Bytes
/
remote_status.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/python
# author: jobs
# email: [email protected]
import os
import sys
import string
import datetime
merge = lambda l: string.join(l, '\n')
def manual():
print """
usage:
python remote_status.py [host_file] [port]
sample:
python remote_status.py host.txt 8082
"""
def get_items(uri):
with open(uri) as f:
return filter(lambda s: len(s) > 0 and not s.startswith('#'), map(
lambda s: s.split('\n')[0].split('\r')[0], f.readlines()))
def remote_status(host_file, port):
for host in get_items(host_file):
print '[%s:%s]' % (host, port)
os.system('curl --silent "%s:%s/status.html"' % (host, port))
return True
def parse_shell(argv):
return remote_status(argv[1], argv[2]) if 3 == len(argv) else False
if __name__ == "__main__":
if not parse_shell(sys.argv):
manual()