Commit 52cb77f7 authored by Julius Metz's avatar Julius Metz

change plot value, fix plotnames

parent aa7e2a8c
...@@ -6,7 +6,7 @@ def cpu_plot(values, title=None, xtitle=None, ytitle=None): ...@@ -6,7 +6,7 @@ def cpu_plot(values, title=None, xtitle=None, ytitle=None):
plot = { plot = {
'data': [], 'data': [],
'layout': { 'layout': {
'showlegend': False, 'showlegend': True,
'title': { 'title': {
'text': title 'text': title
}, },
...@@ -19,7 +19,7 @@ def cpu_plot(values, title=None, xtitle=None, ytitle=None): ...@@ -19,7 +19,7 @@ def cpu_plot(values, title=None, xtitle=None, ytitle=None):
}, },
} }
for cmd, cmd_data in values.items(): 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): if not any(elem != '0' for elem in CPU):
continue continue
...@@ -28,10 +28,9 @@ def cpu_plot(values, title=None, xtitle=None, ytitle=None): ...@@ -28,10 +28,9 @@ def cpu_plot(values, title=None, xtitle=None, ytitle=None):
'type': 'scatter', 'type': 'scatter',
'mode': 'markers', 'mode': 'markers',
'x': cmd_data.get('datetime', []), 'x': cmd_data.get('datetime', []),
'y': cmd_data.get('CPU', []), 'y': CPU,
'name': cmd, 'name': cmd,
} }
) )
pio.show(plot) pio.show(plot)
\ No newline at end of file
...@@ -17,6 +17,14 @@ CONFIG = { ...@@ -17,6 +17,14 @@ CONFIG = {
def datestr2date(datestr): 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( return datetime.date(
int(datestr[:4]), int(datestr[:4]),
int(datestr[4:6]), int(datestr[4:6]),
...@@ -32,9 +40,8 @@ def parse_file(path, collectl): ...@@ -32,9 +40,8 @@ def parse_file(path, collectl):
entrys_data = {} entrys_data = {}
tmp_date = None tmp_date = None
tmp_time = None tmp_time = None
for entry in output: for entry in output:
splited_entry = entry.split(' ', len(head)) splited_entry = entry.split(' ', len(head)-1)
cmd = splited_entry[-1] cmd = splited_entry[-1]
if not cmd in entrys_data: if not cmd in entrys_data:
...@@ -59,6 +66,7 @@ def parse_file(path, collectl): ...@@ -59,6 +66,7 @@ def parse_file(path, collectl):
return entrys_data return entrys_data
@click.command() @click.command()
@click.option('--file', '-f', required=True) @click.option('--file', '-f', required=True)
@click.option('--collectl', '-c', required=False, default='collectl') @click.option('--collectl', '-c', required=False, default='collectl')
...@@ -66,6 +74,7 @@ def main(file, collectl): ...@@ -66,6 +74,7 @@ def main(file, collectl):
path = Path(file) path = Path(file)
if path.exists(): if path.exists():
data = parse_file(path, collectl) data = parse_file(path, collectl)
for generator, settings in CONFIG.items(): for generator, settings in CONFIG.items():
getattr(plots_generators, generator)(data, **settings) getattr(plots_generators, generator)(data, **settings)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment