monitor: Add delay for host control

Some OpenBMC platforms use dbus-sensor and entity-manager to create
the fan sensors. In those systems, phosphor-fan-monitor starts before
the fan sensors are created during BMC boot up. phosphor-fan-monitor
is designed to shutdown the host when there is no fan tach sensors which
is not desirable in this case. This patch supports a package
configuration option delay-host-control to add a desired delay before
phosphor-fan-monitor turns off host. This can be configured to match
with each system timing.

Signed-off-by: Chau Ly <chaul@amperecomputing.com>
Change-Id: I63cd85eb5e6cb04069ce7b4c21c2f4621d243502
diff --git a/monitor/system.cpp b/monitor/system.cpp
index bcd9e33..6408ef4 100644
--- a/monitor/system.cpp
+++ b/monitor/system.cpp
@@ -377,8 +377,23 @@
                 return fan->numSensorsOnDBusAtPowerOn() == 0;
             }))
         {
+#if DELAY_HOST_CONTROL > 0
+            sleep(DELAY_HOST_CONTROL);
+            std::for_each(_fans.begin(), _fans.end(),
+                          [powerStateOn](auto& fan) {
+                              fan->powerStateChanged(powerStateOn);
+                          });
+            if (std::all_of(_fans.begin(), _fans.end(), [](const auto& fan) {
+                    return fan->numSensorsOnDBusAtPowerOn() == 0;
+                }))
+            {
+                handleOfflineFanController();
+                return;
+            }
+#else
             handleOfflineFanController();
             return;
+#endif
         }
 
         if (_sensorMatch.empty())