mirror of
https://github.com/mag37/dockcheck.git
synced 2026-04-18 02:17:46 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf1e78d2ff | ||
|
|
9fa398e553 | ||
|
|
9ef2ea7135 | ||
|
|
8c3b899332 | ||
|
|
8110cd8892 | ||
|
|
502a167919 |
@@ -21,6 +21,14 @@
|
|||||||
___
|
___
|
||||||
## :bell: Changelog
|
## :bell: Changelog
|
||||||
|
|
||||||
|
Made MaxAsync=1 the default - edit to change.
|
||||||
|
Added -x option to pass a MaxAsync value on runtime.
|
||||||
|
Made it possible to disable xargs -P-flag by setting MaxAsync=0 or passing -x 0 option.
|
||||||
|
|
||||||
|
- **v0.5.6.1**: Async xargs hotfix - due to errors `failed to request manifest head ... context canceled`
|
||||||
|
- Defaulted subprocess to 1 with `MaxAsync=1`, increase to find a stable value in your environment.
|
||||||
|
- Added `-x N` option to pass `MaxAsync` value at runtime.
|
||||||
|
- To disable xargs `-P` flag (max processes) all together, set `MaxAsync` to 0.
|
||||||
- **v0.5.6.0**: Heavily improved performance due to async checking for updates.
|
- **v0.5.6.0**: Heavily improved performance due to async checking for updates.
|
||||||
- **v0.5.5.0**: osx and bsd compatibility changes + rewrite of dependency installer
|
- **v0.5.5.0**: osx and bsd compatibility changes + rewrite of dependency installer
|
||||||
- **v0.5.4.0**: Added support for a Prometheus+node_exporter metric collection through a file collector.
|
- **v0.5.4.0**: Added support for a Prometheus+node_exporter metric collection through a file collector.
|
||||||
|
|||||||
18
dockcheck.sh
18
dockcheck.sh
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
VERSION="v0.5.6.0"
|
VERSION="v0.5.6.1"
|
||||||
### ChangeNotes: Heavily improved performance due to asynchronous update checks.
|
### ChangeNotes: Async hotfix, 1 subprocess default, modify MaxAsync variable or pass -x N option to increase.
|
||||||
Github="https://github.com/mag37/dockcheck"
|
Github="https://github.com/mag37/dockcheck"
|
||||||
RawUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/dockcheck.sh"
|
RawUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/dockcheck.sh"
|
||||||
|
|
||||||
@@ -13,6 +13,10 @@ ScriptWorkDir="$(dirname "$ScriptPath")"
|
|||||||
LatestRelease="$(curl -s -r 0-50 $RawUrl | sed -n "/VERSION/s/VERSION=//p" | tr -d '"')"
|
LatestRelease="$(curl -s -r 0-50 $RawUrl | sed -n "/VERSION/s/VERSION=//p" | tr -d '"')"
|
||||||
LatestChanges="$(curl -s -r 0-200 $RawUrl | sed -n "/ChangeNotes/s/# ChangeNotes: //p")"
|
LatestChanges="$(curl -s -r 0-200 $RawUrl | sed -n "/ChangeNotes/s/# ChangeNotes: //p")"
|
||||||
|
|
||||||
|
# User customizable defaults
|
||||||
|
MaxAsync=1
|
||||||
|
Timeout=10
|
||||||
|
|
||||||
# Help Function
|
# Help Function
|
||||||
Help() {
|
Help() {
|
||||||
echo "Syntax: dockcheck.sh [OPTION] [part of name to filter]"
|
echo "Syntax: dockcheck.sh [OPTION] [part of name to filter]"
|
||||||
@@ -34,6 +38,7 @@ Help() {
|
|||||||
echo "-s Include stopped containers in the check. (Logic: docker ps -a)."
|
echo "-s Include stopped containers in the check. (Logic: docker ps -a)."
|
||||||
echo "-t Set a timeout (in seconds) per container for registry checkups, 10 is default."
|
echo "-t Set a timeout (in seconds) per container for registry checkups, 10 is default."
|
||||||
echo "-v Prints current version."
|
echo "-v Prints current version."
|
||||||
|
echo "-x N Set max asynchronous subprocesses, 1 default, 0 to disable, 32+ tested."
|
||||||
echo
|
echo
|
||||||
echo "Project source: $Github"
|
echo "Project source: $Github"
|
||||||
}
|
}
|
||||||
@@ -46,10 +51,8 @@ c_blue="\033[0;34m"
|
|||||||
c_teal="\033[0;36m"
|
c_teal="\033[0;36m"
|
||||||
c_reset="\033[0m"
|
c_reset="\033[0m"
|
||||||
|
|
||||||
MaxAsync=32
|
|
||||||
Timeout=10
|
|
||||||
Stopped=""
|
Stopped=""
|
||||||
while getopts "aynpfrhlisvmc:e:d:t:" options; do
|
while getopts "aynpfrhlisvmc:e:d:t:x:" options; do
|
||||||
case "${options}" in
|
case "${options}" in
|
||||||
a|y) AutoUp="yes" ;;
|
a|y) AutoUp="yes" ;;
|
||||||
c) CollectorTextFileDirectory="${OPTARG}"
|
c) CollectorTextFileDirectory="${OPTARG}"
|
||||||
@@ -65,6 +68,7 @@ while getopts "aynpfrhlisvmc:e:d:t:" options; do
|
|||||||
s) Stopped="-a" ;;
|
s) Stopped="-a" ;;
|
||||||
t) Timeout="${OPTARG}" ;;
|
t) Timeout="${OPTARG}" ;;
|
||||||
v) printf "%s\n" "$VERSION" ; exit 0 ;;
|
v) printf "%s\n" "$VERSION" ; exit 0 ;;
|
||||||
|
x) MaxAsync=${OPTARG} ;;
|
||||||
d) DaysOld=${OPTARG}
|
d) DaysOld=${OPTARG}
|
||||||
if ! [[ $DaysOld =~ ^[0-9]+$ ]] ; then { printf "Days -d argument given (%s) is not a number.\n" "${DaysOld}" ; exit 2 ; } ; fi ;;
|
if ! [[ $DaysOld =~ ^[0-9]+$ ]] ; then { printf "Days -d argument given (%s) is not a number.\n" "${DaysOld}" ; exit 2 ; } ; fi ;;
|
||||||
h|*) Help ; exit 2 ;;
|
h|*) Help ; exit 2 ;;
|
||||||
@@ -321,11 +325,11 @@ export Excludes_string="${Excludes[@]}" # Can only export scalar variables
|
|||||||
export t_out regbin RepoUrl DaysOld
|
export t_out regbin RepoUrl DaysOld
|
||||||
|
|
||||||
# Check for POSIX xargs with -P option, fallback without async
|
# Check for POSIX xargs with -P option, fallback without async
|
||||||
if (echo "test" | xargs -P 10 >/dev/null 2>&1) ; then
|
if (echo "test" | xargs -P 2 >/dev/null 2>&1) && [[ "$MaxAsync" != 0 ]]; then
|
||||||
XargsAsync="-P $MaxAsync"
|
XargsAsync="-P $MaxAsync"
|
||||||
else
|
else
|
||||||
XargsAsync=""
|
XargsAsync=""
|
||||||
printf "%bMissing POSIX xargs, consider installing 'findutils' for asynchronous lookups.%b\n" "$c_red" "$c_reset"
|
[[ "$MaxAsync" != 0 ]] && printf "%bMissing POSIX xargs, consider installing 'findutils' for asynchronous lookups.%b\n" "$c_red" "$c_reset"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Asynchronously check the image-hash of every running container VS the registry
|
# Asynchronously check the image-hash of every running container VS the registry
|
||||||
|
|||||||
Reference in New Issue
Block a user