PEL: Add BMC uptime to PELs in UserData section

A UserData section has been added to each PEL with additional debug
information, now there is a need to add the output of the uptime
command to UserData and display it, but for Hostboot doesn't care
about this property, so skip adding it here it.

Tested: unit test passed
"User Data 0": {
    "Section Version": "1",
    "Sub-section type": "1",
    "Created by": "0x2000",
    ...
    "Uptime": "3y 332d 21h 33m 9s",
    "Load": "1.47 0.94 0.61",
},

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I3d4c78bb1650da9a91804fc83de60597992ffc8a
diff --git a/extensions/openpower-pels/pel.cpp b/extensions/openpower-pels/pel.cpp
index 898dce5..a84b7f8 100644
--- a/extensions/openpower-pels/pel.cpp
+++ b/extensions/openpower-pels/pel.cpp
@@ -574,8 +574,8 @@
                     static_cast<uint16_t>(ComponentID::phosphorLogging);
 
                 // Update system data to ED section
-                auto ud =
-                    util::makeSysInfoUserDataSection(additionalData, dataIface);
+                auto ud = util::makeSysInfoUserDataSection(additionalData,
+                                                           dataIface, false);
                 extUserData->updateDataSection(subType, componentId,
                                                ud->data());
             }
@@ -709,9 +709,24 @@
     json["BootState"] = lastSegment('.', dataIface.getBootState());
 }
 
+void addBMCUptime(nlohmann::json& json, const DataInterfaceBase& dataIface)
+{
+    auto seconds = dataIface.getUptimeInSeconds();
+    if (seconds)
+    {
+        json["BMCUptime"] = dataIface.getBMCUptime(*seconds);
+    }
+    else
+    {
+        json["BMCUptime"] = "";
+    }
+    json["BMCLoad"] = dataIface.getBMCLoadAvg();
+}
+
 std::unique_ptr<UserData>
     makeSysInfoUserDataSection(const AdditionalData& ad,
-                               const DataInterfaceBase& dataIface)
+                               const DataInterfaceBase& dataIface,
+                               bool addUptime)
 {
     nlohmann::json json;
 
@@ -720,6 +735,11 @@
     addIMKeyword(json, dataIface);
     addStatesToJSON(json, dataIface);
 
+    if (addUptime)
+    {
+        addBMCUptime(json, dataIface);
+    }
+
     return makeJSONUserDataSection(json);
 }