文档文档

网络时间协议查询输入插件

此插件收集有关 网络时间协议查询的指标。

此插件需要在系统上安装 ntpq 可执行文件。

引入于: Telegraf v0.11.0 标签: network 操作系统支持: all

全局配置选项

插件支持其他全局和插件配置设置,用于修改指标、标签和字段,创建别名以及配置插件顺序等任务。更多详情请参阅 CONFIGURATION.md

配置

# Get standard NTP query metrics, requires ntpq executable.
[[inputs.ntpq]]
  ## Servers to query with ntpq.
  ## If no server is given, the local machine is queried.
  # servers = []

  ## Options to pass to the ntpq command.
  # options = "-p"

  ## Output format for the 'reach' field.
  ## Available values are
  ##   octal   --  output as is in octal representation e.g. 377 (default)
  ##   decimal --  convert value to decimal representation e.g. 371 -> 249
  ##   count   --  count the number of bits in the value. This represents
  ##               the number of successful reaches, e.g. 37 -> 5
  ##   ratio   --  output the ratio of successful attempts e.g. 37 -> 5/8 = 0.625
  # reach_format = "octal"

您可以使用 options 设置传递 ntpq 命令接受的任意选项。如果您想跳过 DNS 查找,请使用

  options = "-p -n"

例如。

以下是运行 ntpq -p 时 NTP 查询命令返回的各种标头的文档。

  • remote – 正在同步的远程对等节点或服务器。“LOCAL”是此本地主机(如果没有任何远程对等节点或服务器可用,则包含在内);
  • refid – 远程对等节点或服务器本身同步到的位置或内容;
  • st (stratum) – 远程对等节点或服务器的 Stratum
  • t (type) – 类型(u:单播或多播客户端,b:广播或多播客户端,l:本地参考时钟,s:对称对等节点,A:多播服务器,B:广播服务器,M:多播服务器,参见“自动服务器发现”);
  • when – 最后一次轮询时间(几秒前,“h”几小时前,或“d”几天前);
  • poll – 轮询频率:rfc5905 建议 NTPv4 中的此值范围为 4 (16s) 到 17 (36h)(以 2 为底的对数秒),但观察表明实际显示的值是秒,范围远小于 64 (26) 到 1024 (210) 秒;
  • reach – 一个 8 位左移移位寄存器值,用于记录轮询(位设置为成功,位重置为失败),以八进制显示;
  • delay – 与远程对等节点或服务器的往返通信延迟(毫秒);
  • offset – 本地主机与远程对等节点或服务器之间报告的时间的平均偏移量(相位)(RMS,毫秒);
  • jitter – 为该远程对等节点或服务器报告的时间的平均偏差(抖动)(多个时间样本差异的 RMS,毫秒);

Metrics

  • ntpq
    • delay (float, 毫秒)
    • jitter (float, 毫秒)
    • offset (float, 毫秒)
    • poll (int, 秒)
    • reach (int)
    • when (int, 秒)

标签

所有测量值都有以下标签

  • refid
  • remote
  • type
  • stratum

如果您指定了 servers,测量值将具有额外的 source 标签。

示例输出

ntpq,refid=.GPSs.,remote=*time.apple.com,stratum=1,type=u delay=91.797,jitter=3.735,offset=12.841,poll=64i,reach=377i,when=35i 1457960478909556134

此页面是否有帮助?

感谢您的反馈!


InfluxDB 3.8 新特性

InfluxDB 3.8 和 InfluxDB 3 Explorer 1.6 的主要增强功能。

查看博客文章

InfluxDB 3.8 现已适用于 Core 和 Enterprise 版本,同时发布了 InfluxDB 3 Explorer UI 的 1.6 版本。本次发布着重于操作成熟度,以及如何更轻松地部署、管理和可靠地运行 InfluxDB。

更多信息,请查看

InfluxDB Docker 的 latest 标签将指向 InfluxDB 3 Core

在 **2026 年 2 月 3 日**,InfluxDB Docker 镜像的 latest 标签将指向 InfluxDB 3 Core。为避免意外升级,请在您的 Docker 部署中使用特定的版本标签。

如果使用 Docker 来安装和运行 InfluxDB,latest 标签将指向 InfluxDB 3 Core。为避免意外升级,请在您的 Docker 部署中使用特定的版本标签。例如,如果使用 Docker 运行 InfluxDB v2,请将 latest 版本标签替换为 Docker pull 命令中的特定版本标签 — 例如

docker pull influxdb:2