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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IML Open Source
icinga-checks
Commits
e7e52009
Commit
e7e52009
authored
1 month ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
usse sudo for dockerinfo check
parent
c0ff856e
Branches
Branches containing commit
No related tags found
1 merge request
!307
usse sudo for dockerinfo check
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
check_dockercontainer_info
+4
-3
4 additions, 3 deletions
check_dockercontainer_info
docs/20_Checks/check_dockercontainer_info.md
+7
-4
7 additions, 4 deletions
docs/20_Checks/check_dockercontainer_info.md
with
11 additions
and
7 deletions
check_dockercontainer_info
+
4
−
3
View file @
e7e52009
...
@@ -14,13 +14,14 @@
...
@@ -14,13 +14,14 @@
# 2024-01-18 v0.1 <axel.hahn@unibe.ch> init
# 2024-01-18 v0.1 <axel.hahn@unibe.ch> init
# 2024-02-13 v1.0 <axel.hahn@unibe.ch> update docker ps --format
# 2024-02-13 v1.0 <axel.hahn@unibe.ch> update docker ps --format
# 2025-02-10 v1.1 <axel.hahn@unibe.ch> harden sourcing files
# 2025-02-10 v1.1 <axel.hahn@unibe.ch> harden sourcing files
# 2025-04-04 v1.2 <axel.hahn@unibe.ch> use sudo on all docker commands
# ======================================================================
# ======================================================================
# 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.
1
self_APPVERSION
=
1.
2
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# FUNCTIONS
# FUNCTIONS
...
@@ -93,7 +94,7 @@ ph.require "jq"
...
@@ -93,7 +94,7 @@ ph.require "jq"
if
ph.hasParamoption
"s"
"
$@
"
;
then
if
ph.hasParamoption
"s"
"
$@
"
;
then
echo
"List of all containers (docker ps --all):"
echo
"List of all containers (docker ps --all):"
echo
echo
docker ps
--all
sudo
-n
--preserve-env
docker ps
--all
echo
echo
exit
0
exit
0
fi
fi
...
@@ -105,7 +106,7 @@ regex=$(ph.getValueWithParam '' f "$@")
...
@@ -105,7 +106,7 @@ regex=$(ph.getValueWithParam '' f "$@")
if
[
-z
"
$id
"
]
;
then
if
[
-z
"
$id
"
]
;
then
if
[
-n
"
$regex
"
]
;
then
if
[
-n
"
$regex
"
]
;
then
id
=
$(
docker ps
--all
|
grep
-E
"
$regex
"
|
head
-1
|
awk
'{ print $1 }'
)
id
=
$(
sudo
-n
--preserve-env
docker ps
--all
|
grep
-E
"
$regex
"
|
head
-1
|
awk
'{ print $1 }'
)
fi
fi
fi
fi
if
[
-z
"
$id
"
]
;
then
if
[
-z
"
$id
"
]
;
then
...
...
This diff is collapsed.
Click to expand it.
docs/20_Checks/check_dockercontainer_info.md
+
7
−
4
View file @
e7e52009
...
@@ -5,8 +5,6 @@ Script: `check_dockercontainer_info`
...
@@ -5,8 +5,6 @@ Script: `check_dockercontainer_info`
List existing containers and show container details.
List existing containers and show container details.
To show details you can enter an id or define a regex
To show details you can enter an id or define a regex
⚠️ This script is more experimental.
## Requirements
## Requirements
*
`docker`
Docker must be installed
*
`docker`
Docker must be installed
...
@@ -39,7 +37,7 @@ If DOCKER_HOST is not set then the docker socket is detected from a running dock
...
@@ -39,7 +37,7 @@ If DOCKER_HOST is not set then the docker socket is detected from a running dock
______________________________________________________________________
______________________________________________________________________
CHECK_DOCKERCONTAINER_INFO
CHECK_DOCKERCONTAINER_INFO
v1.
1
v1.
2
(c) Institute for Medical Education - University of Bern
(c) Institute for Medical Education - University of Bern
Licence: GNU GPL 3
Licence: GNU GPL 3
...
@@ -90,8 +88,13 @@ None.
...
@@ -90,8 +88,13 @@ None.
### Stats
### Stats
`$ ./check_dockercontaeiner_
top
`
returns
`$ ./check_dockercontaeiner_
info -s
`
returns
```
txt
```
txt
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
31eff39f1582 php:8.4-apache "docker-php-entrypoi…" 10 days ago Exited (0) 24 hours ago mfa-server
9fa83e21142e appmonitor-appmonitor-web "docker-php-entrypoi…" 3 weeks ago Up 3 hours (healthy) 0.0.0.0:8001->80/tcp, :::8001->80/tcp appmonitor-server
7a03472377c4 phpmyadmin/phpmyadmin "/docker-entrypoint.…" 4 weeks ago Exited (0) 4 weeks ago phpmyadmin
835b49cc042c mariadb:10.5.28 "docker-entrypoint.s…" 4 weeks ago Exited (0) 4 weeks ago apost-db
TODO
TODO
```
```
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