diff --git a/plots_generators.py b/plots_generators.py index 406419f9caabced1993c6c789ce1738c7333c0a4..10cd8ade8c455fd175c50731132debeac21bc09a 100644 --- a/plots_generators.py +++ b/plots_generators.py @@ -6,7 +6,7 @@ def cpu_plot(values, title=None, xtitle=None, ytitle=None): plot = { 'data': [], 'layout': { - 'showlegend': False, + 'showlegend': True, 'title': { 'text': title }, @@ -19,7 +19,7 @@ def cpu_plot(values, title=None, xtitle=None, ytitle=None): }, } for cmd, cmd_data in values.items(): - CPU = cmd_data.get('CPU', []) + CPU = cmd_data.get('PCT', []) if not any(elem != '0' for elem in CPU): continue @@ -28,10 +28,9 @@ def cpu_plot(values, title=None, xtitle=None, ytitle=None): 'type': 'scatter', 'mode': 'markers', 'x': cmd_data.get('datetime', []), - 'y': cmd_data.get('CPU', []), + 'y': CPU, 'name': cmd, } ) - pio.show(plot) \ No newline at end of file diff --git a/site_generator.py b/site_generator.py index 250dd349a1b5e00150f2d063f4373358f1dd53c6..cefc1906e63204883ca67170e61e6a8bd0e4eb9e 100644 --- a/site_generator.py +++ b/site_generator.py @@ -17,6 +17,14 @@ CONFIG = { def datestr2date(datestr): + """Converts a "datestring" to a date Object. + + Arguments: + datestr {str} -- string of a Date example: 20191224 + + Returns: + datetime.date -- date of the string + """ return datetime.date( int(datestr[:4]), int(datestr[4:6]), @@ -32,9 +40,8 @@ def parse_file(path, collectl): entrys_data = {} tmp_date = None tmp_time = None - for entry in output: - splited_entry = entry.split(' ', len(head)) + splited_entry = entry.split(' ', len(head)-1) cmd = splited_entry[-1] if not cmd in entrys_data: @@ -59,6 +66,7 @@ def parse_file(path, collectl): return entrys_data + @click.command() @click.option('--file', '-f', required=True) @click.option('--collectl', '-c', required=False, default='collectl') @@ -66,6 +74,7 @@ def main(file, collectl): path = Path(file) if path.exists(): data = parse_file(path, collectl) + for generator, settings in CONFIG.items(): getattr(plots_generators, generator)(data, **settings)