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
e6584e8f
Commit
e6584e8f
authored
Nov 17, 2022
by
jithu.tagore
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update infra_as_service_monitor.py
parent
f8802ac0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
10 deletions
+31
-10
infra_as_service_monitor.py
infra_as_service_monitor.py
+31
-10
No files found.
infra_as_service_monitor.py
View file @
e6584e8f
...
...
@@ -175,10 +175,8 @@ def docker_container():
docker_client
=
docker
.
from_env
()
containers
=
docker_client
.
containers
.
list
(
all
=
True
)
try
:
print
(
container_list
)
if
len
(
container_list
)
!=
0
:
for
each
in
container_list
:
print
(
each
)
try
:
container
=
docker_client
.
containers
.
get
(
each
)
except
docker
.
errors
.
NotFound
as
exc
:
...
...
@@ -200,12 +198,25 @@ def docker_container():
time
=
(
end_date
.
astimezone
(
datetime
.
timezone
.
utc
)
-
start_date
.
astimezone
(
datetime
.
timezone
.
utc
))
.
total_seconds
()
if
time
>
3600
:
time
=
time
/
3600
timing
=
str
(
int
(
time
))
+
" Hour"
if
int
(
time
)
>
1
:
timing
=
str
(
int
(
time
))
+
" Hours"
else
:
timing
=
str
(
int
(
time
))
+
" Hour"
elif
time
<
60
:
timing
=
str
(
int
(
time
))
+
" Seconds"
if
int
(
time
)
>
1
:
timing
=
str
(
int
(
time
))
+
" Seconds"
else
:
timing
=
str
(
int
(
time
))
+
" Second"
elif
time
>
60
:
time
=
time
/
60
timing
=
str
(
int
(
time
))
+
" Minute"
if
int
(
time
)
>
1
:
timing
=
str
(
int
(
time
))
+
" Minutes"
else
:
timing
=
str
(
int
(
time
))
+
" Minutes"
data
.
append
([
container
.
name
,
container
.
id
,
container
.
attrs
[
"State"
][
"Status"
],
timing
])
...
...
@@ -226,19 +237,29 @@ def docker_container():
time
=
(
end_date
.
astimezone
(
datetime
.
timezone
.
utc
)
-
start_date
.
astimezone
(
datetime
.
timezone
.
utc
))
.
total_seconds
()
if
time
>
3600
:
time
=
time
/
3600
timing
=
str
(
int
(
time
))
+
" Hour"
if
int
(
time
)
>
1
:
timing
=
str
(
int
(
time
))
+
" Hours"
else
:
timing
=
str
(
int
(
time
))
+
" Hour"
elif
time
<
60
:
timing
=
str
(
int
(
time
))
+
" Seconds"
if
int
(
time
)
>
1
:
timing
=
str
(
int
(
time
))
+
" Seconds"
else
:
timing
=
str
(
int
(
time
))
+
" Second"
elif
time
>
60
:
time
=
time
/
60
timing
=
str
(
int
(
time
))
+
" Minute"
if
int
(
time
)
>
1
:
timing
=
str
(
int
(
time
))
+
" Minutes"
else
:
timing
=
str
(
int
(
time
))
+
" Minutes"
data
.
append
([
each
.
name
,
each
.
id
,
each
.
attrs
[
"State"
][
"Status"
],
timing
])
except
Exception
as
e
:
logger
.
info
(
e
)
def
status
(
service_name
):
logger
.
info
(
f
"Checking - {service_name} 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