From b983b946896c31f7850ced41635e0b4ade44b15e Mon Sep 17 00:00:00 2001 From: Hugo Rodrigues Date: Mon, 27 Jan 2025 00:02:46 +0000 Subject: [PATCH] Added hook for status changes I allows to call a script to handle status change --- config-example | 7 +++++++ status.sh | 23 +++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/config-example b/config-example index bfee866c2..a9ebe0095 100644 --- a/config-example +++ b/config-example @@ -79,6 +79,13 @@ MY_STATUS_FOOTER='Powered by /dev/null; then + ${MY_HOOK_STATUS} "down" "${MY_COMMAND}" "${MY_HOSTNAME}" &> /dev/null + fi } # save_degradetime() @@ -440,6 +453,10 @@ function save_degradetime() { if [[ "$BE_LOUD" = "yes" ]] || [[ "$BE_QUIET" = "no" ]]; then printf "\\n%-5s %-4s %s" "DEGRADED:" "$MY_COMMAND" "$MY_HOSTNAME" fi + + if [[ -x "${MY_HOOK_STATUS}" ]] && ! grep -E "^${MY_COMMAND};${MY_HOSTNAME}" "${MY_HOSTNAME_STATUS_LASTRUN_DEGRADE}" &>/dev/null; then + ${MY_HOOK_STATUS} "degraded" "${MY_COMMAND}" "${MY_HOSTNAME}" &> /dev/null + fi } # save_availability() @@ -460,6 +477,12 @@ function save_availability() { printf " %s" "$MY_PORT" fi fi + + if [[ -x "${MY_HOOK_STATUS}" ]]; then + if grep -E "^${MY_COMMAND};${MY_HOSTNAME}" "${MY_HOSTNAME_STATUS_LASTRUN}" &>/dev/null || grep -E "^${MY_COMMAND};${MY_HOSTNAME}" "${MY_HOSTNAME_STATUS_LASTRUN_DEGRADE}" &>/dev/null; then + ${MY_HOOK_STATUS} "up" "${MY_COMMAND}" "${MY_HOSTNAME}" &> /dev/null + fi + fi } # save_history()