文档文档

网络文件系统输入插件

此插件收集有关 网络文件系统 挂载上操作的指标。默认情况下,只收集有限数量的通用系统级指标,包括基本的读/写计数,但可以启用更详细的指标。

许多指标,即使带有挂载点标签,实际上是*每个服务器*的。例如,如果您挂载了两个共享:nfs01:/vol/foo/barnfs01:/vol/foo/baz,那么在 /proc/self/mountstats 中将有两个几乎相同的条目。这是内核公开指标的一个限制,而不是此插件的限制。

引入于: Telegraf v1.18.0 标签: network, system 操作系统支持: all

全局配置选项

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

配置

# Read per-mount NFS client metrics from /proc/self/mountstats
[[inputs.nfsclient]]
  ## Read more low-level metrics (optional, defaults to false)
  # fullstat = false

  ## List of mounts to explicitly include or exclude (optional)
  ## The pattern (Go regexp) is matched against the mount point (not the
  ## device being mounted).  If include_mounts is set, all mounts are ignored
  ## unless present in the list. If a mount is listed in both include_mounts
  ## and exclude_mounts, it is excluded.  Go regexp patterns can be used.
  # include_mounts = []
  # exclude_mounts = []

  ## List of operations to include or exclude from collecting.  This applies
  ## only when fullstat=true.  Semantics are similar to {include,exclude}_mounts:
  ## the default is to collect everything; when include_operations is set, only
  ## those OPs are collected; when exclude_operations is set, all are collected
  ## except those listed.  If include and exclude are set, the OP is excluded.
  ## See /proc/self/mountstats for a list of valid operations; note that
  ## NFSv3 and NFSv4 have different lists.  While it is not possible to
  ## have different include/exclude lists for NFSv3/4, unused elements
  ## in the list should be okay.  It is possible to have different lists
  ## for different mountpoints:  use multiple [[input.nfsclient]] stanzas,
  ## with their own lists.  See "include_mounts" above, and be careful of
  ## duplicate metrics.
  # include_operations = []
  # exclude_operations = []

配置选项

  • fullstat: 收集每种操作类型的指标。默认为 false。
  • include_mounts: 仅收集这些挂载点的指标。默认是监控所有挂载点。
  • exclude_mounts: 收集所有挂载点的指标,除了此选项中列出的。排除项优先于包含项。
  • include_operations: 要跟踪的特定 NFS 操作列表。有关 NFSv3 和 NFSV4 的有效操作的完整列表,请参阅 /proc/self/mountstats(“每操作统计信息”部分)。默认是收集所有指标,但这几乎肯定不是你想要的(NFSv3 有 22 个操作,NFSv4 有 50 多个)。建议的基本用法的‘最小’操作收集列表:['READ','WRITE','ACCESS','GETATTR','READDIR','LOOKUP','LOOKUP']
  • exclude_operations: 收集所有指标,除了列出的。排除项优先于包含项。

include_mountsexclude_mounts 参数都应用于本地挂载位置(例如 /mnt/NFS),而不是服务器导出(例如 nfsserver:/vol/NFS)。两者都可以使用 Go 正则表达式。

mountstats 的位置

如果你在容器中挂载了 /proc 文件系统,要告知此插件新位置在哪里,请设置 MOUNT_PROC 环境变量。例如,在 Docker compose 文件中,如果 /proc 被挂载到 /host/proc,则使用

MOUNT_PROC: /host/proc/self/mountstats

Metrics

字段

  • nfsstat
    • bytes (integer, bytes) - 在此操作中交换的总字节数。这是发送接收的字节数,包括开销有效负载(bytes = OP_bytes_sent + OP_bytes_recv)。请参阅下面的 nfs_ops
    • ops (integer, count) - 执行的操作数。
    • retrans (integer, count) - 操作需要重试的次数(retried retrans = OP_trans - OP_ops)。请参阅下面的 nfs_ops
    • exe (integer, milliseconds) - 处理操作花费的毫秒数。
    • rtt (integer, milliseconds) - 所有操作的总往返时间。
    • rtt_per_op (float, milliseconds) - 每个操作的平均往返时间。

此外,启用 fullstat 将提供更多指标。

标签

  • 所有测量值都有以下标签

    • mountpoint - 本地挂载点,例如:“/var/www”
    • serverexport - 完整的服务器导出,例如:“nfsserver.example.org:/export”
  • nfsstat 和 nfs_ops 测量值还将包含

    • operation - 相关的 NFS 操作。对于 nfsstat,它是 READWRITE,但可能是一个约 20 或约 50 个操作中的一个,具体取决于 NFS 版本。支持的操作的完整列表可在 /proc/self/mountstats 中查看。

附加指标

fullstat 为 true 时,会收集附加测量值。标签与上述相同。

NFS 操作

大多数描述来自 参考nfs_iostat.h。字段顺序和名称与 /proc/self/mountstats 和内核源代码中的相同。

请参阅 /proc/self/mountstats 以获取支持的 NFS 操作列表,因为它们会偶尔更改。

  • nfs_bytes

    • 字段 (fields)
      • normalreadbytes (int, bytes): 通过 read() 从服务器读取的字节数
      • normalwritebytes (int, bytes): 通过 write() 写入服务器的字节数
      • directreadbytes (int, bytes): 使用 O_DIRECT 设置读取的字节数
      • directwritebytes (int, bytes): 使用 O_DIRECT 设置写入的字节数
      • serverreadbytes (int, bytes): 通过 NFS READ 读取的字节数(通过 mmap()
      • serverwritebytes (int, bytes): 通过 NFS WRITE 写入的字节数(通过 mmap()
      • readpages (int, count): 读取的页数
      • writepages (int, count): 写入的页数
  • nfs_events (每事件指标)

    • 字段 (fields)
      • inoderevalidates (int, count): 需要从服务器重新验证缓存的 inode 属性的次数。
      • dentryrevalidates (int, count): 需要重新验证缓存的 dentry 节点的次数。
      • datainvalidates (int, count): 缓存的数据被丢弃的 inode 的次数。
      • attrinvalidates (int, count): 缓存的 inode 属性被失效的 inode 的次数。
      • vfsopen (int, count): open() 文件的次数。
      • vfslookup (int, count): 目录中进行的名称查找次数。
      • vfsaccess (int, count): 调用 access() 的次数。(以前称为“vfspermission”)
      • vfsupdatepage (int, count): 页更新(可能写入)的计数。
      • vfsreadpage (int, count): 读取的页数。
      • vfsreadpages (int, count): 读取一组页面的次数(可能通过 mmap()?)。
      • vfswritepage (int, count): 写入的页数。
      • vfswritepages (int, count): 写入一组页面的次数(可能通过 mmap()?)。
      • vfsgetdents (int, count): 通过 getdents() 读取目录条目的次数。这些读取可以从缓存中提供,不一定表示实际的 NFS 请求。(以前称为“vfsreaddir”)
      • vfssetattr (int, count): 设置 inode 属性的次数。
      • vfsflush (int, count): 强制将待处理写入刷新到服务器的次数。
      • vfsfsync (int, count): 对目录和文件调用 fsync() 的次数。
      • vfslock (int, count): 尝试锁定文件的次数(无论是否成功)。
      • vfsrelease (int, count): 调用 close() 的次数。
      • congestionwait (int, count): Linux 内核似乎未使用,但它是 NFS 规范的一部分。
      • setattrtrunc (int, count): 文件大小被截断的次数。
      • extendwrite (int, count): 由于写入操作超出了文件现有末尾而导致文件增长的次数。
      • sillyrenames (int, count): 在使用中的文件被删除的次数(从而创建了一个临时“.nfsXXXXXX”文件)。
      • shortreads (int, count): NFS 服务器返回的数据少于请求的次数。
      • shortwrites (int, count): NFS 服务器报告写入的数据少于请求的次数。
      • delay (int, count): EJUKEBOX (“Jukebox Delay”, 可能未使用) 的发生次数。
      • pnfsreads (int, count): NFS v4.1+ pNFS 读取的计数。
      • pnfswrites (int, count): NFS v4.1+ pNFS 写入的计数。
  • nfs_xprt_tcp

    • 字段 (fields)
      • bind_count (int, count): 到此服务器的全新挂载次数(有时为 0?)
      • connect_count (int, count): 客户端连接到所讨论服务器的次数
      • connect_time (int, jiffies): NFS 客户端等待与其服务器的连接建立所花费的时间。
      • idle_time (int, seconds): NFS 挂载点自上次有 RPC 流量以来的时间(秒)。
      • rpcsends (int, count): 此挂载点发送到服务器的 RPC 请求数。
      • rpcreceives (int, count): 此挂载点从服务器收到的 RPC 回复数。
      • badxids (int, count): 服务器发送的客户端不知道的 XID 计数。
      • inflightsends (int, count): 未完成的请求数;总是 >1。(请参阅参考 #4 关于此字段的注释)
      • backlogutil (int, count): 累积积压计数
  • nfs_xprt_udp

    • 字段 (fields)
      • [与 nfs_xprt_tcp 相同,但 connect_count、connect_time 和 idle_time 除外]
  • nfs_ops

    • 字段的 operations 标签始终设置为 NFS 操作的大写名称,例如 “READ”、“FSINFO” 等。请参阅 /proc/self/mountstats 以获取完整列表。
      • ops (int, count): 此类型的总操作数。
      • trans (int, count): 此类型的总传输次数,包括重传(次数越少越好):OP_ops - OP_trans = total_retransmissions
      • timeouts (int, count): 主要超时次数。
      • bytes_sent (int, count): 发送的字节数,包括标头(也应接近实际在线大小)。
      • bytes_recv (int, count): 接收的字节数,包括标头(也应接近实际在线大小)。
      • queue_time (int, milliseconds): 请求在发送此 OP 类型之前在队列中等待的累积时间。
      • response_time (int, milliseconds): 等待此 OP 类型响应的累积时间。
      • total_time (int, milliseconds): 请求在发送之前在队列中等待的累积时间。
      • errors (int, count): 完成时 tk_status < 0 的操作总数(通常是错误)。这是一个新字段,存在于内核 >=5.3,mountstats 版本 1.1 中。

示例输出

基本指标显示按服务器的读取和写入数据。

nfsstat,mountpoint=/NFS,operation=READ,serverexport=1.2.3.4:/storage/NFS ops=600i,retrans=1i,bytes=1207i,rtt=606i,exe=607i 1612651512000000000
nfsstat,mountpoint=/NFS,operation=WRITE,serverexport=1.2.3.4:/storage/NFS bytes=1407i,rtt=706i,exe=707i,ops=700i,retrans=1i 1612651512000000000

对于 fullstat=true 指标,包括 nfs_bytesnfs_eventsnfs_xprt_tcp(如果存在,则为 nfs_xprt_udp)的附加测量值。此外,还会收集每操作指标,并显示 READ、LOOKUP 和 NULL 的示例。请参阅 /proc/self/mountstats 以获取支持的 NFS 操作列表,因为此列表会定期更改。

nfs_bytes,mountpoint=/home,serverexport=nfs01:/vol/home directreadbytes=0i,directwritebytes=0i,normalreadbytes=42648757667i,normalwritebytes=0i,readpages=10404603i,serverreadbytes=42617098139i,serverwritebytes=0i,writepages=0i 1608787697000000000
nfs_events,mountpoint=/home,serverexport=nfs01:/vol/home attrinvalidates=116i,congestionwait=0i,datainvalidates=65i,delay=0i,dentryrevalidates=5911243i,extendwrite=0i,inoderevalidates=200378i,pnfsreads=0i,pnfswrites=0i,setattrtrunc=0i,shortreads=0i,shortwrites=0i,sillyrenames=0i,vfsaccess=7203852i,vfsflush=117405i,vfsfsync=0i,vfsgetdents=3368i,vfslock=0i,vfslookup=740i,vfsopen=157281i,vfsreadpage=16i,vfsreadpages=86874i,vfsrelease=155526i,vfssetattr=0i,vfsupdatepage=0i,vfswritepage=0i,vfswritepages=215514i 1608787697000000000
nfs_xprt_tcp,mountpoint=/home,serverexport=nfs01:/vol/home backlogutil=0i,badxids=0i,bind_count=1i,connect_count=1i,connect_time=0i,idle_time=0i,inflightsends=15659826i,rpcreceives=2173896i,rpcsends=2173896i 1608787697000000000

nfs_ops,mountpoint=/NFS,operation=NULL,serverexport=1.2.3.4:/storage/NFS trans=0i,timeouts=0i,bytes_sent=0i,bytes_recv=0i,queue_time=0i,response_time=0i,total_time=0i,ops=0i 1612651512000000000
nfs_ops,mountpoint=/NFS,operation=READ,serverexport=1.2.3.4:/storage/NFS bytes=1207i,timeouts=602i,total_time=607i,exe=607i,trans=601i,bytes_sent=603i,bytes_recv=604i,queue_time=605i,ops=600i,retrans=1i,rtt=606i,response_time=606i 1612651512000000000
nfs_ops,mountpoint=/NFS,operation=WRITE,serverexport=1.2.3.4:/storage/NFS ops=700i,bytes=1407i,exe=707i,trans=701i,timeouts=702i,response_time=706i,total_time=707i,retrans=1i,rtt=706i,bytes_sent=703i,bytes_recv=704i,queue_time=705i 1612651512000000000

此页面是否有帮助?

感谢您的反馈!


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