sensor-monitor: Capture PID in event logs

Pass the PID of the process into an event log with the _PID additional
data entry.  This gets done automatically when the report() or commit()
phosphor-logging event log library functions are called, but needs to be
done manually when the D-Bus API is used.  This just provides a way to
see which process created the event log and I just forgot to do this
when I first wrote it..

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I094a0eb9634df53759f257799ae518ffd63e45cd
diff --git a/sensor-monitor/shutdown_alarm_monitor.cpp b/sensor-monitor/shutdown_alarm_monitor.cpp
index e5b6bf3..73b9c4e 100644
--- a/sensor-monitor/shutdown_alarm_monitor.cpp
+++ b/sensor-monitor/shutdown_alarm_monitor.cpp
@@ -18,6 +18,7 @@
 #include "shutdown_alarm_monitor.hpp"
 
 #include <fmt/format.h>
+#include <unistd.h>
 
 #include <phosphor-logging/log.hpp>
 #include <xyz/openbmc_project/Logging/Entry/server.hpp>
@@ -406,7 +407,8 @@
 {
     using namespace sdbusplus::xyz::openbmc_project::Logging::server;
     const auto& [sensorPath, shutdownType, alarmType] = alarmKey;
-    std::map<std::string, std::string> ad{{"SENSOR_NAME", sensorPath}};
+    std::map<std::string, std::string> ad{{"SENSOR_NAME", sensorPath},
+                                          {"_PID", std::to_string(getpid())}};
 
     std::string errorName =
         (alarmValue) ? alarmEventLogs.at(shutdownType).at(alarmType)
diff --git a/sensor-monitor/threshold_alarm_logger.cpp b/sensor-monitor/threshold_alarm_logger.cpp
index bab6002..f50fb6a 100644
--- a/sensor-monitor/threshold_alarm_logger.cpp
+++ b/sensor-monitor/threshold_alarm_logger.cpp
@@ -18,6 +18,7 @@
 #include "sdbusplus.hpp"
 
 #include <fmt/format.h>
+#include <unistd.h>
 
 #include <phosphor-logging/log.hpp>
 #include <xyz/openbmc_project/Logging/Entry/server.hpp>
@@ -229,6 +230,7 @@
     }
 
     ad.emplace("SENSOR_NAME", sensorPath);
+    ad.emplace("_PID", std::to_string(getpid()));
 
     try
     {