From f8d0f6151c2e3793c347e95ab53b65d9d241a0ae Mon Sep 17 00:00:00 2001 From: Oneplus Date: Thu, 4 Jun 2015 03:33:35 +0800 Subject: [PATCH] add list option. --- tools/monitor/monitor.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) mode change 100644 => 100755 tools/monitor/monitor.py diff --git a/tools/monitor/monitor.py b/tools/monitor/monitor.py old mode 100644 new mode 100755 index 9173f418b..e67d8b2fa --- a/tools/monitor/monitor.py +++ b/tools/monitor/monitor.py @@ -11,16 +11,21 @@ from_addr, to_addrs, \ mail_username, mail_password, mail_server, mail_server_port -conn = SMTP(mail_server, mail_server_port) -conn.set_debuglevel(False) -conn.login(mail_username, mail_password) - import logging logging.basicConfig( filename='ltp_monitor.log', format='[%(levelname)s] %(asctime)s : %(message)s', level=logging.INFO) +try: + conn = SMTP(mail_server, mail_server_port) + conn.set_debuglevel(False) + conn.login(mail_username, mail_password) +except: + logging.warning("Failed to logging smtp server.") + conn = None + + mail_content_header = """\ Report from LTP monitoring script ================================= @@ -177,7 +182,7 @@ def run(): h["case"] = ret # restart the service - cmd = "cd {path}; nohup {exe} >> {host}.server.log 2>&1 &".format( + cmd = "cd {path}; nohup {exe} --threads 4 >> {host}.server.log 2>&1 &".format( path = remote_exe_path, exe = remote_exe, host = h["name"]) @@ -235,7 +240,7 @@ def start(h): logging.info("LTP on {host} is already running.".format(host=h["name"])) return - cmd = "cd {path}; nohup {exe} >> {host}.server.log 2>&1 &".format( + cmd = "cd {path}; nohup {exe} --threads 4 >> {host}.server.log 2>&1 &".format( path = remote_exe_path, exe = remote_exe, host = h["name"]) @@ -268,7 +273,7 @@ def testall(): test(h) if __name__=="__main__": - usage = "monitor.py {run|startall|stopall|testall|start [host]|stop [host]|test [host]}" + usage = "monitor.py {run|startall|stopall|testall|start [host]|stop [host]|test [host]|list}" if len(sys.argv) < 2: print >> sys.stderr, usage @@ -298,5 +303,8 @@ def testall(): for h in hosts: if h["name"] == sys.argv[2]: test(h) + elif sys.argv[1] == "list": + for h in hosts: + print >> sys.stderr, "*", h["name"] else: print >> sys.stderr, usage