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
af9ce687
Commit
af9ce687
authored
1 year ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
update _detectDockererror
parent
b09d0e1e
No related branches found
No related tags found
1 merge request
!241
Docker checks
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
check_docker_stats
+2
-17
2 additions, 17 deletions
check_docker_stats
inc_dockerfunctions.sh
+19
-0
19 additions, 0 deletions
inc_dockerfunctions.sh
with
21 additions
and
17 deletions
check_docker_stats
+
2
−
17
View file @
af9ce687
...
...
@@ -45,7 +45,7 @@ OPTIONS:
General:
-h, --help this help
-d, --debug Debug; Flag: show
all
docker
system infos
-d, --debug Debug; Flag: show docker
env values.
Connect to docker:
-p, --path Custom directory for docker binary
...
...
@@ -127,22 +127,7 @@ _detectDockerenv
# --- get stats data
data
=
$(
sudo
-n
--preserve-env
docker stats
--no-stream
--format
'{{ json . }}'
)
if
[
-z
"
$data
"
]
;
then
# zero output could mean:
# - connect to docker failed
# - no data because no container is running
# --> let's detect it...
infos
=
$(
sudo
-n
--preserve-env
docker system info
--format
'{{ json . }}'
)
_detectDockererror
"
$infos
"
typeset
-i
iCRunning
;
iCRunning
=
$(
_getString
"
$data
"
".ContainersRunning"
)
if
[
"
$iCRunning
"
-eq
"0"
]
;
then
ph.status
"
$sLabel
>> Do data. No container is running"
ph.exit
fi
fi
_detectDockererror
"
$data
"
# --- checks to detect maximum
...
...
This diff is collapsed.
Click to expand it.
inc_dockerfunctions.sh
+
19
−
0
View file @
af9ce687
...
...
@@ -12,6 +12,7 @@
# https://docs.docker.com/engine/reference/commandline/docker/
# ----------------------------------------------------------------------
# 2024-01-19 v1.0 <axel.hahn@unibe.ch> init
# 2024-01-29 v1.1 <axel.hahn@unibe.ch> _detectDockererror
# ======================================================================
...
...
@@ -67,10 +68,28 @@ function _debugInfos(){
# detect error after dicker command. It stops if
# - no content was fetched
# - content contains key "ServerErrors"
# param string output of docker command (json)
# param bool flag: is output from docker system info
function
_detectDockererror
(){
local
data
=
"
$1
"
if
[
-z
"
$data
"
]
;
then
if
[
"
$2
"
!=
"1"
]
;
then
# zero output could mean:
# - connect to docker failed
# - no data because no container is running
# --> let's detect it...
infos
=
$(
sudo
-n
--preserve-env
docker system info
--format
'{{ json . }}'
)
_detectDockererror
"
$infos
"
typeset
-i
iCRunning
;
iCRunning
=
$(
_getString
"
$data
"
".ContainersRunning"
)
if
[
"
$iCRunning
"
-eq
"0"
]
;
then
ph.status
"No data. No container is running"
ph.exit
fi
fi
ph.setStatus unknown
ph.status
"No data. Unable to fetch Docker information."
ph.exit
...
...
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