我有一个在子网上运行的本地NTP服务器,使其他子网节点保持同步,而不是每个节点都与上游服务器同步。 但是,在为Nagios实现check_ntp_time插件时,我注意到一个令人沮丧的问题,那就是nagios不断报告与本地ntp服务器同步的本地节点的严重错误。
这里是在本地ntp服务器上的ntpconfiguration,注意上游服务器条目和限制条目,根据我的研究,这将本节点定义为ntp服务器,本地节点可以同步。
driftfile /var/lib/ntp/drift # Permit time synchronization with our time source, but do not # permit the source to query or modify the service on this system. restrict default kod limited nomodify notrap nopeer noquery restrict -6 default kod limited nomodify notrap nopeer noquery # Permit all access over the loopback interface. This could # be tightened as well, but to do so would effect some of # the administrative functions. restrict 127.0.0.1 restrict -6 ::1 # Makes me able to answer requests from local nodes restrict 10.0.0.0 mask 255.255.192.0 nomodify notrap # My source server 0.centos.pool.ntp.org iburst server 1.centos.pool.ntp.org server 2.centos.pool.ntp.org logfile /var/log/ntp/server.log statistics loopstats statsdir /var/log/ntp/ filegen peerstats file peers type day link enable filegen loopstats file loops type day link enable
在本地的non-ntp服务器节点上,除了限制条目被删除以外,所有内容都是相同的, 服务器条目只引用本地ntp服务器: server ntp.example.com iburst 。
每个本地节点都可以parsingntp.example.com 。
我遇到的问题是当我从nagios服务器运行以下命令:
/usr/lib64/nagios/plugins/check_ntp_time -H node-a-1 -v
而输出:
sending request to peer 0 response from peer 0: offset -0.002921819687 sending request to peer 0 response from peer 0: offset -0.0001939535141 sending request to peer 0 re-sending request to peer 0 re-sending request to peer 0 re-sending request to peer 0 re-sending request to peer 0 re-sending request to peer 0 re-sending request to peer 0 discarding peer 0: stratum=0 overall average offset: 0 NTP CRITICAL: Offset unknown|
除了引用上游服务器的本地ntp服务器之外,所有节点都会发生这种情况。 起初我以为这是IPTables的问题,但我有端口在每个本地ntp节点(为了让nagios访问来检查时间差异)刺破:
ACCEPT udp -- eth0 * 10.0.0.0/18 0.0.0.0/0 multiport dports 123 /* 777 allow ntp access */ state NEW
版本:
nagios-plugins-ntp: 1.4.16 ntp: 4.2.6p5-1.el6.centos
任何帮助非常感谢,我真的不能提交nagios的工作,直到我得到解决,因为你知道保持同步服务器时间是优先级1。
– 编辑 –
根据评论,这里是ntpq -p在不同节点上的结果:
# Actual NTP Server (10.0.0.2) ============================================================================== +propjet.latt.ne 241.199.164.101 2 u 105 128 337 14.578 12.954 7.138 +x2la01.hostigat 63.145.169.2 3 u 21 128 377 16.037 13.546 4.090 *pacific.latt.ne 241.199.164.101 2 u 72 128 377 15.148 24.434 7.403 # Local node 1 ============================================================================== *service-a-1.sn1 204.2.134.163 3 u 9 128 377 0.228 5.217 1.296 # Local node 2 ============================================================================== *service-a-1.sn1 204.2.134.163 3 u 91 128 377 0.200 3.608 1.167
这里的关键是这一个:
丢弃peer 0:stratum = 0
一个NTP服务器标识自己为0层是违反规范(它保留primefaces钟或类似的东西)。 几年前,我遇到了一些BSD和Mac OS X主机的问题。 我结束了对源代码的入侵检查,并为“有问题的”主机维护一个单独的插件版本。
如果你想破解这个问题的话,那么这个违规的路线是254-257 (现在,无论如何)。 这是一个黑客,但它适用于我;-)
我发现这个线程在邮件列表存档关于它。 我想还有另一个地方,我build议增加一个命令行选项来忽略阶层检查,但是我不认为它有什么吸引力。
还有一个关于它的错误报告 ,但据我所知,它没有产生任何有用的东西。