Tee / sed / systemd-cat将消息延迟到journald

时间:2017-08-17 14:47:51

标签: debugging sed tee journal

我需要一个脚本来将stdout发送到journald和控制台并行。对于期刊行,我需要在持久化之前对消息进行消毒。

我有一个虚拟的例子来说明我的问题:

ping google.com | tee >( sed 's/seq/SEQ/' | systemd-cat -t 'my-ping')

当我有sed& systemd-cat将消息发送到journald,并且只有在停止ping过程后才会到达。

示例:

$ ping google.com | tee >( sed 's/seq/SEQ/' | systemd-cat -t 'my-ping')
PING google.com (216.58.197.238) 56(84) bytes of data.
64 bytes from nrt13s49-in-f14.1e100.net (216.58.197.238): icmp_seq=1 ttl=40 time=240 ms
64 bytes from nrt13s49-in-f14.1e100.net (216.58.197.238): icmp_seq=2 ttl=40 time=240 ms
64 bytes from nrt13s49-in-f14.1e100.net (216.58.197.238): icmp_seq=3 ttl=40 time=240 ms
64 bytes from nrt13s49-in-f14.1e100.net (216.58.197.238): icmp_seq=4 ttl=40 time=240 ms
64 bytes from nrt13s49-in-f14.1e100.net (216.58.197.238): icmp_seq=5 ttl=40 time=240 ms
^C

消息一次全部进入(参见时间戳):

journalctl -f | grep my-ping
Aug 17 06:03:40 hostname my-ping[30555]: PING google.com (216.58.197.238) 56(84) bytes of data.
Aug 17 06:03:40 hostname my-ping[30555]: 64 bytes from nrt13s49-in-f14.1e100.net (216.58.197.238): icmp_SEQ=1 ttl=40 time=240 ms
Aug 17 06:03:40 hostname my-ping[30555]: 64 bytes from nrt13s49-in-f14.1e100.net (216.58.197.238): icmp_SEQ=2 ttl=40 time=240 ms
Aug 17 06:03:40 hostname my-ping[30555]: 64 bytes from nrt13s49-in-f14.1e100.net (216.58.197.238): icmp_SEQ=3 ttl=40 time=240 ms
Aug 17 06:03:40 hostname my-ping[30555]: 64 bytes from nrt13s49-in-f14.1e100.net (216.58.197.238): icmp_SEQ=4 ttl=40 time=240 ms
Aug 17 06:03:40 hostname my-ping[30555]: 64 bytes from nrt13s49-in-f14.1e100.net (216.58.197.238): icmp_SEQ=5 ttl=40 time=240 ms

似乎这种行为只有在我使用它们时才会出现,如果其中任何一个被遗漏,一切都按预期工作。

你有什么指示可能是什么问题以及如何克服它?

0 个答案:

没有答案