Skip to content
This repository has been archived by the owner on Jul 7, 2020. It is now read-only.

Added: Docker state, in e.g. "up 14 hours" format #8

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
Open

Added: Docker state, in e.g. "up 14 hours" format #8

wants to merge 9 commits into from

Conversation

ualex73
Copy link
Collaborator

@ualex73 ualex73 commented Aug 16, 2019

Added the "_state" value, giving the "docker ps" output format. I personally this format gives more information then the status like "running", also the uptime gives invalid when a container is stopped (now it gives how long ago it stopped).

@Sanderhuisman
Copy link
Owner

I rebased the commit onto the last develop branch. Can you explain the conversion function to string format?

I also have to look if the calculation of time delta is correct as the host and container can have different timezones which are both non utc.

@Sanderhuisman Sanderhuisman self-assigned this Aug 16, 2019
@ualex73
Copy link
Collaborator Author

ualex73 commented Aug 17, 2019

The reason I used the a timezone in the delta, because the e.g. the 'started' value of the container contains a tzinfo/timezone from the 'parser.parser' output:
'started': datetime.datetime(2019, 8, 17, 4, 59, 48, 542645, tzinfo=tzutc())

Also the datetime.now() is normally the local time, without any timezone information. So to match the 'started' tzinfo=tzutc', i added the timezone UTC to my datetime.now() command.
Also, you can't do a delta on a timezone aware and a none timezone aware variables.

Added weeks too, like docker ps has
Removed obsolete code
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants