Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
icinga-checks
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IML Open Source
icinga-checks
Commits
fbd45da4
Commit
fbd45da4
authored
1 month ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
docker info:
- check status output "(healthy)" - speedup output of containers
parent
825d05ac
No related branches found
No related tags found
1 merge request
!308
docker info:
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
check_docker_info
+20
-16
20 additions, 16 deletions
check_docker_info
docs/20_Checks/check_docker_info.md
+4
-4
4 additions, 4 deletions
docs/20_Checks/check_docker_info.md
with
24 additions
and
20 deletions
check_docker_info
+
20
−
16
View file @
fbd45da4
...
@@ -19,13 +19,14 @@
...
@@ -19,13 +19,14 @@
# 2024-01-29 v1.4 <axel.hahn@unibe.ch> add --target option
# 2024-01-29 v1.4 <axel.hahn@unibe.ch> add --target option
# 2024-02-13 v1.5 <axel.hahn@unibe.ch> update docker ps --format
# 2024-02-13 v1.5 <axel.hahn@unibe.ch> update docker ps --format
# 2025-02-10 v1.6 <axel.hahn@unibe.ch> harden sourcing files
# 2025-02-10 v1.6 <axel.hahn@unibe.ch> harden sourcing files
# 2025-06-23 v1.7 <axel.hahn@unibe.ch> check status output "(healthy)"; speedup output of containers
# ======================================================================
# ======================================================================
# shellcheck source=/dev/null
# shellcheck source=/dev/null
.
"
$(
dirname
"
$0
"
)
/inc_pluginfunctions"
||
exit
1
.
"
$(
dirname
"
$0
"
)
/inc_pluginfunctions"
||
exit
1
.
"
$(
dirname
"
$0
"
)
/inc_dockerfunctions.sh"
||
exit
1
.
"
$(
dirname
"
$0
"
)
/inc_dockerfunctions.sh"
||
exit
1
self_APPVERSION
=
1.
6
self_APPVERSION
=
1.
7
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# FUNCTIONS
# FUNCTIONS
...
@@ -66,8 +67,8 @@ OPTIONS:
...
@@ -66,8 +67,8 @@ OPTIONS:
multiple users run a rootless docker daemon.
multiple users run a rootless docker daemon.
Flags:
Flags:
-c, --containers Flag: Show containers
(slow)
-c, --containers Flag: Show containers
-e, --errors Flag: Show containers on error only
(slow)
-e, --errors Flag: Show containers on error only
EXAMPLES:
EXAMPLES:
$_self
$_self
...
@@ -75,7 +76,7 @@ EXAMPLES:
...
@@ -75,7 +76,7 @@ EXAMPLES:
$_self
-c
$_self
-c
Show Status of all containers and a list of container names with its
Show Status of all containers and a list of container names with its
status.
Warning: this feature uses docker ps --all and can be slow.
status.
$_self
-e
$_self
-e
Show Status of all containers. If not all containers are running you
Show Status of all containers. If not all containers are running you
...
@@ -178,20 +179,23 @@ echo "$out"
...
@@ -178,20 +179,23 @@ echo "$out"
if
[
$bOptContainers
-eq
1
]
&&
[
"
$iCTotal
"
-gt
"0"
]
;
then
if
[
$bOptContainers
-eq
1
]
&&
[
"
$iCTotal
"
-gt
"0"
]
;
then
echo
echo
echo
"Containers:"
echo
"Containers:"
# containers=$( sudo -n --preserve-env docker ps --all --format
"{{ json . }}" --all
2>/dev/null )
# containers=$( sudo -n --preserve-env docker ps --all --format
'{"Names": "{{.Names}}", "State": "{{.State}}", "Status": "{{.Status}}" }'
2>/dev/null )
containers
=
$(
sudo
-n
--preserve-env
docker ps
--all
--format
'{"Names": "{{.Names}}", "State": "{{.State}}", "Status": "
{{.Status}}"
}'
2>/dev/null
)
containers
=
$(
sudo
-n
--preserve-env
docker ps
--format
"table {{.Names}} | {{.State}} |
{{.Status}}"
--all
2>/dev/null
|
sed
-n
2,
\$
p
)
echo
"
$containers
"
|
while
read
-r
line
;
do
echo
"
$containers
"
|
while
read
-r
line
;
do
sName
=
$(
_getString
"
$line
"
".Names"
)
contStatus
=
"OK"
sState
=
$(
_getString
"
$line
"
".State"
)
if
grep
-q
"("
<<<
"
$line
"
;
then
sStatus
=
$(
_getString
"
$line
"
".Status"
)
if
grep
-Fv
"(healthy)"
<<<
"
$line
"
|
grep
-q
"("
;
then
sIco
=
contStatus
=
"??"
# Icinga ui does not show these characters
# commented because within a while loop I am in a subshell
# sIco="🔶"
# ph.setStatus critical
# grep "exited" <<< "${sState}" >/dev/null && sIco="❌"
fi
# grep "running" <<< "${sState}" >/dev/null && sIco="✅"
else
if
!
grep
-q
"| running |"
<<<
"
$line
"
;
then
printf
" %-14s %-40s %-20s
\n
"
"
$sIco
$sState
"
"
$sName
"
"
$sStatus
"
contStatus
=
"??"
fi
fi
echo
"
$contStatus
$line
"
done
done
echo
echo
...
...
This diff is collapsed.
Click to expand it.
docs/20_Checks/check_docker_info.md
+
4
−
4
View file @
fbd45da4
...
@@ -37,7 +37,7 @@ If DOCKER_HOST is not set then the docker socket is detected from a running dock
...
@@ -37,7 +37,7 @@ If DOCKER_HOST is not set then the docker socket is detected from a running dock
______________________________________________________________________
______________________________________________________________________
CHECK_DOCKER_INFO
CHECK_DOCKER_INFO
v1.
6
v1.
7
(c) Institute for Medical Education - University of Bern
(c) Institute for Medical Education - University of Bern
Licence: GNU GPL 3
Licence: GNU GPL 3
...
@@ -73,8 +73,8 @@ OPTIONS:
...
@@ -73,8 +73,8 @@ OPTIONS:
multiple users run a rootless docker daemon.
multiple users run a rootless docker daemon.
Flags:
Flags:
-c, --containers Flag: Show containers
(slow)
-c, --containers Flag: Show containers
-e, --errors Flag: Show containers on error only
(slow)
-e, --errors Flag: Show containers on error only
EXAMPLES:
EXAMPLES:
check_docker_info
check_docker_info
...
@@ -82,7 +82,7 @@ EXAMPLES:
...
@@ -82,7 +82,7 @@ EXAMPLES:
check_docker_info -c
check_docker_info -c
Show Status of all containers and a list of container names with its
Show Status of all containers and a list of container names with its
status.
Warning: this feature uses docker ps --all and can be slow.
status.
check_docker_info -e
check_docker_info -e
Show Status of all containers. If not all containers are running you
Show Status of all containers. If not all containers are running you
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment