meta-ampere: mtjade: Support host consoles logger
This commit supports phosphor-hostlogger in STREAM mode, to forward
the byte stream from obmc-console to rsyslog via the imuxsock module.
The logs can be obtained in /var/log/. The logs are rotated by
logrotate. The size threshold of cpu console is 256KB and the others are
64KB. Each log is polled every 1 minute to check if its file size
exceeds the threshold to rotate it to the new file. Each console can be
saved in up to 2 log files.
Tested (CPU console):
1. Change the mux of CPU console to BMC
$ ampere_uartmux_ctrl.sh 1 2
2. Connect to CPU SOL console
$ ssh root@<BMC_IP> -p 2200
3. Execute commands in the CPU SOL console
=> The console output on CPU SOL console will all be logged to
/var/log/obmc-console-cpu.log
=> The log will be rotated to /var/log/obmc-console-cpu.log.1 if the
original log file size exceeds 256KB every 1min poll
Signed-off-by: Chau Ly <chaul@amperecomputing.com>
Change-Id: I5586d1c634ec0f244069b868bd48b75560520dc1
diff --git a/meta-ampere/meta-common/recipes-extended/rsyslog/rsyslog/hostconsole.conf b/meta-ampere/meta-common/recipes-extended/rsyslog/rsyslog/hostconsole.conf
new file mode 100644
index 0000000..6900a5d
--- /dev/null
+++ b/meta-ampere/meta-common/recipes-extended/rsyslog/rsyslog/hostconsole.conf
@@ -0,0 +1,91 @@
+#Host console log
+
+module(load="imuxsock" SysSock.Use="off")
+
+template(name="ConsoleTemplate" type="string" string="%rawmsg%")
+
+ruleset(name="ConsoleCPURuleset") {
+ action(type="omfile" file="/var/log/obmc-console-cpu.log" template="ConsoleTemplate")
+}
+ruleset(name="ConsoleATFRuleset") {
+ action(type="omfile" file="/var/log/obmc-console-atf.log" template="ConsoleTemplate")
+}
+ruleset(name="ConsoleSECPRO0Ruleset") {
+ action(type="omfile" file="/var/log/obmc-console-secpro0.log" template="ConsoleTemplate")
+}
+ruleset(name="ConsoleSECPRO1Ruleset") {
+ action(type="omfile" file="/var/log/obmc-console-secpro1.log" template="ConsoleTemplate")
+}
+ruleset(name="ConsoleMPRO0Ruleset") {
+ action(type="omfile" file="/var/log/obmc-console-mpro0.log" template="ConsoleTemplate")
+}
+ruleset(name="ConsoleMPRO1Ruleset") {
+ action(type="omfile" file="/var/log/obmc-console-mpro1.log" template="ConsoleTemplate")
+}
+ruleset(name="ConsoleSCP0Ruleset") {
+ action(type="omfile" file="/var/log/obmc-console-scp0.log" template="ConsoleTemplate")
+}
+ruleset(name="ConsoleSCP1Ruleset") {
+ action(type="omfile" file="/var/log/obmc-console-scp1.log" template="ConsoleTemplate")
+}
+
+# Custom socket for serial console logs.
+input(type="imuxsock"
+ Socket="/run/rsyslog/console/cpu"
+ CreatePath="on"
+ UseSpecialParser="off"
+ ParseHostname="off"
+ ruleset="ConsoleCPURuleset")
+
+input(type="imuxsock"
+ Socket="/run/rsyslog/console/atf"
+ CreatePath="on"
+ UseSpecialParser="off"
+ ParseHostname="off"
+ ruleset="ConsoleATFRuleset")
+
+input(type="imuxsock"
+ Socket="/run/rsyslog/console/secpro0"
+ CreatePath="on"
+ UseSpecialParser="off"
+ ParseHostname="off"
+ ruleset="ConsoleSECPRO0Ruleset")
+
+input(type="imuxsock"
+ Socket="/run/rsyslog/console/secpro1"
+ CreatePath="on"
+ UseSpecialParser="off"
+ ParseHostname="off"
+ ruleset="ConsoleSECPRO1Ruleset")
+
+input(type="imuxsock"
+ Socket="/run/rsyslog/console/mpro0"
+ CreatePath="on"
+ UseSpecialParser="off"
+ ParseHostname="off"
+ ruleset="ConsoleMPRO0Ruleset")
+
+input(type="imuxsock"
+ Socket="/run/rsyslog/console/mpro1"
+ CreatePath="on"
+ UseSpecialParser="off"
+ ParseHostname="off"
+ ruleset="ConsoleMPRO1Ruleset")
+
+input(type="imuxsock"
+ Socket="/run/rsyslog/console/scp0"
+ CreatePath="on"
+ UseSpecialParser="off"
+ ParseHostname="off"
+ ruleset="ConsoleSCP0Ruleset")
+
+input(type="imuxsock"
+ Socket="/run/rsyslog/console/scp1"
+ CreatePath="on"
+ UseSpecialParser="off"
+ ParseHostname="off"
+ ruleset="ConsoleSCP1Ruleset")
+
+$EscapeControlCharactersOnReceive off
+$DropTrailingLFOnReception off
+
diff --git a/meta-ampere/meta-common/recipes-extended/rsyslog/rsyslog/rsyslog.logrotate b/meta-ampere/meta-common/recipes-extended/rsyslog/rsyslog/rsyslog.logrotate
index a6ba28d..098236a 100644
--- a/meta-ampere/meta-common/recipes-extended/rsyslog/rsyslog/rsyslog.logrotate
+++ b/meta-ampere/meta-common/recipes-extended/rsyslog/rsyslog/rsyslog.logrotate
@@ -20,3 +20,48 @@
systemctl reload rsyslog 2> /dev/null || true
endscript
}
+# Keep up to 2 256k files for cpu console logs
+/var/log/obmc-console-cpu.log
+{
+ copytruncate
+ rotate 1
+ size 256k
+ missingok
+ postrotate
+ systemctl reload rsyslog 2> /dev/null || true
+ endscript
+}
+# Keep up to 2 64k files for atf console logs
+/var/log/obmc-console-atf.log
+{
+ copytruncate
+ rotate 1
+ size 64k
+ missingok
+ postrotate
+ systemctl reload rsyslog 2> /dev/null || true
+ endscript
+}
+# Keep up to 2 64k files for secpro and mpro console logs
+/var/log/obmc-console-*pro*.log
+{
+ copytruncate
+ rotate 1
+ size 64k
+ missingok
+ postrotate
+ systemctl reload rsyslog 2> /dev/null || true
+ endscript
+}
+
+# Keep up to 2 64k files for Mt.Jade's scp console logs
+/var/log/obmc-console-scp*.log
+{
+ copytruncate
+ rotate 1
+ size 64k
+ missingok
+ postrotate
+ systemctl reload rsyslog 2> /dev/null || true
+ endscript
+}
diff --git a/meta-ampere/meta-common/recipes-extended/rsyslog/rsyslog_%.bbappend b/meta-ampere/meta-common/recipes-extended/rsyslog/rsyslog_%.bbappend
index 034ae3c..863f314 100644
--- a/meta-ampere/meta-common/recipes-extended/rsyslog/rsyslog_%.bbappend
+++ b/meta-ampere/meta-common/recipes-extended/rsyslog/rsyslog_%.bbappend
@@ -5,6 +5,7 @@
file://rotate-event-logs.service \
file://rotate-event-logs.sh \
file://rsyslog-override.conf \
+ file://hostconsole.conf \
"
FILES:${PN} += "${systemd_system_unitdir}/rsyslog.service.d/rsyslog-override.conf"
@@ -18,6 +19,7 @@
${D}${systemd_system_unitdir}/rsyslog.service.d/rsyslog-override.conf
install -d ${D}${bindir}
install -m 0755 ${WORKDIR}/rotate-event-logs.sh ${D}/${bindir}/rotate-event-logs.sh
+ install -m 0755 ${WORKDIR}/hostconsole.conf ${D}${sysconfdir}/rsyslog.d/hostconsole.conf
rm ${D}${sysconfdir}/rsyslog.d/imjournal.conf
}
diff --git a/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/server.ttyS0.conf b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/server.ttyS0.conf
index 2d02a51..2d80850 100644
--- a/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/server.ttyS0.conf
+++ b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/server.ttyS0.conf
@@ -1,3 +1,3 @@
+# socket-id is default to obmc-console
local-tty = ttyS0
local-tty-baud = 115200
-logfile = /var/log/obmc-console-cpu.log
diff --git a/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/server.ttyS1.conf b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/server.ttyS1.conf
index a771884..6421f93 100644
--- a/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/server.ttyS1.conf
+++ b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/server.ttyS1.conf
@@ -1,4 +1,3 @@
local-tty = ttyS1
local-tty-baud = 115200
socket-id = ttyS1
-logfile = /var/log/obmc-console-scp0.log
diff --git a/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/server.ttyS2.conf b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/server.ttyS2.conf
index 7ac6953..f8be872 100644
--- a/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/server.ttyS2.conf
+++ b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/server.ttyS2.conf
@@ -1,4 +1,3 @@
local-tty = ttyS2
local-tty-baud = 115200
socket-id = ttyS2
-logfile = /var/log/obmc-console-atf.log
diff --git a/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/server.ttyS3.conf b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/server.ttyS3.conf
index 0ec1b69..8f1ebba 100644
--- a/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/server.ttyS3.conf
+++ b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/server.ttyS3.conf
@@ -1,4 +1,3 @@
local-tty = ttyS3
local-tty-baud = 115200
socket-id = ttyS3
-logfile = /var/log/obmc-console-scp1.log
diff --git a/meta-ampere/meta-jade/recipes-phosphor/hostlogger/phosphor-hostlogger/ttyS0.conf b/meta-ampere/meta-jade/recipes-phosphor/hostlogger/phosphor-hostlogger/ttyS0.conf
new file mode 100644
index 0000000..e0c10a4
--- /dev/null
+++ b/meta-ampere/meta-jade/recipes-phosphor/hostlogger/phosphor-hostlogger/ttyS0.conf
@@ -0,0 +1,3 @@
+# SOCKET-ID is default to obmc-console
+MODE=stream
+STREAM_DST=/run/rsyslog/console/cpu
diff --git a/meta-ampere/meta-jade/recipes-phosphor/hostlogger/phosphor-hostlogger/ttyS1.conf b/meta-ampere/meta-jade/recipes-phosphor/hostlogger/phosphor-hostlogger/ttyS1.conf
new file mode 100644
index 0000000..faaf1a4
--- /dev/null
+++ b/meta-ampere/meta-jade/recipes-phosphor/hostlogger/phosphor-hostlogger/ttyS1.conf
@@ -0,0 +1,3 @@
+SOCKET_ID=ttyS1
+MODE=stream
+STREAM_DST=/run/rsyslog/console/scp0
diff --git a/meta-ampere/meta-jade/recipes-phosphor/hostlogger/phosphor-hostlogger/ttyS2.conf b/meta-ampere/meta-jade/recipes-phosphor/hostlogger/phosphor-hostlogger/ttyS2.conf
new file mode 100644
index 0000000..5d3cfb6
--- /dev/null
+++ b/meta-ampere/meta-jade/recipes-phosphor/hostlogger/phosphor-hostlogger/ttyS2.conf
@@ -0,0 +1,3 @@
+SOCKET_ID=ttyS2
+MODE=stream
+STREAM_DST=/run/rsyslog/console/atf
diff --git a/meta-ampere/meta-jade/recipes-phosphor/hostlogger/phosphor-hostlogger/ttyS3.conf b/meta-ampere/meta-jade/recipes-phosphor/hostlogger/phosphor-hostlogger/ttyS3.conf
new file mode 100644
index 0000000..14bfd4b
--- /dev/null
+++ b/meta-ampere/meta-jade/recipes-phosphor/hostlogger/phosphor-hostlogger/ttyS3.conf
@@ -0,0 +1,3 @@
+SOCKET_ID=ttyS3
+MODE=stream
+STREAM_DST=/run/rsyslog/console/scp1
diff --git a/meta-ampere/meta-jade/recipes-phosphor/hostlogger/phosphor-hostlogger_%.bbappend b/meta-ampere/meta-jade/recipes-phosphor/hostlogger/phosphor-hostlogger_%.bbappend
new file mode 100644
index 0000000..38521ad
--- /dev/null
+++ b/meta-ampere/meta-jade/recipes-phosphor/hostlogger/phosphor-hostlogger_%.bbappend
@@ -0,0 +1,18 @@
+FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
+
+SRC_URI:append = " \
+ file://ttyS0.conf \
+ file://ttyS1.conf \
+ file://ttyS2.conf \
+ file://ttyS3.conf \
+ "
+
+do_install:append() {
+
+ # Install the configurations
+ install -m 0755 -d ${D}${sysconfdir}/${BPN}
+ install -m 0644 ${WORKDIR}/*.conf ${D}${sysconfdir}/${BPN}/
+
+ # Remove upstream-provided default configuration
+ rm -f ${D}${sysconfdir}/${BPN}/ttyVUART0.conf
+}