dreport: Collect journal log in case PID is not present

dreport uses PID information from the elog or core file to
collect PID based journal logs as part the BMC dump.
Existing dreport skips journal log collection in case PID
information is missing in the elog or core file.

Proposed changes help to collect the last 500 journal entries when
the PID is not present in the elog entry or core file.

Resolves openbmc/openbmc#2716

Change-Id: Ib3d8dfea64ea17f4b020b429267294c36530848b
Signed-off-by: Jayanth Othayoth <ojayanth@in.ibm.com>
diff --git a/tools/dreport.d/plugins.d/journalpid b/tools/dreport.d/plugins.d/journalpid
index aa6a19a..0481d4d 100644
--- a/tools/dreport.d/plugins.d/journalpid
+++ b/tools/dreport.d/plugins.d/journalpid
@@ -7,7 +7,14 @@
 . $DREPORT_INCLUDE/functions
 
 desc="Journal pid:$pid log"
-file_name="journal-pid-$pid.log"
-command="journalctl -o verbose _PID=$pid"
+
+if [ $pid -eq $ZERO ]; then
+    log_warning "Missing PID, Collecting last 500 journal entries"
+    file_name="journal.log"
+    command="journalctl -o verbose -n $JOURNAL_LINE_LIMIT"
+else
+    file_name="journal-pid-$pid.log"
+    command="journalctl -o verbose _PID=$pid"
+fi
 
 add_cmd_output "$command" "$file_name" "$desc"