Updated README, changed other stuff too

This commit is contained in:
Gordon Grant-Stuart 2022-12-01 17:31:48 +00:00
parent a847fe79f9
commit 4cabecbc7c
2 changed files with 40 additions and 27 deletions

View File

@ -1,3 +1,28 @@
# check_yunohost # check_yunohost
A monitoring plugin (Nagios & Opsview compatible) to check Yunohost servers. A monitoring plugin (Nagios & Opsview compatible) to check Yunohost servers.
This plugin returns the results of the most recent Yunohost diagnosis.
**Usage:** `check_yunohost [-h] -a [<category>|all|last_diagnosis] [-c <Crit>] [-w <Warn>]`
### Options:
#### -a
- **last_diagnosis**: Hours since last diagnosis was run. The default WARNING is 24 hours, and the default CRITICAL is 720 hours (30 days).
- **base_system**: "Base System" category
- **internet_connectivity**: "Internet Connectivity" category
- **dns_records**: "dns records" category
- **ports_exposure**: "Ports Exposure" category
- **web**: "Web" category
- **email**: "Email" category
- **services_status_check**: "Services Status Check" category
- **system_resources**: "System Resources" category
- **system_configurations**: "System Configurations" category
- **applications**: "Applications" category
- **all**: Check all categories.
The Category checks will return WARNING if one or more items in the Yunohost diagnosis category has a WARNING status, and CRITICAL if one or more items have a CRITICAL status.
#### -c
- **Critical**: Only applicable to 'last_diagnosis'.
#### -w
- **Warning**: Only applicable to 'last_diagnosis'.

View File

@ -31,16 +31,16 @@ function help () {
Only applicable to 'last_diagnosis'. Only applicable to 'last_diagnosis'.
Category can be one of the following: Category can be one of the following:
"Base System" base_system
"Internet Connectivity" internet_connectivity
"dns records" dns_records
"Ports Exposure" ports_exposure
"Web" web
"Email" email
"Services Status Check" services_status_check
"System Resources" system_resources
"System Configurations" system_configurations
"Applications" applications
EOF EOF
} }
@ -48,10 +48,8 @@ EOF
function category () { function category () {
while IFS= read line; do while IFS= read line; do
if [[ $(echo "$line" | grep -c "^ description: ") -gt 0 ]]; then if [[ $(echo "$line" | grep -c "^ description: ") -gt 0 ]]; then
currentcategory="$(echo "${line}" | sed 's/^ description: //')" currentcategory="$(echo "${line}" | sed 's/^ description: //; s/_/ /g')"
# currentcategory="${line//^ description: /}"
fi fi
# echo "==${currentcategory}==${line}=="
if [[ "${currentcategory,,}" == "${1,,}" || "${1,,}" == 'all' ]]; then if [[ "${currentcategory,,}" == "${1,,}" || "${1,,}" == 'all' ]]; then
echo "$line" echo "$line"
fi fi
@ -60,17 +58,13 @@ function category () {
SHOW=$(mktemp /tmp/XXXXXX) SHOW=$(mktemp /tmp/XXXXXX)
sudo yunohost diagnosis show --full > $SHOW sudo yunohost diagnosis show --full > $SHOW
# SHOW="show_full.yml"
CHECK_TYPE='na' CHECK_TYPE='na'
CATEGORY='' CATEGORY=''
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
case "$1" in case "$1" in
-h) -h) help; exit;;
help
exit
;;
-a) -a)
shift shift
if [[ "$1" == 'last_diagnosis' ]]; then if [[ "$1" == 'last_diagnosis' ]]; then
@ -80,14 +74,8 @@ while [[ $# -gt 0 ]]; do
CATEGORY="$1" CATEGORY="$1"
fi fi
;; ;;
-w) -w) shift; LAST_DIAGNOSIS_WARN="$1";;
shift -c) shift; LAST_DIAGNOSIS_CRIT="$1";;
LAST_DIAGNOSIS_WARN="$1"
;;
-c)
shift
LAST_DIAGNOSIS_CRIT="$1"
;;
esac esac
shift shift
done done