Add timestamp and print all info on each event 83/23183/1
authorBryan Sullivan <bryan.sullivan@att.com>
Sat, 15 Oct 2016 17:39:39 +0000 (10:39 -0700)
committerBryan Sullivan <bryan.sullivan@att.com>
Sat, 15 Oct 2016 17:39:39 +0000 (10:39 -0700)
JIRA: VES-1

Change-Id: I93b83d21706468827a2ce2f174601bbc69d28c02
Signed-off-by: Bryan Sullivan <bryan.sullivan@att.com>
tests/blueprints/tosca-vnfd-hello-ves/monitor.py

index 24ad557..ec4a00d 100644 (file)
 #
 # Status: this is a work in progress, under test.
 
+import time
+
+report_time = ""
+request_rate = ""
+app_state = ""
+
 with open('/home/ubuntu/ves.log') as f:
   while True:
     line = f.readline()
     if line:
 #      print line,
+
+      if "lastEpochMicrosec" in line:
+#....5....1....5....2....5....3....5
+#            "lastEpochMicrosec": 1476552393091008,
+        report_time = line[34:-2]
+        report_time = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(1347517370))
+
       if "requestRate" in line:
-#       print line,
-        rate = line[27:-2]
-        print 'request rate: {0}'.format(rate)
 #....5....1....5....2....5....3....5
 #            "requestRate": 2264,
+        request_rate = line[27:-2]
+        print '{0} app state: {1}\trequest rate: {2}'.format(
+          report_time, app_state, request_rate)
+
       if "\"specificProblem\": \"Started\"" in line:
-        print 'app state change: Started'
+        app_state = "Started"
+        print '{0} app state change: Started'.format(report_time)
+
       if "\"specificProblem\": \"Stopped\"" in line:
-        print 'app state change: Stopped'
+        app_state = "Stopped"
+        print '{0} app state change: Stopped'.format(report_time)