![如何在文件中获取 Nagios 的输出](https://linux22.com/image/597857/%E5%A6%82%E4%BD%95%E5%9C%A8%E6%96%87%E4%BB%B6%E4%B8%AD%E8%8E%B7%E5%8F%96%20Nagios%20%E7%9A%84%E8%BE%93%E5%87%BA.png)
我已经为 Linux 服务器 m/c 配置了 Nagios 监控工具,以监控另一个 Linux 主机 m/c(到目前为止,我只监控单个 m/c)。我按照官方文档在服务器端安装了 nagios 服务器,在客户端安装了 NRPE 守护程序。根据文档,nagios 运行正常,并定期检查我已监控的所有服务,还安装了一些附加插件。
但我想知道如何以适当的格式将监控历史记录输出到特定文件中。由于我尚未通过 Apache 安装 Web 界面,因此是否有任何解决方案可以解决我的问题
以下是我获取的 nagios 监控日志文件:
[1349064000] LOG ROTATION: DAILY
[1349064000] LOG VERSION: 2.0
[1349064000] CURRENT HOST STATE: localhost;UP;HARD;1;PING OK - Packet loss = 0%, RTA = 0.03 ms
[1349064000] CURRENT HOST STATE: remotehost;UP;HARD;1;PING OK - Packet loss = 0%, RTA = 0.17 ms
[1349064000] CURRENT SERVICE STATE: localhost;Current Load;OK;HARD;1;OK - load average: 0.00, 0.00, 0.00
[1349064000] CURRENT SERVICE STATE: localhost;Current Users;OK;HARD;1;USERS OK - 7 users currently logged in
[1349064000] CURRENT SERVICE STATE: localhost;HTTP;OK;HARD;1;HTTP OK HTTP/1.1 200 OK - 1889 bytes in 0.001 seconds
[1349064000] CURRENT SERVICE STATE: localhost;PING;OK;HARD;1;PING OK - Packet loss = 0%, RTA = 0.04 ms
[1349064000] CURRENT SERVICE STATE: localhost;Root Partition;CRITICAL;HARD;100;DISK CRITICAL - free space: / 108 MB (1% inode=61%):
[1349064000] CURRENT SERVICE STATE: localhost;SSH;OK;HARD;1;SSH OK - OpenSSH_5.1 (protocol 2.0)
[1349064000] CURRENT SERVICE STATE: localhost;Swap Usage;OK;HARD;1;SWAP OK - 97% free (841 MB out of 870 MB)
[1349064000] CURRENT SERVICE STATE: localhost;Total Processes;OK;HARD;1;PROCS OK: 79 processes with STATE = RSZDT
[1349064000] CURRENT SERVICE STATE: remotehost;CPU Load;OK;HARD;1;OK - load average: 0.08, 0.02, 0.01
[1349064000] CURRENT SERVICE STATE: remotehost;Current Users;WARNING;HARD;3;USERS WARNING - 3 users currently logged in
[1349064000] CURRENT SERVICE STATE: remotehost;File Size;WARNING;HARD;3;WARN: /home/new/ctags.1p has size 13864 Byte. Warn at 13000. :
[1349064000] CURRENT SERVICE STATE: remotehost;Swap Usage;OK;HARD;1;SWAP OK - 100% free (869 MB out of 870 MB)
[1349064000] CURRENT SERVICE STATE: remotehost;Total Processes;OK;HARD;1;PROCS OK: 106 processes
[1349064000] CURRENT SERVICE STATE: remotehost;Zombie Processes;OK;HARD;1;PROCS OK: 0 processes with STATE = Z
[1349064028] SERVICE NOTIFICATION: nagiosadmin;remotehost;Current Users;WARNING;notify-service-by-email;USERS WARNING - 3 users currently logged in
[1349064988] Auto-save of retention data completed successfully.
[1349065258] SERVICE NOTIFICATION: nagiosadmin;remotehost;File Size;WARNING;notify-service-by-email;WARN: /home/new/ctags.1p has size 13864 Byte. Warn at 13000. :
[1349065938] SERVICE NOTIFICATION: nagiosadmin;localhost;Root Partition;CRITICAL;notify-service-by-email;DISK CRITICAL - free space: / 109 MB (1% inode=61%):
[1349067628] SERVICE NOTIFICATION: nagiosadmin;remotehost;Current Users;WARNING;notify-service-by-email;USERS WARNING - 3 users currently logged in
[1349068588] Auto-save of retention data completed successfully.
[1349068858] SERVICE NOTIFICATION: nagiosadmin;remotehost;File Size;WARNING;notify-service-by-email;WARN: /home/new/ctags.1p has size 13864 Byte. Warn at 13000. :
[1349069538] SERVICE NOTIFICATION: nagiosadmin;localhost;Root Partition;CRITICAL;notify-service-by-email;DISK CRITICAL - free space: / 109 MB (1% inode=61%)
如果我在这件事上有什么错误,请告诉我。如果这个问题需要更多 nagios 信息,请告诉我,我一定会分享。
提前致谢。
答案1
您可以通过启用 nagios.cfg 中的各种 log_ 选项来启用更多日志记录,但这实际上不是 Nagios 的用途。请参阅nagios.cfg 上的文档页面
Nagios 的真正优势在于通知和事件处理程序逻辑,但如果您只想将结果记录在某处,您可能还需要研究 ndoutils。这将允许您将结果放入数据库中。一旦您完成这项工作,还有其他工具可以利用这些数据。