使用 nxlog 解析 sophos 文本文件并发送到 syslog 服务器

使用 nxlog 解析 sophos 文本文件并发送到 syslog 服务器

我有一台装有 sophos 的 Windows Server 2012 R2 机器。每天都会有来自 sophos 的扫描,并将信息附加到日志“sav.txt”中。

输出示例(部分信息已更改):

    20150710 205446 Using detection data version 5.16 (detection engine 3.58.3). This version can detect 9405871 items.
20150710 205446 User (NT AUTHORITY\LOCAL SERVICE) has started on-access scanning for this machine.
20150711 020000 Scan 'Sophos Management Server' started.
20150711 023317 Scan 'Sophos Management Server' completed.
20150711 023317 Summary of results for scan 'Sophos Management Server':
  Items scanned: 166433
  Errors: 0
  Items quarantined: 0
  Items dealt with: 0

使用 nxlog,我希望能够解析 sav.txt 文件以获取我在输出示例中显示的当天信息,并将该信息发送到 syslog 服务器。

唯一的问题是,随着时间的推移,sav.txt 文件会变得越来越大,我们希望 nxlog 仅发送该日期的文本文件中的信息。

仅 7 月 1 日,仅 7 月 1 日的消息将被发送到我们的系统日志服务器,7 月 2 日也是如此,等等。

我不知道这是否重要,但我们在服务器上使用 Kiwi Syslog。Kiwi 有一个适用于 Windows 的免费实用程序,但它不会解析文本文件,只会发送我们需要的信息。Kiwi 似乎只从事件日志中提取数据,但可以接收任何数据。

答案1

可能有不同的方法,但以下方法可以实现:

Exec if not (($raw_event =~ /^(\d{4})(\d{2})(\d{2}) /) and \
             (substr(string(now()), 0, 10) == $1 + '-' + $2 + '-' + $3)) drop();
  • 请注意,NXLog 只会发送最新的数据,并且通常不会重新发送整个文件,除非日志源创建新文件并复制内容。
  • 您可能希望使用 xm_multiline 来处理跨越多行的事件。
  • 在 sav.txt 上设置日志轮换以便将旧条目轮换掉不是更好吗?

相关内容