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

fix help;

parent 13ac2a0f
No related branches found
No related tags found
1 merge request!241Docker checks
...@@ -13,13 +13,14 @@ ...@@ -13,13 +13,14 @@
# https://docs.docker.com/engine/reference/commandline/docker/ # https://docs.docker.com/engine/reference/commandline/docker/
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# 2024-01-26 v1.0 <axel.hahn@unibe.ch> init # 2024-01-26 v1.0 <axel.hahn@unibe.ch> init
# 2024-01-29 v1.1 <axel.hahn@unibe.ch> fix help;
# ====================================================================== # ======================================================================
. $(dirname $0)/inc_pluginfunctions . $(dirname $0)/inc_pluginfunctions
. $(dirname $0)/inc_dockerfunctions.sh . $(dirname $0)/inc_dockerfunctions.sh
self_APPVERSION=1.0 self_APPVERSION=1.1
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# FUNCTIONS # FUNCTIONS
...@@ -48,8 +49,12 @@ USAGE: ...@@ -48,8 +49,12 @@ USAGE:
$_self [OPTIONS] $_self [OPTIONS]
OPTIONS: OPTIONS:
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:
-p, --path Custom directory for docker binary -p, --path Custom directory for docker binary
-t, --target Custom docker target; value for DOCKER_HOST -t, --target Custom docker target; value for DOCKER_HOST
Needed only if Docker does not run on a unix socket or Needed only if Docker does not run on a unix socket or
...@@ -91,7 +96,7 @@ while [[ "$#" -gt 0 ]]; do case $1 in ...@@ -91,7 +96,7 @@ while [[ "$#" -gt 0 ]]; do case $1 in
fi fi
shift; shift;; shift; shift;;
-t|--target) export DOCKER_HOST="$2"; shift; shift;; -t|--target) export DOCKER_HOST="$2"; shift; shift;;
*) echo "ERROR: Unknown parameter: $1"; showHelp; exit 1; *) echo "ERROR: Unknown parameter: $1"; _showHelp; exit 1;
esac; done esac; done
ph.require "docker" ph.require "docker"
...@@ -108,7 +113,7 @@ _detectDockererror "$data" ...@@ -108,7 +113,7 @@ _detectDockererror "$data"
out=$( out=$(
echo "$data" | while read -r line; do echo "$data" | while read -r line; do
id=$( echo "$line" | jq -r ".ID") id=$( echo "$line" | jq -r ".ID")
name=$( echo "$line" | jq -r ".Names") name=$( echo "$line" | jq -r ".Names")
pslist=$( sudo -n --preserve-env docker top "$id" "-o user,pid,pcpu,pmem,command" 2>/dev/null ) pslist=$( sudo -n --preserve-env docker top "$id" "-o user,pid,pcpu,pmem,command" 2>/dev/null )
...@@ -121,7 +126,7 @@ done ...@@ -121,7 +126,7 @@ done
typeset -i iContainers; iContainers=$( echo "$data" | wc -l ) typeset -i iContainers; iContainers=$( echo "$data" | wc -l )
typeset -i iLines; iLines=$( echo "$out" | wc -l ) typeset -i iLines; iLines=$( echo "$out" | wc -l )
typeset -i iProcesses; iProcesses=iLines-iContainers*2 typeset -i iProcesses; iProcesses=$(( iLines-iContainers*2 ))
# --- output # --- output
......
...@@ -43,9 +43,11 @@ function _getString(){ ...@@ -43,9 +43,11 @@ function _getString(){
function _detectDockerenv(){ function _detectDockerenv(){
local dockeruid= local dockeruid=
if [ -z "$DOCKER_HOST" ]; then if [ -z "$DOCKER_HOST" ]; then
_is_docker_detected=1
dockeruid=$( ps -ef | grep containerd | grep -Eo "/run/user/([0-9]*)/" | head -1 | cut -f 4 -d '/' ) dockeruid=$( ps -ef | grep containerd | grep -Eo "/run/user/([0-9]*)/" | head -1 | cut -f 4 -d '/' )
test -n "$dockeruid" && export DOCKER_HOST="unix:///run/user/$dockeruid/docker.sock" if [ -n "$dockeruid" ]; then
_is_docker_detected=1
export DOCKER_HOST="unix:///run/user/$dockeruid/docker.sock"
fi
# Don't abort - it is allowed that the variable DOCKER_HOST is missing # Don't abort - it is allowed that the variable DOCKER_HOST is missing
fi fi
if grep "/run/user/[0-9]*" <<< "$DOCKER_HOST" >/dev/null; then if grep "/run/user/[0-9]*" <<< "$DOCKER_HOST" >/dev/null; then
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment