Prevent missing sensor PEL when host is not running

occ-control will create a PEL if the OCC sensors PDRs have not been
found after 5 mintues.
This change will prevent creating that PEL if the host is not at
runtime.
This condition can happen if the host is powered on and then powered off
before all sensors have been found.

Change-Id: I885f2148b7527ef9b577a60dd33ac9af3618e831
Signed-off-by: Chris Cain <cjcain@us.ibm.com>
diff --git a/occ_manager.cpp b/occ_manager.cpp
index 3772265..7905600 100644
--- a/occ_manager.cpp
+++ b/occ_manager.cpp
@@ -146,6 +146,17 @@
                     tracedHostWait = true;
                 }
                 discoverTimer->restartOnce(30s);
+#ifdef PLDM
+                if (throttleTraceTimer->isEnabled())
+                {
+                    // Host is no longer running, disable throttle timer and
+                    // make sure traces are not throttled
+                    log<level::INFO>(
+                        "findAndCreateObjects(): disabling sensor timer");
+                    throttleTraceTimer->setEnabled(false);
+                    pldmHandle->setTraceThrottle(false);
+                }
+#endif
             }
         }
     }
@@ -230,6 +241,17 @@
             waitingForHost = true;
             log<level::INFO>(
                 "checkAllActiveSensors(): Waiting for host to start");
+#ifdef PLDM
+            if (throttleTraceTimer->isEnabled())
+            {
+                // Host is no longer running, disable throttle timer and
+                // make sure traces are not throttled
+                log<level::INFO>(
+                    "checkAllActiveSensors(): disabling sensor timer");
+                throttleTraceTimer->setEnabled(false);
+                pldmHandle->setTraceThrottle(false);
+            }
+#endif
         }
     }
 
@@ -1350,10 +1372,20 @@
 //   which will trigger pldm traces to be throttled.
 void Manager::throttleTraceExpired()
 {
-    // Throttle traces
-    pldmHandle->setTraceThrottle(true);
-    // Create PEL
-    createPldmSensorPEL();
+    if (utils::isHostRunning())
+    {
+        // Throttle traces
+        pldmHandle->setTraceThrottle(true);
+        // Create PEL
+        createPldmSensorPEL();
+    }
+    else
+    {
+        // Make sure traces are not throttled
+        pldmHandle->setTraceThrottle(false);
+        log<level::INFO>(
+            "throttleTraceExpired(): host it not running ignoring sensor timer");
+    }
 }
 
 void Manager::createPldmSensorPEL()