monitor: Event logs for missing fans

This commit adds the code to create event logs calling out the fan when
it has been missing for a certain amount of time.

This is basically identical to the functionality that the fan presence
application in this repo provides, but with it in this application all
fan errors are created from the same place.  This will become important
when there is a power off due to a fan missing and the error for that
needs to be re-committed at power off time so it can be shown as the
cause of the power off.

The functionality is configured in the JSON:

fan_missing_error_delay:
Defines the number of seconds a fan must be missing with power on before
an error will be created.  If this isn't present in the JSON, then
errors will not be created at all.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I76de9d8d1bf6e283560b1ce46e70f84522e2d708
diff --git a/monitor/json_parser.cpp b/monitor/json_parser.cpp
index 46ae049..1bb018d 100644
--- a/monitor/json_parser.cpp
+++ b/monitor/json_parser.cpp
@@ -223,6 +223,14 @@
             nonfuncRotorErrorDelay = 0;
         }
 
+        // fan_missing_error_delay is optional.
+        std::optional<size_t> fanMissingErrorDelay;
+        if (fan.contains("fan_missing_error_delay"))
+        {
+            fanMissingErrorDelay =
+                fan.at("fan_missing_error_delay").get<size_t>();
+        }
+
         // Handle optional conditions
         auto cond = std::optional<Condition>();
         if (fan.contains("condition"))
@@ -253,11 +261,11 @@
                     entry("JSON_DUMP=%s", fan["condition"].dump().c_str()));
             }
         }
-        fanDefs.emplace_back(
-            std::tuple(fan["inventory"].get<std::string>(), funcDelay,
-                       fan["allowed_out_of_range_time"].get<size_t>(),
-                       fan["deviation"].get<size_t>(), nonfuncSensorsCount,
-                       monitorDelay, nonfuncRotorErrorDelay, sensorDefs, cond));
+        fanDefs.emplace_back(std::tuple(
+            fan["inventory"].get<std::string>(), funcDelay,
+            fan["allowed_out_of_range_time"].get<size_t>(),
+            fan["deviation"].get<size_t>(), nonfuncSensorsCount, monitorDelay,
+            nonfuncRotorErrorDelay, fanMissingErrorDelay, sensorDefs, cond));
     }
 
     return fanDefs;