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
c4ab3752
Commit
c4ab3752
authored
1 month ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Plain Diff
Merge branch '8066-docker-health' into 'master'
docker info: See merge request
!308
parents
825d05ac
fbd45da4
Branches
Branches containing commit
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 @
c4ab3752
...
...
@@ -19,13 +19,14 @@
# 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
# 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
.
"
$(
dirname
"
$0
"
)
/inc_pluginfunctions"
||
exit
1
.
"
$(
dirname
"
$0
"
)
/inc_dockerfunctions.sh"
||
exit
1
self_APPVERSION
=
1.
6
self_APPVERSION
=
1.
7
# ----------------------------------------------------------------------
# FUNCTIONS
...
...
@@ -66,8 +67,8 @@ OPTIONS:
multiple users run a rootless docker daemon.
Flags:
-c, --containers Flag: Show containers
(slow)
-e, --errors Flag: Show containers on error only
(slow)
-c, --containers Flag: Show containers
-e, --errors Flag: Show containers on error only
EXAMPLES:
$_self
...
...
@@ -75,7 +76,7 @@ EXAMPLES:
$_self
-c
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
Show Status of all containers. If not all containers are running you
...
...
@@ -178,20 +179,23 @@ echo "$out"
if
[
$bOptContainers
-eq
1
]
&&
[
"
$iCTotal
"
-gt
"0"
]
;
then
echo
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
sName
=
$(
_getString
"
$line
"
".Names"
)
sState
=
$(
_getString
"
$line
"
".State"
)
sStatus
=
$(
_getString
"
$line
"
".Status"
)
sIco
=
# Icinga ui does not show these characters
# sIco="🔶"
# grep "exited" <<< "${sState}" >/dev/null && sIco="❌"
# grep "running" <<< "${sState}" >/dev/null && sIco="✅"
printf
" %-14s %-40s %-20s
\n
"
"
$sIco
$sState
"
"
$sName
"
"
$sStatus
"
contStatus
=
"OK"
if
grep
-q
"("
<<<
"
$line
"
;
then
if
grep
-Fv
"(healthy)"
<<<
"
$line
"
|
grep
-q
"("
;
then
contStatus
=
"??"
# commented because within a while loop I am in a subshell
# ph.setStatus critical
fi
else
if
!
grep
-q
"| running |"
<<<
"
$line
"
;
then
contStatus
=
"??"
fi
fi
echo
"
$contStatus
$line
"
done
echo
...
...
This diff is collapsed.
Click to expand it.
docs/20_Checks/check_docker_info.md
+
4
−
4
View file @
c4ab3752
...
...
@@ -37,7 +37,7 @@ If DOCKER_HOST is not set then the docker socket is detected from a running dock
______________________________________________________________________
CHECK_DOCKER_INFO
v1.
6
v1.
7
(c) Institute for Medical Education - University of Bern
Licence: GNU GPL 3
...
...
@@ -73,8 +73,8 @@ OPTIONS:
multiple users run a rootless docker daemon.
Flags:
-c, --containers Flag: Show containers
(slow)
-e, --errors Flag: Show containers on error only
(slow)
-c, --containers Flag: Show containers
-e, --errors Flag: Show containers on error only
EXAMPLES:
check_docker_info
...
...
@@ -82,7 +82,7 @@ EXAMPLES:
check_docker_info -c
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
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