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
b09d0e1e
Commit
b09d0e1e
authored
1 year ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
fix help;
parent
13ac2a0f
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_dockercontainer_top
+10
-5
10 additions, 5 deletions
check_dockercontainer_top
inc_dockerfunctions.sh
+4
-2
4 additions, 2 deletions
inc_dockerfunctions.sh
with
14 additions
and
7 deletions
check_dockercontainer_top
+
10
−
5
View file @
b09d0e1e
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
inc_dockerfunctions.sh
+
4
−
2
View file @
b09d0e1e
...
@@ -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
...
...
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