开发者

How to send a syslog entry for another machine?

I have two machines, "here" and "there".

"there" creates 开发者_如何学Pythonan output file and sends it to "here" for some processing. "here" runs a shell script on the output and uses logger to send the results to a syslog aggregator. Unfortunately, the log aggregator sees the message as coming from "here", but I want it appear that the message came from "there".

In short, I run:

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

and get:

2010-11-09T15:40:11.516811-06:00 here logger: Hello World

but want:

2010-11-09T15:40:11.516811-06:00 there logger: Hello World

Is there a way to use logger to make the traffic appear from a different host? The actual message format I use cannot be changed.


Syslog and syslog-ng support sending logs to other machines. This is why there is a hostname field in the output! (To delineate them). It has done this for years. Else, sysadmins would have to run around collecting logs from a billion machines to watch their systems.

From the "syslog.conf" man page:

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 (‘‘@’’).

See the syslog.conf man page for more details


I believe the answer with logger is "no".

logger probably uses the syslog(3) library routine which has no provision for setting the host in a log entry.

You could write your own version of logger that sends the logs over the wire the way you want. http://www.faqs.org/rfcs/rfc3164.html


You could use the -t option of logger to tag each line from "there".

If this breaks your format for some log consumer, you could pre-process your logs before you consume them, replacing the hostname of all tagged lines and removing the tags.

Otherwise, you may need to get another part of this system to budge or write your own logger...


my man logger tells me to use

logger -n IP
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜