diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..0cfcba5 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,25 @@ +# Pre-commit hooks to run tests and ensure code is cleaned. +# See https://pre-commit.com for more information +--- +repos: + - repo: https://github.com/codespell-project/codespell + rev: v2.2.2 + hooks: + - id: codespell + args: + - --ignore-words-list=exten + - --skip="./.*,*.csv,*.json,*.ini,*.subject,*.txt,*.html,*.log,*.conf" + - --quiet-level=2 + - --ignore-regex=.*codespell-ignore$ + #- --write-changes # Uncomment to write changes + exclude_types: [csv, json] + - repo: https://github.com/adrienverge/yamllint + rev: v1.32.0 + hooks: + - id: yamllint + ignore: .github/ + - repo: https://github.com/pre-commit/mirrors-prettier + rev: v2.7.1 + hooks: + - id: prettier + args: ["--print-width", "100"] diff --git a/README.md b/README.md index 508c11a..f670706 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Checks are done by running Icinga/Nagios compatible check plugins inside contain - `/usr/lib/nagios/plugins/check_apt`: for Debian based image, provide by the `monitoring-plugins-basic` debian package - `/usr/lib/nagios/plugins/check_apk`: for Alpine based image, see [project](https://gitea.zionetrix.net/bn8/check_apk) for install instructions -__Note:__ The first plugin detected as installed will be used. +**Note:** The first plugin detected as installed will be used. ## Installation diff --git a/check_container_upgrade b/check_container_upgrade index b300f68..6f92a46 100755 --- a/check_container_upgrade +++ b/check_container_upgrade @@ -139,7 +139,7 @@ fi EXIT_CODE=0 declare -A CONTAINER_STATUS_FILE declare -A CONTAINER_PID -declare -A UPTODATE +declare -A UP_TO_DATE declare -A ERRORS declare -A UNKNOWNS CHECKED_CONTAINERS=( ) @@ -232,7 +232,7 @@ do rm -f ${CONTAINER_STATUS_FILE[$container]} if [ $ex -eq 0 ] then - UPTODATE+=( ["$container"]=$STATUS ) + UP_TO_DATE+=( ["$container"]=$STATUS ) else ERRORS+=( ["$container"]=$STATUS ) [ $ex -ge 3 ] && UNKNOWNS+=( "$container" ) @@ -266,7 +266,7 @@ debug "Not found containers (${#NOTFOUNDS[@]}): $( implode ", " "${NOTFOUNDS[@]} # Compute performance data let CONTAINER_COUNTS=${#CHECKED_CONTAINERS[@]}+${#NOTFOUNDS[@]} PERF_DATA=( - "uptodate_containers=${#UPTODATE[@]};;;0;$CONTAINER_COUNTS" + "uptodate_containers=${#UP_TO_DATE[@]};;;0;$CONTAINER_COUNTS" "containers_with_errors=${#ERRORS[@]};1;;0;$CONTAINER_COUNTS" "unknown_state_containers=${#UNKNOWNS[@]};;;0;$CONTAINER_COUNTS" ) @@ -274,7 +274,7 @@ PERF_DATA=( # Display check result message case $EXIT_CODE in 0) - echo -n "OK - All ${#UPTODATE[@]} container(s) are uptodate" + echo -n "OK - All ${#UP_TO_DATE[@]} container(s) are up-to-date" ;; 1) echo -n "WARNING - ${#ERRORS[@]} container(s) need to be updated" @@ -296,9 +296,9 @@ do echo ${container} - ${ERRORS[${container}]} done -for container in ${!UPTODATE[@]} +for container in ${!UP_TO_DATE[@]} do - echo ${container} - ${UPTODATE[${container}]} + echo ${container} - ${UP_TO_DATE[${container}]} done exit $EXIT_CODE