nvme_manager: add support for adjust monitoring interval

Add support for adjust monitoring interval by adding monitorIntervalSec
into nvme_config.json.

Default set interval to 1 second if monitorIntervalSec not exists in
config file.

Example of set monitoring interval to 3 second:

{
    "config": [
        ...
    ],
    "threshold": [
        ...
    ],
    "monitorIntervalSec": 3
}

Tested on Bletchley.

Signed-off-by: Potin Lai <potin.lai@quantatw.com>
Change-Id: Iee11b23bd3166b9a35100d41b93f9f98dc3f355d
diff --git a/nvme_manager.cpp b/nvme_manager.cpp
index 51b0f7d..7154227 100644
--- a/nvme_manager.cpp
+++ b/nvme_manager.cpp
@@ -375,7 +375,7 @@
     std::function<void()> callback(std::bind(&Nvme::read, this));
     try
     {
-        u_int64_t interval = MONITOR_INTERVAL_SECONDS * 1000000;
+        u_int64_t interval = monitorIntervalSec * 1000000;
         _timer.restart(std::chrono::microseconds(interval));
     }
     catch (const std::exception& e)
@@ -421,6 +421,9 @@
         static const std::vector<Json> empty{};
         std::vector<Json> readings = data.value("config", empty);
         std::vector<Json> thresholds = data.value("threshold", empty);
+        monitorIntervalSec =
+            data.value("monitorIntervalSec", MONITOR_INTERVAL_SECONDS);
+
         if (!thresholds.empty())
         {
             for (const auto& instance : thresholds)
diff --git a/nvme_manager.hpp b/nvme_manager.hpp
index 0ee23df..ffdb20a 100644
--- a/nvme_manager.hpp
+++ b/nvme_manager.hpp
@@ -155,6 +155,9 @@
     void read();
 
     std::vector<phosphor::nvme::Nvme::NVMeConfig> getNvmeConfig();
+
+    /** @brief Monitor interval in second  */
+    size_t monitorIntervalSec;
 };
 } // namespace nvme
 } // namespace phosphor