From 1f8e3d6ff66f474c215b4c56f480512e12b08f87 Mon Sep 17 00:00:00 2001 From: Ken Gaillot Date: Tue, 5 Dec 2023 13:52:05 -0600 Subject: [PATCH] Fix: agents: handle dampening parameter consistently and correctly Always quote variable when used (in case value incorrectly contains whitespace), always use attrd_updater -B instead of -U to ensure dampening is truly reloadable, and always mark parameter as reloadable in metadata. Also, dampening doesn't need to be passed with attrd_updater -D. --- agents/ocf/HealthCPU.in | 9 ++++----- agents/ocf/HealthSMART.in | 16 ++++++++-------- agents/ocf/ifspeed.in | 20 ++++++++++++-------- agents/ocf/ping.in | 13 ++++--------- 4 files changed, 28 insertions(+), 30 deletions(-) diff --git a/agents/ocf/HealthCPU.in b/agents/ocf/HealthCPU.in index 4bd6e3672aa..14e4b0741fc 100755 --- a/agents/ocf/HealthCPU.in +++ b/agents/ocf/HealthCPU.in @@ -126,16 +126,16 @@ healthcpu_monitor() { if [ $IDLE -lt ${OCF_RESKEY_red_limit} ] ; then # echo "System state RED!" - attrd_updater -n "#health-cpu" -B "red" -d ${OCF_RESKEY_dampening} + attrd_updater -n "#health-cpu" -B "red" -d "${OCF_RESKEY_dampening}" return $OCF_SUCCESS fi if [ $IDLE -lt ${OCF_RESKEY_yellow_limit} ] ; then # echo "System state yellow." - attrd_updater -n "#health-cpu" -B "yellow" -d ${OCF_RESKEY_dampening} + attrd_updater -n "#health-cpu" -B "yellow" -d "${OCF_RESKEY_dampening}" else # echo "System state green." - attrd_updater -n "#health-cpu" -B "green" -d ${OCF_RESKEY_dampening} + attrd_updater -n "#health-cpu" -B "green" -d "${OCF_RESKEY_dampening}" fi return $OCF_SUCCESS @@ -145,8 +145,7 @@ healthcpu_monitor() { } healthcpu_reload_agent() { - # No action required - :; + return $OCF_SUCCESS } healthcpu_validate() { diff --git a/agents/ocf/HealthSMART.in b/agents/ocf/HealthSMART.in index b6edac229e2..b2f37dee59d 100755 --- a/agents/ocf/HealthSMART.in +++ b/agents/ocf/HealthSMART.in @@ -139,25 +139,25 @@ check_temperature() { if [ $1 -lt ${lower_red_limit} ] ; then ocf_log info "Drive ${DRIVE} ${DEVICE} too cold: ${1} C" - attrd_updater -n "#health-smart" -U "red" -d "${OCF_RESKEY_dampen}" + attrd_updater -n "#health-smart" -B "red" -d "${OCF_RESKEY_dampen}" return 1 fi if [ $1 -gt ${upper_red_limit} ] ; then ocf_log info "Drive ${DRIVE} ${DEVICE} too hot: ${1} C" - attrd_updater -n "#health-smart" -U "red" -d "${OCF_RESKEY_dampen}" + attrd_updater -n "#health-smart" -B "red" -d "${OCF_RESKEY_dampen}" return 1 fi if [ $1 -lt ${lower_yellow_limit} ] ; then ocf_log info "Drive ${DRIVE} ${DEVICE} quite cold: ${1} C" - attrd_updater -n "#health-smart" -U "yellow" -d "${OCF_RESKEY_dampen}" + attrd_updater -n "#health-smart" -B "yellow" -d "${OCF_RESKEY_dampen}" return 1 fi if [ $1 -gt ${upper_yellow_limit} ] ; then ocf_log info "Drive ${DRIVE} ${DEVICE} quite hot: ${1} C" - attrd_updater -n "#health-smart" -U "yellow" -d "${OCF_RESKEY_dampen}" + attrd_updater -n "#health-smart" -B "yellow" -d "${OCF_RESKEY_dampen}" return 1 fi } @@ -244,7 +244,7 @@ HealthSMART_start() { } HealthSMART_stop() { - attrd_updater -D -n "#health-smart" -d "${OCF_RESKEY_dampen}" + attrd_updater -D -n "#health-smart" rm "${OCF_RESKEY_state}" @@ -278,7 +278,7 @@ HealthSMART_monitor() { # Check overall S.M.A.R.T. status "${OCF_RESKEY_smartctl}" -d "${DEVICE}" -H ${DRIVE} | grep -q "SMART overall-health self-assessment test result: PASSED" if [ $? -ne 0 ]; then - attrd_updater -n "#health-smart" -U "red" -d "${OCF_RESKEY_dampen}" + attrd_updater -n "#health-smart" -B "red" -d "${OCF_RESKEY_dampen}" return $OCF_SUCCESS fi @@ -290,7 +290,7 @@ HealthSMART_monitor() { else "${OCF_RESKEY_smartctl}" -H "${DRIVE}" | grep -q "SMART overall-health self-assessment test result: PASSED" if [ $? -ne 0 ]; then - attrd_updater -n "#health-smart" -U "red" -d "${OCF_RESKEY_dampen}" + attrd_updater -n "#health-smart" -B "red" -d "${OCF_RESKEY_dampen}" return $OCF_SUCCESS fi @@ -301,7 +301,7 @@ HealthSMART_monitor() { fi done - attrd_updater -n "#health-smart" -U "green" -d "${OCF_RESKEY_dampen}" + attrd_updater -n "#health-smart" -B "green" -d "${OCF_RESKEY_dampen}" return $OCF_SUCCESS fi diff --git a/agents/ocf/ifspeed.in b/agents/ocf/ifspeed.in index 5fbaf893d12..8c07c3d7bac 100755 --- a/agents/ocf/ifspeed.in +++ b/agents/ocf/ifspeed.in @@ -123,7 +123,7 @@ Can be used to tune how big attribute value will be. - + The time to wait (dampening) for further changes to occur. @@ -147,6 +147,7 @@ Log more verbosely. + END @@ -154,7 +155,7 @@ END usage() { cat <