From 4cabecbc7c4db74c41b20d5faa1aaada240dba27 Mon Sep 17 00:00:00 2001 From: Gordon Grant-Stuart Date: Thu, 1 Dec 2022 17:31:48 +0000 Subject: [PATCH] Updated README, changed other stuff too --- README.md | 27 ++++++++++++++++++++++++++- check_yunohost | 40 ++++++++++++++-------------------------- 2 files changed, 40 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 68ec5e2..d9add39 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,28 @@ # check_yunohost -A monitoring plugin (Nagios & Opsview compatible) to check Yunohost servers. \ No newline at end of file +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 [|all|last_diagnosis] [-c ] [-w ]` + +### 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'. diff --git a/check_yunohost b/check_yunohost index 8b8b5af..34e726c 100755 --- a/check_yunohost +++ b/check_yunohost @@ -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