health_metric: add threshold lower bound support

Add the lower bound logic to the threshold monitoring.

Change-Id: I445d58a798cdbc04c8d818b9156a8431daed6aa7
Signed-off-by: Jagpal Singh Gill <paligill@gmail.com>
diff --git a/health_metric.cpp b/health_metric.cpp
index b37698e..abe77af 100644
--- a/health_metric.cpp
+++ b/health_metric.cpp
@@ -115,6 +115,28 @@
     ThresholdIntf::value(thresholds, true);
 }
 
+bool didThresholdViolate(ThresholdIntf::Bound bound, double thresholdValue,
+                         double value)
+{
+    switch (bound)
+    {
+        case ThresholdIntf::Bound::Lower:
+        {
+            return (value < thresholdValue);
+        }
+        case ThresholdIntf::Bound::Upper:
+        {
+            return (value > thresholdValue);
+        }
+        default:
+        {
+            error("Invalid threshold bound {BOUND}", "BOUND",
+                  std::to_underlying(bound));
+            return false;
+        }
+    }
+}
+
 void HealthMetric::checkThreshold(ThresholdIntf::Type type,
                                   ThresholdIntf::Bound bound, double value)
 {
@@ -125,7 +147,7 @@
     {
         auto thresholdValue = thresholds[type][bound];
         auto assertions = ThresholdIntf::asserted();
-        if (value > thresholdValue)
+        if (didThresholdViolate(bound, thresholdValue, value))
         {
             if (!assertions.contains(threshold))
             {
@@ -170,6 +192,7 @@
               ThresholdIntf::Type::PerformanceLoss,
               ThresholdIntf::Type::Critical, ThresholdIntf::Type::Warning})
         {
+            checkThreshold(type, ThresholdIntf::Bound::Lower, value);
             checkThreshold(type, ThresholdIntf::Bound::Upper, value);
         }
     }