diff options
author | Bryan Sullivan <bryan.sullivan@att.com> | 2016-10-16 13:37:46 -0700 |
---|---|---|
committer | Bryan Sullivan <bryan.sullivan@att.com> | 2016-10-16 13:37:46 -0700 |
commit | a36ff3c3680c8eb5d8c291e7a6e237780ca34937 (patch) | |
tree | 234b62fd5adf6a4f278c52c5fb3daabe0c787ffe /tests/blueprints/tosca-vnfd-hello-ves/monitor.py | |
parent | b2ffe501d141995fd99a69664d2dfb2ec5c9f8f4 (diff) |
Add CPU usage reporting
JIRA: VES-1
Change-Id: Id2b5dc8bef0aa5de478835aa9505ee9f7a4618db
Signed-off-by: Bryan Sullivan <bryan.sullivan@att.com>
Diffstat (limited to 'tests/blueprints/tosca-vnfd-hello-ves/monitor.py')
-rw-r--r-- | tests/blueprints/tosca-vnfd-hello-ves/monitor.py | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/tests/blueprints/tosca-vnfd-hello-ves/monitor.py b/tests/blueprints/tosca-vnfd-hello-ves/monitor.py index d861f05..372d586 100644 --- a/tests/blueprints/tosca-vnfd-hello-ves/monitor.py +++ b/tests/blueprints/tosca-vnfd-hello-ves/monitor.py @@ -19,17 +19,39 @@ # # Status: this is a work in progress, under test. +import os import time +import sys +import select report_time = "" request_rate = "" app_state = "" +mode = "f" +summary = "" +status = "" + +def print_there(x, y, text): + sys.stdout.write("\x1b7\x1b[%d;%df%s\x1b8" % (x, y, text)) + sys.stdout.flush() + +a,b = os.popen('stty size', 'r').read().split() +columns = int(b) with open('/home/ubuntu/ves.log') as f: while True: + if sys.stdin in select.select([sys.stdin], [], [], 0)[0]: + line = sys.stdin.readline() + if "f" in line: mode = "f" + if "c" in line: mode = "c" + # Update screen as the <cr> messed up the display! + print_there(1,columns-56,summary) + print_there(2,columns-56,status) + line = f.readline() if line: -# print "line: ", line, + if mode == "f": + print line, if "lastEpochMicrosec" in line: #0....5....1....5....2....5....3....5....4....5....5 @@ -48,14 +70,23 @@ with open('/home/ubuntu/ves.log') as f: #....5....1....5....2....5....3....5 # "requestRate": 2264, request_rate = line[27:-2] - print '{0} app state: {1}\trequest rate: {2}'.format( + summary = report_time + " app state: " + app_state + ", request rate: " + request_rate + print_there(1,columns-56,summary) +#2016-10-16 17:15:29 app state: Started, request rate: 99 +#....5....1....5....2....5....3....5....4....5....5....5....6 + if mode == "c": print '{0} *** app state: {1}\trequest rate: {2}'.format( report_time, app_state, request_rate) if "\"specificProblem\": \"Started\"" in line: app_state = "Started" - print '{0} app state change: Started'.format(report_time) + status = report_time + " app state change: Started" + if mode == "c": print '{0} *** app state change: Started'.format(report_time) if "\"specificProblem\": \"Stopped\"" in line: app_state = "Stopped" - print '{0} app state change: Stopped'.format(report_time) + status = report_time + " app state change: Stopped" + if mode == "c": print '{0} *** app state change: Stopped'.format(report_time) + + print_there(1,columns-56,summary) + print_there(2,columns-56,status) |