3131from measurement .files import logfiles
3232from measurement .process import meta as proc_meta
3333from measurement .tidb import pdctl
34+ from measurement .ftrace import ftrace
3435
3536
3637class Insight ():
38+ cwd = util .cwd ()
3739 # data output dir
3840 outdir = "data"
3941 full_outdir = ""
@@ -43,14 +45,18 @@ class Insight():
4345 insight_logfiles = None
4446 insight_configfiles = None
4547 insight_pdctl = None
48+ insight_trace = None
4649
4750 def __init__ (self , args ):
48- if args .output :
49- self .outdir = args .output
5051 if not args .alias :
5152 self .alias = util .get_hostname ()
52- self .full_outdir = fileutils .create_dir (
53- os .path .join (self .outdir , self .alias ))
53+ if args .output and util .is_abs_path (args .output ):
54+ self .outdir = args .output
55+ self .full_outdir = fileutils .create_dir (
56+ os .path .join (self .outdir , self .alias ))
57+ else :
58+ self .full_outdir = fileutils .create_dir (
59+ os .path .join (self .cwd , self .outdir , self .alias ))
5460 logging .debug ("Output directory is: %s" % self .full_outdir )
5561
5662 # data collected by `collector`
@@ -126,6 +132,22 @@ def run_perf(self, args):
126132 self .insight_perf = perf .InsightPerf (options = args )
127133 self .insight_perf .run (self .full_outdir )
128134
135+ def run_ftrace (self , args ):
136+ if not args .ftrace :
137+ logging .debug ("Ignoring collecting of ftrace data." )
138+ return
139+ # perf requires root priviledge
140+ if not util .is_root_privilege ():
141+ logging .fatal ("It's required to run ftrace with root priviledge." )
142+ return
143+
144+ if args .ftracepoint :
145+ self .insight_ftrace = ftrace .InsightFtrace (self .cwd , args )
146+ self .insight_ftrace .run (self .full_outdir )
147+ else :
148+ logging .debug ("Ignoring collecting of ftrace data, no tracepoint is chose." )
149+
150+
129151 def get_datadir_size (self ):
130152 # du requires root priviledge to check data-dir
131153 if not util .is_root_privilege ():
@@ -242,6 +264,9 @@ def read_pdctl(self, args):
242264 # read and save `pd-ctl` info
243265 insight .read_pdctl (args )
244266
267+ # save ftrace data
268+ insight .run_ftrace (args )
269+
245270 # compress all output to tarball
246271 if args .compress :
247272 fileutils .compress_tarball (insight .full_outdir , insight .alias )
0 commit comments