phosphro-health-monitor: Fix polling interval

Right now it pulls every second instead of 10 like before.

Tested: fusion2 N/A
Google-Bug-Id: 304302509
Change-Id: I491a8d8fa9df47f7904b15f406489c94417b0a68
Signed-off-by: Willy Tu <wltu@google.com>
diff --git a/recipes-phosphor/health/phosphor-health-monitor/0003-add-the-meson-option-for-monitor-collection-freq.patch b/recipes-phosphor/health/phosphor-health-monitor/0003-add-the-meson-option-for-monitor-collection-freq.patch
new file mode 100644
index 0000000..c2229f4
--- /dev/null
+++ b/recipes-phosphor/health/phosphor-health-monitor/0003-add-the-meson-option-for-monitor-collection-freq.patch
@@ -0,0 +1,63 @@
+From 5156c3e49b61e65ec5539198233645da7db9dfc7 Mon Sep 17 00:00:00 2001
+From: Jagpal Singh Gill <paligill@gmail.com>
+Date: Sun, 3 Mar 2024 18:43:53 -0800
+Subject: [PATCH] add the meson option for monitor collection freq
+
+Add the meson option for health monitor collection frequency with a
+default value of 1s.
+
+Change-Id: I47a87c5b85eebc676239d1d3dcf90037f0bc56b1
+Signed-off-by: Jagpal Singh Gill <paligill@gmail.com>
+(cherry picked from commit ea100c90f4c1b0e6144f038303422f49a3bf2081)
+---
+ health_monitor.cpp | 5 ++++-
+ meson.build        | 2 ++
+ meson.options      | 2 ++
+ 3 files changed, 8 insertions(+), 1 deletion(-)
+
+diff --git a/health_monitor.cpp b/health_monitor.cpp
+index 772bdf9..de8b723 100644
+--- a/health_monitor.cpp
++++ b/health_monitor.cpp
+@@ -1,3 +1,5 @@
++#include "config.h"
++
+ #include "health_monitor.hpp"
+ 
+ #include <phosphor-logging/lg2.hpp>
+@@ -44,7 +46,8 @@ auto HealthMonitor::run() -> sdbusplus::async::task<>
+             debug("Reading Health Metric Collection for {TYPE}", "TYPE", type);
+             collection->read();
+         }
+-        co_await sdbusplus::async::sleep_for(ctx, std::chrono::seconds(1));
++        co_await sdbusplus::async::sleep_for(
++            ctx, std::chrono::seconds(MONITOR_COLLECTION_INTERVAL));
+     }
+ }
+ 
+diff --git a/meson.build b/meson.build
+index 037a633..c9466d2 100644
+--- a/meson.build
++++ b/meson.build
+@@ -44,6 +44,8 @@ conf_data.set('HEALTH_SENSOR_PATH', '"/xyz/openbmc_project/sensors/utilization/"
+ conf_data.set('SENSOR_OBJPATH', '"/xyz/openbmc_project/sensors"')
+ conf_data.set('INVENTORY_OBJPATH', '"/xyz/openbmc_project/inventory"')
+ conf_data.set('MONITOR_AVERAGE_VALUE', get_option('use-average-value').allowed())
++conf_data.set('MONITOR_COLLECTION_INTERVAL', get_option('monitor-collection-interval'))
++
+ configure_file(output : 'config.h',
+                configuration : conf_data)
+ 
+diff --git a/meson.options b/meson.options
+index c841bf4..53c58a1 100644
+--- a/meson.options
++++ b/meson.options
+@@ -6,3 +6,5 @@ option(
+     value: 'disabled',
+     description: 'Update the metric with average value.',
+ )
++# Variables
++option('monitor-collection-interval', type: 'integer', value: 1, description: 'The health monitor collection interval in seconds.',)
+-- 
+2.55.0.1082.g2b9226bbc0-goog
+
diff --git a/recipes-phosphor/health/phosphor-health-monitor_%.bbappend b/recipes-phosphor/health/phosphor-health-monitor_%.bbappend
index 72679ef..571996f 100644
--- a/recipes-phosphor/health/phosphor-health-monitor_%.bbappend
+++ b/recipes-phosphor/health/phosphor-health-monitor_%.bbappend
@@ -3,7 +3,10 @@
 SRC_URI:append:gbmc = " \
   file://0001-health-metric-use-instantaneous-value.patch \
   file://0002-add-option-to-update-dbus-with-average-value.patch \
+  file://0003-add-the-meson-option-for-monitor-collection-freq.patch \
 "
 
 PACKAGECONFIG:append:gbmc = " average-value"
-PACKAGECONFIG[average-value] = "-Duse-average-value=enabled,-Duse-average-value=disabled"
\ No newline at end of file
+PACKAGECONFIG[average-value] = "-Duse-average-value=enabled,-Duse-average-value=disabled"
+
+EXTRA_OEMESON:append = " -Dmonitor-collection-interval=10"