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