如何在 OSX 中启用 syslogd 从路由器接收 UDP 日志

发布于 2024-07-29 07:32:37 字数 253 浏览 5 评论 0原文

有时路由器会坏,我想获取路由器日志。

虽然有些路由器具有内置日志查看器,但有些则没有。 大多数路由器似乎都有使用系统日志将日志发送到另一台主机的功能。

如何让 OSX(客户端)接收这些日志? OSX 有一个 syslogd,但指令充其量是不透明的。

也许不同的客户端应用程序会更好,但我更喜欢一种无需通过互联网下载刚刚崩溃的工具即可进行破解的方法...

OSX 本身没有 netcat,否则我会尝试这样做。

Occasionally a router goes bad and I would like to get the router logs.

While some routers have built-in log viewers, some do not. Most routers seem to have a facility to send logs to another host using syslog.

How do I get OSX (client) to receive these logs? OSX has a syslogd, but the instructions are opaque at best.

Perhaps a different client application would be better, but I'd prefer a way I could just hack up without downloading tools across the internet that has just broken down...

OSX does not have netcat, natively, otherwise I would have tried that.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

静待花开 2024-08-05 07:32:37

使用可能适用于 OS X 的 syslog-ng,虽然我不确定,但我使用以下 3 行通过家庭网络从我的 wifi 路由器捕获系统日志消息到我的日志服务器:

 source net { udp(); };

 destination wifirouter { file("/opt/var/log/wifirouter.log"); };

 log { source(net); destination(wifirouter); };

然后将 wifi 路由器配置为使用记录服务器的 IP 地址和 wifirouter 标识符。 您可以修改源行以仅接受来自某些源 IP 地址的信息。

Using syslog-ng which is probably available for OS X, although I am not certain, I capture syslog messages over my home network from my wifi router to my log server with the following 3 lines:

 source net { udp(); };

 destination wifirouter { file("/opt/var/log/wifirouter.log"); };

 log { source(net); destination(wifirouter); };

The wifi router was then configured to use use the log server's IP address and the wifirouter identifier. You could modify the source line to accept from only certain source IP addresses.

ま柒月 2024-08-05 07:32:37

对于现有的 Mac OS syslogd,所需的“魔法”如下。

编辑 syslogd 的 launchd 配置,/System/Library/LaunchDaemons/com.apple.syslogd.plist(您需要是 root 用户,或者使用“sudo vi”或您最喜欢的其他方法来编辑此配置) 。)

(某些版本似乎已经注释掉了必要的部分,但我的一个版本没有。)

在以下内容之后:

 <key>Sockets</key>
 <dict>
 ...
     <key>BSDSystemLogger</key>
     <dict>
     ...
     </dict>

添加或取消注释(删除前导“”行),此部分:

     <key>NetworkListener</key>
     <dict>
          <key>SockServiceName</key>
          <string>syslog</string>
          <key>SockType</key>
          <string>dgram</string>
     </dict>

然后重新启动 syslogd完全(即使用 launchctl,再次以 root 身份)

sudo launchctl unload /System/Library/LaunchDaemons/com.apple.syslogd.plist
sudo launchctl load /System/Library/LaunchDaemons/com.apple.syslogd.plist

(我认为这个问题/答案可能属于 superuser.com?也许有人可以将其移过去。)

The required "magic", with the stock Mac OS syslogd, is as follows.

Edit the launchd config for syslogd, /System/Library/LaunchDaemons/com.apple.syslogd.plist (you will need to be root, or use 'sudo vi' or your favourite other method to edit this.)

(Some versions seem to already have the necessary section commented out, but one of mine didn't.)

After the following:

 <key>Sockets</key>
 <dict>
 ...
     <key>BSDSystemLogger</key>
     <dict>
     ...
     </dict>

add in, or uncomment (remove the leading "" lines), this section:

     <key>NetworkListener</key>
     <dict>
          <key>SockServiceName</key>
          <string>syslog</string>
          <key>SockType</key>
          <string>dgram</string>
     </dict>

and then restart the syslogd completely (i.e. using launchctl, again as root)

sudo launchctl unload /System/Library/LaunchDaemons/com.apple.syslogd.plist
sudo launchctl load /System/Library/LaunchDaemons/com.apple.syslogd.plist

(I think this question/ answer probably belongs on superuser.com? Maybe someone can move it over.)

自控 2024-08-05 07:32:37

仅供参考,可以使用 XCode 套件附带的属性列表编辑器来编辑二进制 plist 文件,也可以使用第 3 方编辑器 Text Wrangler。 我还没有尝试过,但考虑到它与 TextWrangler 的血统,我怀疑 BBEdit 也能够编辑它。

FYI, binary plist files can be edited using either the Property List Editor included with the XCode suite, or you can use the 3rd party editor Text Wrangler. I've not tried it, but I suspect BBEdit would be able to edit it as well considering it's lineage with TextWrangler.

温折酒 2024-08-05 07:32:37

从 OS X 10.7 及更高版本开始,您应该参考此 StackOverflow 答案来了解此问题。

From OS X 10.7 and above you should refer to this StackOverflow answer for this question.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文