开发者

Make socat write to (TCP or UNIX) socket line by line for log gathering [closed]

开发者 https://www.devze.com 2023-03-12 15:23 出处:网络
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.

Closed 2 years ago.

Improve this question

I'm trying to merge several log files from multiple hosts. I'm doing a socat -u EXEC:'follow_log_cmd' UNIX-SENDTO:/tmp/socket for each log I want to follow.

On the log gathering machine I'm doing socat -u UNIX-RECV:/tmp/socket -

My problem is that log entries are getting overlapp开发者_开发问答ed sometimes because socat's not writing one line at a time, but instead a buffer at a time.

Is there any way to make it write one line at a time?


Try using a pseudo terminal to make socat's writing line buffered:

- socat -u EXEC:'follow_log_cmd' UNIX-SENDTO:/tmp/socket
+ socat -u EXEC:'follow_log_cmd',pty,ctty UNIX-SENDTO:/tmp/socket

See also: https://stackoverflow.com/questions/1000674/turn-off-buffering-in-pipe

0

精彩评论

暂无评论...
验证码 换一张
取 消