From 30271f16c9878a03b803d2f1e6b5b5ec214a6365 Mon Sep 17 00:00:00 2001
From: liupei <liupei@kylinos.cn>
Date: Wed, 23 Aug 2023 19:02:10 +0800
Subject: [PATCH] Add the parameter of dampening and fix attrd_updater command

---
 agents/ocf/HealthIOWait.in | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/agents/ocf/HealthIOWait.in b/agents/ocf/HealthIOWait.in
index ba7a17a..de2844b 100644
--- a/agents/ocf/HealthIOWait.in
+++ b/agents/ocf/HealthIOWait.in
@@ -60,6 +60,15 @@ the #health-iowait will go red if the %iowait of the CPU get higher than 15%.
 <content type="integer" default="15"/>
 </parameter>
 
+<parameter name="dampening" reloadable="1">
+<longdesc lang="en">
+The time to wait (dampening) in seconds for further changes before writing
+</longdesc>
+<shortdesc lang="en">The time to wait (dampening) in seconds for further changes 
+before writing</shortdesc>
+<content type="string" default="5s"/>
+</parameter>
+
 </parameters>
 
 <actions>
@@ -109,16 +118,16 @@ agent_monitor() {
           # echo $OCF_RESKEY_yellow_limit
           if [ $WAIT -gt ${OCF_RESKEY_red_limit} ] ; then
             # echo "System state RED!"
-            attrd_updater -n "#health-iowait" -U "red" -d "5s"
+            attrd_updater -n "#health-iowait" -B "red" -d ${OCF_RESKEY_dampening}
             return $OCF_SUCCESS
           fi
 
           if [ $WAIT -gt ${OCF_RESKEY_yellow_limit} ] ; then
             # echo "System state yellow."
-            attrd_updater -n "#health-iowait" -U "yellow" -d "5s"
+            attrd_updater -n "#health-iowait" -B "yellow" -d ${OCF_RESKEY_dampening}
           else
             # echo "System state green."
-            attrd_updater -n "#health-iowait" -U "green" -d "5s"
+            attrd_updater -n "#health-iowait" -B "green" -d ${OCF_RESKEY_dampening}
           fi
           return $OCF_SUCCESS
         fi
@@ -175,6 +184,10 @@ if [ -z "${OCF_RESKEY_yellow_limit}" ] ; then
   OCF_RESKEY_yellow_limit=10
 fi
 
+if [ -z "${OCF_RESKEY_dampening}" ]; then
+    OCF_RESKEY_dampening="5s"
+fi
+
 case $__OCF_ACTION in
 meta-data)      meta_data
                 exit $OCF_SUCCESS
-- 
2.33.1.windows.1

