Skip to content
Snippets Groups Projects
Commit af9ce687 authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

update _detectDockererror

parent b09d0e1e
No related branches found
No related tags found
1 merge request!241Docker checks
......@@ -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
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment