You are not logged in.
In my /etc/systemd/journal.conf the journal log is mirrored to a virtual console:
ForwardToConsole=yes
TTYPath=/dev/tty12
The output to the virtual console is the same as with
journalctl -n
However, the journal record's timestamp format is different. With 'journalctl' command it's "human readable", whereas the forwarded output in the virtual console shows the number of seconds from the boot as the timestamp. Is there a way to change the timestamp format for the forwarded output?
Last edited by nbd (2015-12-04 17:20:34)
bing different
Offline
journalctl formats the timestamp to the human readable format. The forwarder always provides raw data as it is in the journal itself, to allow people to apply their own filters. You could write a small filter and pipe the output through it.
Offline
Thanks for the idea. Such solution is even more convenient.
bing different
Offline
I initially marked this post as solved, but I cannot figure out how that filter would work. When I write in /etc/journald.conf
TTYPath=/path/to/myFilter
and the script myFilter is follows:
#!/bin/bash
read q && echo $q | sed -r -e "s/^\[.+\](.*)/[$(date +%k:%M:%S)]\1/" > /dev/tty12
then journal log is not forwarded. Although if I run in terminal something like:
echo [11122.2233] aaa bbb | /path/to/myFilter
The line is modified and outputted OK. How the forwarded journal log can be passed through a filter?
bing different
Offline
You cannot just forward your output to an executable and expect the kernel to know what you want with it. It must be a node like tty. I'm somewhat busy at the moment, but I'll get back at you, should you not have found it out yourself.
EDIT: Like, you know, output to tty60, read from tty60, filter and output it to tty12.
Last edited by Awebb (2015-12-03 19:16:16)
Offline
It must be a node like tty.
I supposed just that. Will read about mknod and named pipes. Thanks.
bing different
Offline
No luck. Tried:
#!/bin/bash
while true
do
if read line </dev/tty20; then
echo qqqqqqqqq
echo $line | sed -r -e "s/^\[.+\](.*)/[$(date +%k:%M:%S)]\1/" > /dev/tty12
fi
done
And then in terminal emulator:
$ echo qq > /dev/tty20
No output in either terminal or the /dev/tty12 console.
Also tried
mknod /dev/myFilter c 4 [X]
When 'X' is 12, then the output to /dev/myFilter goes straight to /dev/tty12 without being passed through the filter script. When 'X' is 20 - no output. When 'X' is 150 - error 'No such device.' Also tried:
mknod /dev/myFilter p
and
mknod /tmp/myFilter -c 4 20
Doesn't work either.
bing different
Offline
I have the following /etc/systemd/system/journal@tty12.service:
[Unit]
Description=Journal tail on %I
After=systemd-user-sessions.service systemd-journald.service
# On systems without virtual consoles, don't start any getty. (Note
# that serial gettys are covered by serial-getty@.service, not this
# unit
ConditionPathExists=/dev/tty0
[Service]
# the VT is cleared by TTYVTDisallocate
ExecStart=/bin/sh -c "exec /bin/journalctl -af > /dev/%I"
Type=idle
Restart=always
RestartSec=1
UtmpIdentifier=%I
TTYPath=/dev/%I
TTYReset=yes
TTYVHangup=yes
#TTYVTDisallocate=yes
TTYVTDisallocate=no
KillMode=process
IgnoreSIGPIPE=no
# Unset locale for the console getty since the console has problems
# displaying some internationalized messages.
Environment=LANG= LANGUAGE= LC_CTYPE= LC_NUMERIC= LC_TIME= LC_COLLATE= LC_MONETARY= LC_MESSAGES= LC_PAPER= LC_NAME= LC_ADDRESS= LC_TELEPHONE= LC_MEASUREMENT= LC_IDENTIFICATION=
[Install]
Alias=getty.target.wants/journal@tty12.service
Enable and start it. Disable forward to tty in /etc/systemd/journald.conf.
Mortuus in anima, curam gero cutis
Offline
patroclo7,
thanks, didn't occured to recall about 'journalctl -f'. Looks like a good or better alternative to "ForwardToConsole".
bing different
Offline