[systemd-devel] Collect logs over serial
Paul Menzel
pmenzel+systemd-devel at molgen.mpg.de
Thu Jan 31 16:34:25 UTC 2019
Dear systemd/udev folks,
Having a large pool of (different) systems, we hit Linux kernel
panics several times in a year. To better debug those, we want
to make use of the serial ports still present on today’s
systems.
Unfortunately, the serial ports on the back plane, we’d like to
use, are numbered differently. Can you recommend best practices
how to detect where that port is on a system?
Currently, we only do it for port ttyS1, by adding
`console=ttyS1,115200n8` to the Linux kernel command line *on
all systems*, and using the attached script and service unit
template and the server the serial cable is connected to.
```
[Unit]
Description=TTY logger
[Service]
ExecStart=/usr/libexec/serial-log %I
Type=simple
UtmpIdentifier=%I
[Install]
WantedBy=basic.target
```
```
devnam="$1"
while true; do
until /usr/bin/stty -F "/dev/$devnam" 115200 -echo 2>/dev/null; do
sleep 60
done
until cat "/dev/$devnam" >> /var/log/$devnam.log 2>&1;do
sleep 1
done
done
```
Polling the device every 60 seconds is not very elegant, and we
also would like to avoid having to configure each device
manually, where the serial port is.
Does udev/systemd/… have some features solving this more in a
better way?
Kind regards,
Paul
-------------- next part --------------
[Unit]
Description=TTY logger
[Service]
ExecStart=/usr/libexec/serial-log %I
Type=simple
UtmpIdentifier=%I
[Install]
WantedBy=basic.target
-------------- next part --------------
#! /bin/bash
(($#==1)) || { echo "usage: $0 device-name" >&2; exit 1; }
devnam="$1"
while true; do
until /usr/bin/stty -F "/dev/$devnam" 115200 -echo 2>/dev/null; do
sleep 60
done
until cat "/dev/$devnam" >> /var/log/$devnam.log 2>&1;do
sleep 1
done
done
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5174 bytes
Desc: S/MIME Cryptographic Signature
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20190131/6705322d/attachment-0001.bin>
More information about the systemd-devel
mailing list