summaryrefslogtreecommitdiffstats
path: root/doc/AnalyticsWebReport.py
diff options
context:
space:
mode:
authoritraviv <itraviv@cisco.com>2017-03-05 14:22:07 +0200
committeritraviv <itraviv@cisco.com>2017-03-05 14:22:07 +0200
commit02b2d82180e957fd058d2b944d6ce2bd3de08e49 (patch)
tree34457949d34418c4aab6d4024260d8bd2498b156 /doc/AnalyticsWebReport.py
parent4d3b3baf8f29bcd5d2ee8a8f575554068a9f8f15 (diff)
ELKConnect - new module to fetch data from ELK server instead of GA, TRexDataAnalysisV2 changed to contain more metrics on performance (avg,min,max,std etc). minor changes to the webreport module after moving to elk
Signed-off-by: itraviv <itraviv@cisco.com>
Diffstat (limited to 'doc/AnalyticsWebReport.py')
-rwxr-xr-xdoc/AnalyticsWebReport.py68
1 files changed, 35 insertions, 33 deletions
diff --git a/doc/AnalyticsWebReport.py b/doc/AnalyticsWebReport.py
index 04058a02..a4c4e0ab 100755
--- a/doc/AnalyticsWebReport.py
+++ b/doc/AnalyticsWebReport.py
@@ -1,33 +1,35 @@
-import os
-import sys
-import AnalyticsConnect as ac
-import TRexDataAnalysisV2 as tr
-import time
-import datetime
-
-
-def main(verbose=False, source='ga', detailed_test_stats='yes'):
- if source == 'ga':
- if verbose:
- print('Retrieving data from Google Analytics')
- analytics = ac.initialize_analyticsreporting()
- current_date = time.strftime("%Y-%m-%d")
- k_days_ago = datetime.datetime.now() - datetime.timedelta(days=15)
- start_date = str(k_days_ago.date())
- response = ac.get_report(analytics, start_date, current_date)
- all_data_dict, setups = ac.export_to_tuples(response)
- if source == 'elk':
- all_data_dict = 0 # INSERT JSON FROM ELK HERE
- dest_path = os.path.join(os.getcwd(), 'build', 'images')
- if verbose:
- print('Saving data to %s' % dest_path)
- if detailed_test_stats:
- print('generating detailed table for test results')
- tr.create_all_data(all_data_dict, start_date, current_date, save_path=dest_path,
- detailed_test_stats=detailed_test_stats)
- if verbose:
- print('Done without errors.')
-
-
-if __name__ == "__main__":
- main()
+import os
+import sys
+import ELKConnect as ec
+import AnalyticsConnect as ac
+import TRexDataAnalysisV2 as tr
+import time
+import datetime
+
+
+def main(verbose=False, source='elk', detailed_test_stats='yes'):
+ current_date = time.strftime("%Y-%m-%d")
+ k_days_ago = datetime.datetime.now() - datetime.timedelta(days=15)
+ start_date = str(k_days_ago.date())
+ if source == 'ga':
+ if verbose:
+ print('Retrieving data from Google Analytics')
+ analytics = ac.initialize_analyticsreporting()
+ response = ac.get_report(analytics, start_date, current_date)
+ all_data_dict, setups = ac.export_to_tuples(response)
+ if source == 'elk':
+ elk_manager = ec.ELKManager(hostname='sceasr-b20', index='trex_perf-000004', port=9200)
+ all_data_dict = elk_manager.fetch_and_parse()
+ dest_path = os.path.join(os.getcwd(), 'build', 'images')
+ if verbose:
+ print('Saving data to %s' % dest_path)
+ if detailed_test_stats:
+ print('generating detailed table for test results')
+ tr.create_all_data(all_data_dict, current_date, save_path=dest_path,
+ detailed_test_stats=detailed_test_stats)
+ if verbose:
+ print('Done without errors.')
+
+
+if __name__ == "__main__":
+ main()