Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
zoe
main
Commits
42234400
Commit
42234400
authored
Oct 11, 2017
by
Daniele Venzano
Browse files
Fix cpu usage metric calculation
parent
6d7464fc
Changes
1
Hide whitespace changes
Inline
Side-by-side
zoe_master/backends/docker/threads.py
View file @
42234400
...
...
@@ -19,7 +19,6 @@ import logging
import
threading
import
time
from
copy
import
deepcopy
from
datetime
import
datetime
from
zoe_lib.config
import
get_conf
from
zoe_lib.state
import
SQLManager
,
Service
...
...
@@ -148,14 +147,9 @@ class DockerStateSynchronizer(threading.Thread):
node_stats
.
image_list
.
append
(
image
)
def
_get_core_usage
(
self
,
stat
):
try
:
this_read_ts
=
datetime
.
strptime
(
stat
[
'read'
],
'%Y-%m-%dT%H:%M:%S.%f'
)
except
ValueError
:
return
0
pre_read_ts
=
datetime
.
strptime
(
stat
[
'preread'
],
'%Y-%m-%dT%H:%M:%S.%f'
)
cpu_time_now
=
stat
[
'cpu_stats'
][
'cpu_usage'
][
'total_usage'
]
cpu_time_pre
=
stat
[
'precpu_stats'
][
'cpu_usage'
][
'total_usage'
]
return
(
cpu_time_now
-
cpu_time_pre
)
/
((
this_read_ts
-
pre_read_ts
).
total_seconds
()
*
1000000000
)
return
(
cpu_time_now
-
cpu_time_pre
)
/
1000000000
def
_update_service_status
(
self
,
service
:
Service
,
container
,
host_config
:
DockerHostConfig
):
"""Update the service status."""
...
...
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