解决方案
- 确保 FreeBSD 时区正确。
- 更改 Nagios on time zone 的配置:
vi /usr/local/etc/nagios/nagios.cfg
找到“#TIMEZONE OFFSET”部分
添加以下行:
use_timezone=Asia/ChongQing
其他时区值可以从 /usr/share/zoneinfo 获取,例如
cd /usr/share/zoneinfo;ls
- 将时区值和参数插入 Apache 的 CGI 模块的虚拟主机,在 nagios 部分:
SetEnv TZ "Australia/Brisbane"
例如
Options ExecCGI AllowOverride None Order allow,deny Allow from all Order deny,allow Deny from all Allow from all SetEnv TZ "Asia/Kuala_Lumpur"
- 最后,重新启动 Nagios & Apache 以使上述更改生效:
/usr/local/etc/rc.d/nagios restart;/usr/local/etc/rc.d/apache22 reload
原因
Nagios 配置需要指定时区偏移量,以及 Apache 的 CGI 模块。
这两个设置确保 nagios 的时间与服务器的时间同步。
问题
Nagios 的时间戳不正确,例如注释部分,日志文件的时间戳。
但是服务器的日期、时间和时区是正确的。
日期:2020-06-02 22:17:10 来源:oir作者:oir