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: ...@@ -45,7 +45,7 @@ OPTIONS:
General: General:
-h, --help this help -h, --help this help
-d, --debug Debug; Flag: show all docker system infos -d, --debug Debug; Flag: show docker env values.
Connect to docker: Connect to docker:
-p, --path Custom directory for docker binary -p, --path Custom directory for docker binary
...@@ -127,22 +127,7 @@ _detectDockerenv ...@@ -127,22 +127,7 @@ _detectDockerenv
# --- get stats data # --- get stats data
data=$( sudo -n --preserve-env docker stats --no-stream --format '{{ json . }}' ) data=$( sudo -n --preserve-env docker stats --no-stream --format '{{ json . }}' )
_detectDockererror "$data"
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
# --- checks to detect maximum # --- checks to detect maximum
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
# https://docs.docker.com/engine/reference/commandline/docker/ # https://docs.docker.com/engine/reference/commandline/docker/
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# 2024-01-19 v1.0 <axel.hahn@unibe.ch> init # 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(){ ...@@ -67,10 +68,28 @@ function _debugInfos(){
# detect error after dicker command. It stops if # detect error after dicker command. It stops if
# - no content was fetched # - no content was fetched
# - content contains key "ServerErrors" # - content contains key "ServerErrors"
# param string output of docker command (json)
# param bool flag: is output from docker system info
function _detectDockererror(){ function _detectDockererror(){
local data="$1" local data="$1"
if [ -z "$data" ] ; then 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.setStatus unknown
ph.status "No data. Unable to fetch Docker information." ph.status "No data. Unable to fetch Docker information."
ph.exit ph.exit
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment