我在子网上运行本地NTP服务器以保持其他子网节点同步,而不是每个节点都与上游服务器同步.但是,在为Nagios实现check_ntp_time插件时,我注意到一个令人沮丧的问题,即nagios一直报告本地节点与本地ntp服务器同步的严重错误.
这是本地ntp服务器上的ntp配置,注意上游服务器条目和限制条目,根据我的研究,这将节点定义为本地节点可以同步的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
在本地非ntp服务器节点上,除了限制条目被删除之外,一切都是相同的,并且服务器条目仅引用本地ntp服务器:server ntp.example.com iburst.
每个本地节点都可以解析ntp.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