From c6ee0973522268ed7b3241cf0ec2e06398444114 Mon Sep 17 00:00:00 2001 From: Grace Chin Date: Tue, 4 May 2021 12:02:17 -0400 Subject: [PATCH 1/4] Remove deprecated attrd_options --- extra/resources/ping | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/extra/resources/ping b/extra/resources/ping index 3cf8dfe..2e93f22 100755 --- a/extra/resources/ping +++ b/extra/resources/ping @@ -178,7 +178,7 @@ ping_stop() { rm -f "${OCF_RESKEY_pidfile}" - attrd_updater -D -n "$OCF_RESKEY_name" -d "$OCF_RESKEY_dampen" $attrd_options + attrd_updater -D -n "$OCF_RESKEY_name" -d "$OCF_RESKEY_dampen" return $OCF_SUCCESS } @@ -302,9 +302,9 @@ ping_update() { score=$(expr $active \* $OCF_RESKEY_multiplier) if [ "$__OCF_ACTION" = "start" ] ; then - attrd_updater -n "$OCF_RESKEY_name" -B "$score" -d "$OCF_RESKEY_dampen" $attrd_options + attrd_updater -n "$OCF_RESKEY_name" -B "$score" -d "$OCF_RESKEY_dampen" else - attrd_updater -n "$OCF_RESKEY_name" -v "$score" -d "$OCF_RESKEY_dampen" $attrd_options + attrd_updater -n "$OCF_RESKEY_name" -v "$score" -d "$OCF_RESKEY_dampen" fi rc=$? case $rc in @@ -396,11 +396,6 @@ case "${OCF_RESKEY_debug}" in ;; esac -attrd_options='-q' -if [ "${OCF_RESKEY_debug}" = "true" ]; then - attrd_options='' -fi - case "$__OCF_ACTION" in meta-data) meta_data exit $OCF_SUCCESS -- 1.8.3.1 From 6d6c4691cf0970059689856c354daf9e098b4451 Mon Sep 17 00:00:00 2001 From: Grace Chin Date: Tue, 4 May 2021 14:50:37 -0400 Subject: [PATCH 2/4] Replace debug values, true and false, with 0 and 1 --- extra/resources/ping | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/extra/resources/ping b/extra/resources/ping index 2e93f22..fee019b 100755 --- a/extra/resources/ping +++ b/extra/resources/ping @@ -24,7 +24,7 @@ : ${OCF_RESKEY_dampen:="5s"} : ${OCF_RESKEY_attempts:="3"} : ${OCF_RESKEY_multiplier:="1"} -: ${OCF_RESKEY_debug:="false"} +: ${OCF_RESKEY_debug:="0"} : ${OCF_RESKEY_failure_score:="0"} : ${OCF_RESKEY_use_fping:="1"} : ${OCF_RESKEY_host_list:=""} @@ -152,7 +152,7 @@ END ping_conditional_log() { level="$1"; shift - if [ "${OCF_RESKEY_debug}" = "true" ]; then + if [ $OCF_RESKEY_debug -gt 0 ]; then ocf_log "$level" "$*" fi } @@ -388,8 +388,8 @@ fi # Check the debug option case "${OCF_RESKEY_debug}" in - true|True|TRUE|1) OCF_RESKEY_debug=true;; - false|False|FALSE|0) OCF_RESKEY_debug=false;; + true|True|TRUE|1) OCF_RESKEY_debug=0;; + false|False|FALSE|0) OCF_RESKEY_debug=1;; *) ocf_log warn "Value for 'debug' is incorrect. Please specify 'true' or 'false' not: ${OCF_RESKEY_debug}" OCF_RESKEY_debug=false -- 1.8.3.1 From a886a31056b6aca764c6911f5432af2c5ebf51df Mon Sep 17 00:00:00 2001 From: Grace Chin Date: Tue, 11 May 2021 11:04:50 -0400 Subject: [PATCH 3/4] Add verbose debug mode which logs ping and fping output when set --- extra/resources/ping | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/extra/resources/ping b/extra/resources/ping index fee019b..cc796af 100755 --- a/extra/resources/ping +++ b/extra/resources/ping @@ -249,10 +249,13 @@ fping_check() { case $rc in 0) + if [ $OCF_RESKEY_debug -gt 1 ]; then + ping_conditional_log info "$output" + fi ;; 1) for h in $(echo "$output" | grep "is unreachable" | awk '{print $1}'); do - ping_conditional_log warn "$h is inactive" + ping_conditional_log warn "$h is inactive: $output" done ;; *) @@ -282,7 +285,12 @@ ping_check() { p_out=$($p_exe $p_args $OCF_RESKEY_options $host 2>&1); rc=$? case $rc in - 0) active=$(expr $active + 1);; + 0) + active=$(expr $active + 1) + if [ $OCF_RESKEY_debug -gt 1 ]; then + ping_conditional_log info "$p_out" + fi + ;; 1) ping_conditional_log warn "$host is inactive: $p_out";; *) ocf_log err "Unexpected result for '$p_exe $p_args $OCF_RESKEY_options $host' $rc: $p_out";; esac @@ -388,10 +396,11 @@ fi # Check the debug option case "${OCF_RESKEY_debug}" in - true|True|TRUE|1) OCF_RESKEY_debug=0;; - false|False|FALSE|0) OCF_RESKEY_debug=1;; + true|True|TRUE|1) OCF_RESKEY_debug=1;; + false|False|FALSE|0) OCF_RESKEY_debug=0;; + verbose|Verbose|VERBOSE|2) OCF_RESKEY_debug=2;; *) - ocf_log warn "Value for 'debug' is incorrect. Please specify 'true' or 'false' not: ${OCF_RESKEY_debug}" + ocf_log warn "Value for 'debug' is incorrect. Please specify 'true', 'false', or 'verbose', not: ${OCF_RESKEY_debug}" OCF_RESKEY_debug=false ;; esac -- 1.8.3.1 From 460043f133ced80e923b1290af70502a72deb7f8 Mon Sep 17 00:00:00 2001 From: Grace Chin Date: Tue, 11 May 2021 11:07:05 -0400 Subject: [PATCH 4/4] Improve variable names --- extra/resources/ping | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/extra/resources/ping b/extra/resources/ping index cc796af..9763b60 100755 --- a/extra/resources/ping +++ b/extra/resources/ping @@ -244,22 +244,22 @@ fping_check() { timeout=$(expr $OCF_RESKEY_timeout \* 1000 / $OCF_RESKEY_attempts) cmd="$p_exe -r $OCF_RESKEY_attempts -t $timeout -B 1.0 $OCF_RESKEY_options $OCF_RESKEY_host_list" - output=$($cmd 2>&1); rc=$? - active=$(echo "$output" | grep "is alive" | wc -l) + fping_output=$($cmd 2>&1); rc=$? + active=$(echo "$fping_output" | grep "is alive" | wc -l) case $rc in 0) if [ $OCF_RESKEY_debug -gt 1 ]; then - ping_conditional_log info "$output" + ping_conditional_log info "$fping_output" fi ;; 1) - for h in $(echo "$output" | grep "is unreachable" | awk '{print $1}'); do - ping_conditional_log warn "$h is inactive: $output" + for h in $(echo "$fping_output" | grep "is unreachable" | awk '{print $1}'); do + ping_conditional_log warn "$h is inactive: $fping_output" done ;; *) - ocf_log err "Unexpected result for '$cmd' $rc: $(echo "$output" | tr '\n' ';')" + ocf_log err "Unexpected result for '$cmd' $rc: $(echo "$fping_output" | tr '\n' ';')" ;; esac @@ -282,17 +282,17 @@ ping_check() { *:*) p_exe=ping6 esac - p_out=$($p_exe $p_args $OCF_RESKEY_options $host 2>&1); rc=$? + ping_output=$($p_exe $p_args $OCF_RESKEY_options $host 2>&1); rc=$? case $rc in 0) active=$(expr $active + 1) if [ $OCF_RESKEY_debug -gt 1 ]; then - ping_conditional_log info "$p_out" + ping_conditional_log info "$ping_output" fi ;; - 1) ping_conditional_log warn "$host is inactive: $p_out";; - *) ocf_log err "Unexpected result for '$p_exe $p_args $OCF_RESKEY_options $host' $rc: $p_out";; + 1) ping_conditional_log warn "$host is inactive: $ping_output";; + *) ocf_log err "Unexpected result for '$p_exe $p_args $OCF_RESKEY_options $host' $rc: $ping_output";; esac done return $active -- 1.8.3.1