linux – Nagios – check_ntp_time – 偏移未知

我在子网上运行本地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

解决方法

这里的关键是这一个:

discarding peer 0: stratum=0

将自身标识为层0的NTP服务器违反了规范(它保留用于原子钟或类似的东西).几年前我遇到了一些BSD和Mac OS X主机的问题.我最终破解了源代码中的stratum check并为“有问题”的主机维护了一个单独的插件版本.

The offending lines are 254-257(目前,无论如何),如果你想撕掉那个.这是一个黑客,但它对我有用;-)

我在邮件列表中找到了关于它的this thread档案.我认为还有一个我建议添加一个命令行选项来忽略层次检查,但我不认为它有任何牵引力.

关于它还有一个bug report,但就我所知,它还没有产生任何有用的东西.

相关文章

linux常用进程通信方式包括管道(pipe)、有名管道(FIFO)、...
Linux性能观测工具按类别可分为系统级别和进程级别,系统级别...
本文详细介绍了curl命令基础和高级用法,包括跳过https的证书...
本文包含作者工作中常用到的一些命令,用于诊断网络、磁盘占满...
linux的平均负载表示运行态和就绪态及不可中断状态(正在io)的...
CPU上下文频繁切换会导致系统性能下降,切换分为进程切换、线...