From 42aeab57342a0285d48e72d1a764ee64168796f0 Mon Sep 17 00:00:00 2001
From: an7s <an7s@git.zephyr-software.com>
Date: Wed, 11 May 2016 00:42:15 +0000
Subject: [PATCH] Add hostname to gathered stats

Former-commit-id: e053eacd7c33a2654c2f8ac1a874b1e29f432bd0
---
 tools/gather_stats.py | 14 ++++++++++----
 tools/ps_analyze.sh   |  2 ++
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/tools/gather_stats.py b/tools/gather_stats.py
index 9498e7d06..e6f9d3185 100755
--- a/tools/gather_stats.py
+++ b/tools/gather_stats.py
@@ -23,15 +23,16 @@ def extract_attribute(attribute_line):
 # get stats one file at a time
 stats = {}
 for log_file_path in sys.argv[1:]:
+	ps_analyze_log = False
 	log_file = os.path.basename(log_file_path)
 
 	if not os.path.exists(log_file_path):
 		continue
 
 	if log_file == 'ps_analyze.log':
-		continue
+		ps_analyze_log = True
 
-	step_name= os.path.splitext(log_file)[0]
+	step_name = os.path.splitext(log_file)[0]
 
 	with open(log_file_path, 'r') as f:
 		for line in f:
@@ -39,11 +40,16 @@ for log_file_path in sys.argv[1:]:
 			if not line or line is None:
 				continue
 		
-			if re.search(ATTRIBUTE, line) or re.search(ATTRIBUTE2, line): 
+			if ps_analyze_log:
+				if 'ATTRIBUTE start_time' in line or 'ATTRIBUTE end_time' in line or 'ATTRIBUTE hostname' in line:
+					(attribute_name, attribute_value) = extract_attribute(line.rstrip())
+					if not step_name in stats:
+						stats[step_name] = {}
+					stats[step_name][attribute_name] = attribute_value
+			elif re.search(ATTRIBUTE, line) or re.search(ATTRIBUTE2, line): 
 				(attribute_name, attribute_value) = extract_attribute(line.rstrip())
 				if not step_name in stats:
 					stats[step_name] = {}
-
 				stats[step_name][attribute_name] = attribute_value
 
 if stats:
diff --git a/tools/ps_analyze.sh b/tools/ps_analyze.sh
index 8125102c6..8a47c9c3b 100755
--- a/tools/ps_analyze.sh
+++ b/tools/ps_analyze.sh
@@ -583,8 +583,10 @@ report_logs()
 {
 	logfile=logs/ps_analyze.log
 
+	myhost=$(hostname)
 	echo "# ATTRIBUTE start_time=$ps_starttime" >> $logfile
 	echo "# ATTRIBUTE end_time=$ps_endtime" >> $logfile
+	echo "# ATTRIBUTE hostname=$myhost" >> $logfile
 	echo "# ATTRIBUTE peasoup_step_name=all_peasoup" >> $logfile
 
 	for i in $all_logs
-- 
GitLab