gpt4 book ai didi

linux - 如何为另一台机器发送系统日志条目?

转载 作者:太空宇宙 更新时间:2023-11-04 09:56:13 26 4
gpt4 key购买 nike

我有两台机器,“这里”和“那里”。

“那里”创建一个输出文件并将其发送到“这里”进行一些处理。 “此处”在输出上运行一个 shell 脚本,并使用 logger 将结果发送到 syslog 聚合器。不幸的是,日志聚合器将消息视为来自“这里”,但我希望消息看起来像是来自“那里”。

简而言之,我运行:

echo "Hello World"|logger -p local1.alert

并得到:

2010-11-09T15:40:11.516811-06:00 此处记录器:Hello World

但想要:

2010-11-09T15:40:11.516811-06:00 记录器:Hello World

有没有办法使用logger 使流量显示来自不同的主机?我使用的实际消息格式无法更改。

最佳答案

Syslog 和 syslog-ng 支持发送日志到其他机器。这就是输出中有主机名字段的原因! (描绘它们)。它已经这样做了很多年。否则,系统管理员将不得不四处奔走,从十亿台机器上收集日志以监视他们的系统。

来自“syslog.conf”手册页:

syslogd(8) provides full remote logging, i.e. is able to send mes-
sages to a remote host running syslogd(8) and to receive messages from
remote hosts. The remote host won’t forward the message again, it will
just log them locally. To forward messages to another host, prepend
the hostname with the at sign (‘‘@’’).

有关详细信息,请参阅 syslog.conf 手册页

关于linux - 如何为另一台机器发送系统日志条目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4138955/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com