Mik*_*ell 6 linux ntp centos nagios
我有一个在子网上运行的本地 NTP 服务器,以保持其他子网节点同步,而不需要每个节点都与上游服务器同步。但是,在check_ntp_time
为 Nagios实施插件时,我注意到一个令人沮丧的问题,即 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
Run Code Online (Sandbox Code Playgroud)
而在本地非 ntp 服务器节点上,除了限制条目被删除之外,一切都相同,并且服务器条目仅引用本地 ntp 服务器:server ntp.example.com iburst
。
每个本地节点都可以解析ntp.example.com
.
我遇到的问题是当我从 nagios 服务器运行以下命令时:
/usr/lib64/nagios/plugins/check_ntp_time -H node-a-1 -v
Run Code Online (Sandbox Code Playgroud)
和输出:
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|
Run Code Online (Sandbox Code Playgroud)
除了引用上游服务器的本地 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
Run Code Online (Sandbox Code Playgroud)
版本:
nagios-plugins-ntp: 1.4.16
ntp: 4.2.6p5-1.el6.centos
Run Code Online (Sandbox Code Playgroud)
非常感谢任何帮助,在解决此问题之前我真的无法提交 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
Run Code Online (Sandbox Code Playgroud)
这里的关键是这一行:
丢弃对等体 0:层=0
将自身标识为层 0 的 NTP 服务器违反了规范(它是为原子钟或类似的东西保留的)。几年前我在一些 BSD 和 Mac OS X 主机上遇到过这个问题。我最终从源代码中破解了层检查,并为“有问题的”主机维护了一个单独的插件构建。
有问题的线路是 254-257(目前,无论如何),如果你想把它撕掉。这是一个黑客,但它对我有用;-)
我在关于它的邮件列表档案中找到了这个线程。我认为还有另一个我建议添加命令行选项来忽略层检查,但我认为它没有任何吸引力。
还有一个关于它的错误报告,但据我所知,它没有产生任何有用的东西。
归档时间: |
|
查看次数: |
26557 次 |
最近记录: |