Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
Collectl2plotly
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Matthias Lieber
Collectl2plotly
Commits
aa7e2a8c
Commit
aa7e2a8c
authored
Feb 18, 2020
by
Julius Metz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
first plot generator basics, datetime added to data
parent
cae10365
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
5 deletions
+45
-5
plots_generators.py
plots_generators.py
+12
-2
site_generator.py
site_generator.py
+33
-3
No files found.
plots_generators.py
View file @
aa7e2a8c
import
plotly.io
as
pio
import
datetime
def
cpu_plot
(
values
,
title
=
None
):
def
cpu_plot
(
values
,
title
=
None
,
xtitle
=
None
,
ytitle
=
None
):
plot
=
{
'data'
:
[],
'layout'
:
{
...
...
@@ -9,15 +10,24 @@ def cpu_plot(values, title=None):
'title'
:
{
'text'
:
title
},
'xaxis'
:
{
'title'
:
xtitle
,
},
'yaxis'
:
{
'title'
:
ytitle
,
},
},
}
for
cmd
,
cmd_data
in
values
.
items
():
CPU
=
cmd_data
.
get
(
'CPU'
,
[])
if
not
any
(
elem
!=
'0'
for
elem
in
CPU
):
continue
plot
[
'data'
].
append
(
{
'type'
:
'scatter'
,
'mode'
:
'markers'
,
'x'
:
cmd_data
.
get
(
'
T
ime'
,
[]),
'x'
:
cmd_data
.
get
(
'
datet
ime'
,
[]),
'y'
:
cmd_data
.
get
(
'CPU'
,
[]),
'name'
:
cmd
,
}
...
...
site_generator.py
View file @
aa7e2a8c
import
subprocess
from
pathlib
import
Path
import
time
import
date
time
import
click
import
plots_generators
HEAD_BLACKLIST
=
[
'Time'
,
'Date'
]
CONFIG
=
{
'cpu_plot'
:{
'title'
:
'CPU load'
,
'xtitle'
:
'Date'
,
'ytitle'
:
'CPU load'
,
}
}
def
datestr2date
(
datestr
):
return
datetime
.
date
(
int
(
datestr
[:
4
]),
int
(
datestr
[
4
:
6
]),
int
(
datestr
[
6
:
8
]),
)
def
parse_file
(
path
,
collectl
):
process
=
subprocess
.
run
([
collectl
,
'-P'
,
'-p'
,
path
,
'-sZ'
],
capture_output
=
True
)
output
=
process
.
stdout
.
decode
().
splitlines
()
head
=
output
.
pop
(
0
).
split
(
' '
)
head
[
0
]
=
head
[
0
][
1
:]
entrys_data
=
{}
tmp_date
=
None
tmp_time
=
None
for
entry
in
output
:
splited_entry
=
entry
.
split
(
' '
,
len
(
head
))
cmd
=
splited_entry
[
-
1
]
if
not
cmd
in
entrys_data
:
entrys_data
[
cmd
]
=
{
head_elem
:
[]
for
head_elem
in
head
[:
-
1
]}
entrys_data
[
cmd
]
=
{
head_elem
:
[]
for
head_elem
in
head
[:
-
1
]
if
head_elem
not
in
HEAD_BLACKLIST
}
entrys_data
[
cmd
][
'datetime'
]
=
[]
for
i
,
head_elem
in
enumerate
(
head
[:
-
1
]):
if
head_elem
==
'Date'
:
tmp_date
=
datestr2date
(
splited_entry
[
i
])
if
head_elem
==
'Time'
:
tmp_time
=
datetime
.
time
.
fromisoformat
(
splited_entry
[
i
])
if
not
head_elem
in
HEAD_BLACKLIST
:
entrys_data
[
cmd
][
head_elem
].
append
(
splited_entry
[
i
])
entrys_data
[
cmd
][
'datetime'
].
append
(
datetime
.
datetime
.
combine
(
tmp_date
,
tmp_time
),
)
return
entrys_data
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment