dreport: collecting all namespace journal logs
For BMCs that support multiple namespaces to manage logs, add the
--namespace=* option to the journalctl command to collect all logs.
refer to systemd-journald.service.html[0].
Tested:
1. Prepare a namespace configuration, to isolate logs (in general for
the third-party code, like silicon vendor, etc), avoid too many
unexpected to noise the system.
```
~# cp /etc/systemd/journald.conf /etc/systemd/journald@intel.conf
~# mkdir -p /etc/systemd/system/com.intel.crashdump.service.d
~# echo "[Service]" > /etc/systemd/system/com.intel.crashdump.service.d/override.conf
~# echo "LogNamespace=intel" >> /etc/systemd/system/com.intel.crashdump.service.d/override.conf
~# reboot # or restart systemd-journald, and daemon-reload
````
2. using journalctl vs journalctl --namespace=*
```
~# journalctl -u com.intel.crashdump.service
Dec 10 16:56:49 xxx systemd[1]: Starting Intel BMC CPU Crashdump...
Dec 10 16:56:55 xxx systemd[1]: Started Intel BMC CPU Crashdump.
```
```
~# journalctl --namespace=*
Dec 10 16:56:49 xxx systemd[1]: Starting Intel BMC CPU Crashdump...
Dec 10 16:56:55 xxx systemd[1]: Started Intel BMC CPU Crashdump.
Dec 10 16:56:57 xxx crashdump[258]: Crashdump version: ....
Dec 10 16:56:57 xxx crashdump[258]: Initializing crashdump...
....
```
3. After this change, check the journal logs, and the journal logs
should be collect the logs from all namespaces.
```
cat journal-pretty.log| ag "Initializing crashdump"
"MESSAGE" : "Initializing crashdump...",
```
[0]: https://www.freedesktop.org/software/systemd/man/latest/systemd-journald.service.html#Journal%20Namespaces
Change-Id: I70f33eb6119cbe041bb0dc2aac527e02d8f5e757
Signed-off-by: Jian Zhang <zhangjian.3032@bytedance.com>
diff --git a/ffdc b/ffdc
index 5587a33..8791f1f 100644
--- a/ffdc
+++ b/ffdc
@@ -26,7 +26,7 @@
"host_console.txt" "cat /var/log/obmc-console.log"
"BMC_proc_list.txt" "top -n 1 -b"
- "BMC_journalctl.txt" "journalctl --no-pager"
+ "BMC_journalctl.txt" "journalctl --namespace=* --no-pager"
"BMC_dmesg.txt" "dmesg"
"BMC_procinfo.txt" "cat /proc/cpuinfo"
"BMC_meminfo.txt" "cat /proc/meminfo"
diff --git a/tools/dreport.d/plugins.d/journalpid b/tools/dreport.d/plugins.d/journalpid
index c60e521..344d4c2 100644
--- a/tools/dreport.d/plugins.d/journalpid
+++ b/tools/dreport.d/plugins.d/journalpid
@@ -11,10 +11,10 @@
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"
+ command="journalctl --namespace=* -o verbose -n $JOURNAL_LINE_LIMIT"
else
file_name="journal-pid-$pid.log"
- command="journalctl -o verbose _PID=$pid"
+ command="journalctl --namespace=* -o verbose _PID=$pid"
fi
add_cmd_output "$command" "$file_name" "$desc"
diff --git a/tools/dreport.d/plugins.d/journalpretty b/tools/dreport.d/plugins.d/journalpretty
index d1986cc..109d549 100644
--- a/tools/dreport.d/plugins.d/journalpretty
+++ b/tools/dreport.d/plugins.d/journalpretty
@@ -8,6 +8,6 @@
desc="Journal pretty log"
file_name="journal-pretty.log"
-command="journalctl -o json-pretty -r"
+command="journalctl --namespace=* -o json-pretty -r"
add_cmd_output "$command" "$file_name" "$desc"