-
Notifications
You must be signed in to change notification settings - Fork 4
/
summary.py
executable file
·130 lines (110 loc) · 3.74 KB
/
summary.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/usr/bin/env python3
import argparse
import os
import subprocess
import sys
ez_dir = "/var/log/easy-flamegraph/"
def initialize_arguments(current_dir):
""" Assign the default search folder and the arguments """
parser = argparse.ArgumentParser(
description='Description for Perf data summary')
parser.add_argument(
'-i', '--input-folder',
type=str,
help='The input folder with captured /var/log/easy-flamegraph',
default=argparse.SUPPRESS)
parser.add_argument(
'-m', '--month',
type=str,
help='The month of the data to be parsed to generate .csv files',
default="\\d+")
parser.add_argument(
'-o', '--output-folder',
type=str,
help='The output folder with all the files(include .csv, html...) ',
default=argparse.SUPPRESS)
parser.add_argument(
'--cpu',
action='store_true',
help='Generate the CPU dash board',
default=argparse.SUPPRESS)
parser.add_argument(
'--io',
action='store_true',
help='Generate the IO dash board',
default=argparse.SUPPRESS)
parser.add_argument(
'--mem',
action='store_true',
help='Generate the MEM dash board',
default=argparse.SUPPRESS)
return parser
def main():
current_dir = os.getcwd()
parser = initialize_arguments(current_dir)
args = parser.parse_args()
# By default, generate all subsystems summary
gen_all, gen_cpu, gen_io, gen_mem = True, False, False, False
if hasattr(args, "cpu"):
gen_cpu, gen_all = True, False
if hasattr(args, "io"):
gen_io, gen_all = True, False
if hasattr(args, "mem"):
gen_mem, gen_all = True, False
realpath = os.path.realpath(sys.argv[0])
dirname = os.path.dirname(realpath)
extra_mem = [dirname + "/profile/cleansing/mem-extract.py"]
dashboard = [dirname + "/profile/dashboard.py"]
if hasattr(args, "input_folder"):
input_dir = args.input_folder
else:
input_dir = ez_dir
input_dir = os.path.abspath(input_dir)
mem_stat_dir = input_dir
if os.path.isdir(mem_stat_dir):
extra_mem.append("--input-folder")
extra_mem.append(mem_stat_dir)
else:
print("The input folder {} doesn't exist!!".format(mem_stat_dir))
sys.exit(1)
if hasattr(args, "output_folder"):
output_dir = args.output_folder
else:
"""Generate the intermediate files(csv,summary.html) to the designated
folder unless assigned it in the command manually
"""
output_dir = input_dir
output_dir = os.path.abspath(output_dir)
if os.path.isdir(output_dir):
extra_mem.append("--output-folder")
extra_mem.append(output_dir)
"""The ouput folder is the place to put csv. It's the input folder to
get csv to generate the dashboard
"""
dashboard.append("--input-folder")
dashboard.append(output_dir)
dashboard.append("--output-folder")
dashboard.append(output_dir)
dashboard.append("--csv-source")
dashboard.append(output_dir)
else:
print("The output folder {} doesn't exist!!".format(output_dir))
sys.exit(1)
"""Generate all the memory chart"""
extra_mem.append("-a")
if gen_all:
print("Generate all subsystems summary:")
"""Currently, we only have memory extraction tool"""
subprocess.check_call(extra_mem)
subprocess.check_call(dashboard)
return
"""Todo: Generate a specific type needs to be implemented"""
if gen_cpu:
pass
if gen_io:
pass
if gen_mem:
subprocess.check_call(extra_mem)
subprocess.check_call(dashboard)
if __name__ == '__main__':
main()