Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
docker_health_check
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
jithu.tagore
docker_health_check
Commits
eac2fc00
Commit
eac2fc00
authored
Nov 17, 2022
by
jithu.tagore
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update infra_as_service_monitor.py
parent
3a39332e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
8 deletions
+0
-8
infra_as_service_monitor.py
infra_as_service_monitor.py
+0
-8
No files found.
infra_as_service_monitor.py
View file @
eac2fc00
...
...
@@ -178,17 +178,13 @@ def docker_container():
docker_client
=
docker
.
from_env
()
try
:
if
len
(
container_list
)
!=
0
:
print
(
container_list
)
for
each
in
container_list
:
print
(
each
)
try
:
container
=
docker_client
.
containers
.
get
(
each
)
print
(
container
)
except
docker
.
errors
.
NotFound
as
exc
:
print
(
f
"Check container name!
\n
{exc.explanation}"
)
else
:
if
container
.
attrs
[
"State"
][
"Status"
]
==
"restarting"
or
container
.
attrs
[
"State"
][
"Status"
]
==
"exited"
:
print
(
container
.
attrs
[
"State"
])
container_restart
.
append
(
container
)
start
=
container
.
attrs
[
"State"
][
"StartedAt"
]
end
=
container
.
attrs
[
"State"
][
"FinishedAt"
]
...
...
@@ -196,13 +192,11 @@ def docker_container():
end_date
=
dateutil
.
parser
.
isoparse
(
end
)
time
=
((
end_date
-
start_date
)
.
total_seconds
())
if
container
.
attrs
[
"State"
][
"Status"
]
==
"running"
or
container
.
attrs
[
"State"
][
"Status"
]
==
"created"
:
print
(
container
.
attrs
[
"State"
])
start
=
container
.
attrs
[
"State"
][
"StartedAt"
]
end
=
container
.
attrs
[
"State"
][
"FinishedAt"
]
start_date
=
dateutil
.
parser
.
isoparse
(
start
)
end_date
=
datetime
.
datetime
.
now
(
tz
=
datetime
.
timezone
.
utc
)
time
=
(
end_date
.
astimezone
(
datetime
.
timezone
.
utc
)
-
start_date
.
astimezone
(
datetime
.
timezone
.
utc
))
.
total_seconds
()
print
(
time
)
if
time
>
3600
:
time
=
time
/
3600
if
int
(
time
)
>
1
:
...
...
@@ -223,9 +217,7 @@ def docker_container():
timing
=
str
(
int
(
time
))
+
" Minutes"
else
:
timing
=
str
(
int
(
time
))
+
" Minutes"
data
.
append
([
container
.
name
,
container
.
id
,
container
.
attrs
[
"State"
][
"Status"
],
timing
])
print
(
data
)
else
:
...
...
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