从/proc/[id]/mountstats或/proc/self/mountstats解释数据

7
我希望监控我的NFS共享的IO。有很多程序可以解释/proc/[id]/mountstats([id] = nfs客户端/服务器的ID)或/proc/self/mountstats中的数据。问题是,这些程序计算每秒钟的一些IO。这在命令行中非常好,但对于我的监视解决方案来说相当无用。因此,我想自己解释mountstats的计数器。现在我的问题是,我需要一些关于nfs v4的mountstats文档。
到目前为止,我的搜索没有找到任何有用信息。
Ubuntu上/proc/self/mountstats的示例输出(nfs客户端):
...
device IPADRESS:/mountpoint mounted on /mnt/mountpoint with fstype nfs4 statvers=1.0
    opts:   rw,vers=4,rsize=1048576,wsize=1048576,acregmin=3,acregmax=60,acdirmin=30,acdirmax=60,hard,nointr,proto=tcp,timeo=600,retrans=2,sec=sys
    age:    77663
    caps:   caps=0x1e,wtmult=512,dtsize=4096,bsize=0,namelen=255
    nfsv4:  bm0=0xfdffbfff,bm1=0xf9be3e,acl=0x3
    sec:    flavor=1,pseudoflavor=1
    events: 1462723 25756220 1025148 1164028 1083099 2027020 31347107 1984730 279773 1915700 1346583 21077199 520498 31825 525298 39026 2180470 1083041 0 16822 990144 11011 0 0 0
    bytes:  46686144592 3990939437 0 0 30238687174 3759616491 7739053 1346583
    RPC iostats version: 1.0  p/v: 100003/4 (nfs)
    xprt:   tcp 852 1 2 0 0 11822378 11822377 0 17669710 13357205
    per-op statistics
            NULL: 0 0 0 0 0 0 0 0
            READ: 1950114 1950114 0 330348288 30355844804 105050 6678050 6907640
           WRITE: 911822 911822 0 3932410080 215189360 10653830 1472320 12211620
          COMMIT: 389509 389509 0 65718096 88808052 8060 253550 284360
            OPEN: 1168845 1168845 0 292577612 554554444 430040 628900 1229990
    OPEN_CONFIRM: 43 43 0 7048 2924 0 10 10
     OPEN_NOATTR: 0 0 0 0 0 0 0 0
    OPEN_DOWNGRADE: 54 54 0 9952 12744 90 0 120
           CLOSE: 1081161 1081161 0 191495392 255153996 201030 404620 767870
         SETATTR: 43303 43303 0 8753024 10046296 1060 25650 30380
          FSINFO: 2 2 0 268 184 0 0 0
           RENEW: 0 0 0 0 0 0 0 0
     SETCLIENTID: 0 0 0 0 0 0 0 0
    SETCLIENTID_CONFIRM: 0 0 0 0 0 0 0 0
            LOCK: 1140050 1140050 0 246277244 77523400 76270 326950 469890
           LOCKT: 1 1 0 188 52 0 0 0
           LOCKU: 1037895 1037895 0 187916912 70576860 18130 357530 441480
          ACCESS: 450451 450451 0 72511716 102702828 21440 222460 280950
         GETATTR: 1462724 1462724 0 224029496 310097488 21290 390910 485350
          LOOKUP: 2043380 2043380 0 361899452 532433688 18200 499200 585170
     LOOKUP_ROOT: 1 1 0 116 232 0 0 0
          REMOVE: 32356 32356 0 5953448 7765440 600 15450 18560
          RENAME: 20388 20388 0 5593088 9215376 510 7740 9750
            LINK: 537 537 0 132024 231984 0 220 270
         SYMLINK: 0 0 0 0 0 0 0 0
          CREATE: 999 999 0 227376 293140 30 650 830
        PATHCONF: 1 1 0 140 72 0 0 0
          STATFS: 2872 2872 0 419360 333152 580 3980 4880
        READLINK: 0 0 0 0 0 0 0 0
         READDIR: 82718 82718 0 14625720 118955760 770 48470 53310
     SERVER_CAPS: 3 3 0 400 264 0 0 0
     DELEGRETURN: 0 0 0 0 0 0 0 0
          GETACL: 0 0 0 0 0 0 0 0
          SETACL: 0 0 0 0 0 0 0 0
    FS_LOCATIONS: 0 0 0 0 0 0 0 0
 ...

我有同样的问题:http://serverfault.com/questions/810729/what-is-snmp-mib-for-getting-nfs-io-counters。你找到解决方法了吗? - GP92
1
@JeevanPatnaik 你看过 https://utcc.utoronto.ca/~cks/space/blog/linux/NFSMountstatsIndex 吗? - Peter Brittain
谢谢,这个有效。请把它作为答案! - GP92
还有这个带有很多信息的链接:http://www.fsl.cs.stonybrook.edu/~mchen/mountstat-format.txt - GP92
3个回答

7
完整的源代码: http://www.fsl.cs.stonybrook.edu/~mchen/mountstat-format.txt
       Format of NFS mountstat

Linux内核版本:2.6.32-358.el6.x86_64

统计数据的重要文件:

- linux/fs/nfs/super.c: nfs_show_stats
- linux/include/linux/nfs_iostat.h: nfs_stat_eventcounters
- linux/net/sunrpc/stats.c: rpc_print_iostats
- linux/net/sunrpc/xprtsock.c: xs_tcp_print_stats

服务器能力 (caps)

  1. caps: 服务器能力
  2. wtmult: 服务器磁盘块大小
  3. dtsize: readdir 大小
  4. bsize: 服务器块大小
  5. namlen:

nfsv4 (nfs_show_stats)

  1. bm0: 属性位掩码[0],支持哪些属性
  2. bm1: 属性位掩码[1],支持哪些属性
  3. acl: acl 位掩码,支持哪些 acl 属性

sec, 此挂载的安全性 (nfs_show_stats)

  1. flavor: auth->au_ops->au_flavor
  2. pseudoflavor: auth->au_flavor

事件 (linux/nfs_iostat.h: nfs_stat_eventcounters)

  1. inoderevalidate(节点重新验证)
  2. dentryrevalidate(目录项重新验证)
  3. datainvalidate(数据无效)
  4. attrinvalidate(属性无效)
  5. vfsopen(VFS打开)
  6. vfslookup(VFS查找)
  7. vfsaccess(VFS访问)
  8. vfsupdatepage(VFS更新页)
  9. vfsreadpage(VFS读取页)
  10. vfsreadpages(VFS读取多页)
  11. vfswritepage(VFS写入页)
  12. vfswritepages(VFS写入多页)
  13. vfsgetdents(VFS获取目录项)
  14. vfssetattr(VFS设置属性)
  15. vfsflush(VFS刷新)
  16. vfsfsync(VFS同步)
  17. vfslock(VFS锁定)
  18. vfsrelease(VFS释放)
  19. congestionwait(拥塞等待)
  20. setattrtrunc(设置属性截断)
  21. extendwrite(扩展写入)
  22. sillyrename(愚蠢重命名)
  23. shortread(短读取)
  24. shortwrite(短写入)
  25. delay(延迟)
  26. pnfs_read(PNFS读取)
  27. pnfs_write(PNFS写入)

字节(linux/nfs_iostat.h: nfs_stat_bytecounters)

  1. normalreadbytes(普通读取字节数)
  2. normalwritebytes(普通写入字节数)
  3. directreadbytes(直接读取字节数)
  4. directwritebytes(直接写入字节数)
  5. serverreadbytes(服务器读取字节数)
  6. serverwritebytes(服务器写入字节数)
  7. readpages(读取页数)
  8. writepages(写入页数)

xprt (tcp)

  • linux/net/sunrpc/xprtsock.c:xs_tcp_print_stats
  • linux/include/linux/sunrpc/xprt.h:struct rpc_xprt
  1. srcport: 短暂端口
  2. bind_count: rpcbind 操作的次数
  3. connect_count: TCP 连接的次数
  4. connect_time: 连接所花费的时间
  5. idle_time: 传输空闲时间长度
  6. rpcsends: 套接字发送的次数
  7. rpcrecvs: 套接字接收的次数
  8. badxids: 收到的不可匹配 XIDs 的数量
  9. req_u: 在线请求的平均数(插槽表利用率)
  10. bklog_u: 备用队列的利用率(备用队列的平均长度)
  11. max_slots: 最大 rpc 插槽数量
  12. sending_u: 发送队列的利用率
  13. pending_u: 挂起队列的利用率

每个 RPC 操作类型都显示 (rpc_print_iostats)

统计记录: rpc_exit_task ---> xprt_release ---> rpc_count_iostats

所有 NFS 协议在这里解释: http://www.freesoft.org/CIE/Topics/115.htm

  1. 操作类型的名称
  2. ops:请求了多少个此类型的操作
  3. trans:发送了多少次此类型的操作
  4. timeouts:此类型的操作发生了多少次超时
  5. bytes_sent:针对此类型的操作已发送多少字节
  6. bytes_recv:针对此类型的操作已接收多少字节
  7. queue:在传输之前,此类型的操作在队列中等待了多长时间(毫秒)
  8. rtt:客户端等待从服务器收到此类型操作的回复所需的时间(毫秒)
  9. execute:此类型的操作需要执行的时间(从rpc_init_task到rpc_exit_task)(毫秒)

rpc_run_task ---> rpc_new_task ---> rpc_init_task

最后三个时间统计使用ns进行收集,但在打印输出时将其转换为ms。

执行时间应该接近于(queue + rtt)。

请注意,在Linux源代码中,字段的名称以“om_”为前缀,例如第一个字段为“om_ops”,而不是“ops”。

NFSv4.0示例

device 130.245.177.235:/nfsdata/ mounted on /mnt with fstype nfs4 statvers=1.1
    opts:    rw,vers=4,rsize=1048576,wsize=1048576,namlen=255,acregmin=3,acregmax=60,
            acdirmin=30,acdirmax=60,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,
            clientaddr=130.245.177.234,minorversion=0,local_lock=none
    age:    19  (time, in seconds, since the NFS is mounted)
    caps:    caps=0xfff7,wtmult=512,dtsize=32768,bsize=0,namlen=255
    nfsv4:    bm0=0xfdffafff,bm1=0xf9be3e,acl=0x0
    sec:    flavor=1,pseudoflavor=1
    events:    0 168232 0 0 0 10095 217808 0 2 9797 0 9739 0 0 19739 19739 0 19739 0 0 0 0 0 0 0 0 0
    bytes:    1612840960 0 0 0 627536112 0 158076 0
    RPC iostats version: 1.0  p/v: 100003/4 (nfs)
    xprt:    tcp 737 0 1 0 0 69698 69697 0 81817 0 2 1082 12119
    per-op statistics
            NULL: 0 0 0 0 0 0 0 0
            READ: 9797 9797 0 1567520 628138612 71 7953 8200
           WRITE: 0 0 0 0 0 0 0 0
          COMMIT: 0 0 0 0 0 0 0 0
            OPEN: 19740 19740 0 4737600 7343280 505 3449 4172
    OPEN_CONFIRM: 10211 10211 0 1552072 694348 74 836 1008
     OPEN_NOATTR: 0 0 0 0 0 0 0 0
    OPEN_DOWNGRADE: 0 0 0 0 0 0 0 0
           CLOSE: 19739 19739 0 3316152 2605548 334 3045 3620
         SETATTR: 0 0 0 0 0 0 0 0
          FSINFO: 1 1 0 132 108 0 0 0
           RENEW: 0 0 0 0 0 0 0 0
     SETCLIENTID: 0 0 0 0 0 0 0 0
    SETCLIENTID_CONFIRM: 0 0 0 0 0 0 0 0
            LOCK: 0 0 0 0 0 0 0 0
           LOCKT: 0 0 0 0 0 0 0 0
           LOCKU: 0 0 0 0 0 0 0 0
          ACCESS: 96 96 0 14584 19584 0 8 10
         GETATTR: 1 1 0 132 188 0 0 0
          LOOKUP: 10095 10095 0 1655576 2382420 36 898 1072
     LOOKUP_ROOT: 0 0 0 0 0 0 0 0
          REMOVE: 0 0 0 0 0 0 0 0
          RENAME: 0 0 0 0 0 0 0 0
            LINK: 0 0 0 0 0 0 0 0
         SYMLINK: 0 0 0 0 0 0 0 0
          CREATE: 0 0 0 0 0 0 0 0
        PATHCONF: 1 1 0 128 72 0 0 0
          STATFS: 0 0 0 0 0 0 0 0
        READLINK: 0 0 0 0 0 0 0 0
         READDIR: 0 0 0 0 0 0 0 0
     SERVER_CAPS: 2 2 0 256 176 0 0 0
     DELEGRETURN: 0 0 0 0 0 0 0 0
          GETACL: 0 0 0 0 0 0 0 0
          SETACL: 0 0 0 0 0 0 0 0
    FS_LOCATIONS: 0 0 0 0 0 0 0 0
    RELEASE_LOCKOWNER: 0 0 0 0 0 0 0 0
         SECINFO: 0 0 0 0 0 0 0 0
     EXCHANGE_ID: 0 0 0 0 0 0 0 0
    CREATE_SESSION: 0 0 0 0 0 0 0 0
    DESTROY_SESSION: 0 0 0 0 0 0 0 0
        SEQUENCE: 0 0 0 0 0 0 0 0
    GET_LEASE_TIME: 0 0 0 0 0 0 0 0
    RECLAIM_COMPLETE: 0 0 0 0 0 0 0 0
       LAYOUTGET: 0 0 0 0 0 0 0 0
    GETDEVICEINFO: 0 0 0 0 0 0 0 0
    LAYOUTCOMMIT: 0 0 0 0 0 0 0 0
    LAYOUTRETURN: 0 0 0 0 0 0 0 0


NFSv4.1 EXAMPLE
===============
device 130.245.177.235:/nfsdata mounted on /mnt with fstype nfs4 statvers=1.1
    opts:   rw,vers=4.1,rsize=1048576,wsize=1048576,namlen=255,acregmin=3,acregmax=60,acdirmin=30,acdirmax=60,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=130.245.177.234,local_lock=none
    age:    44
    impl_id:    name='',domain='',date='0,0'
    caps:   caps=0x3ffff,wtmult=512,dtsize=32768,bsize=0,namlen=255
    nfsv4:  bm0=0xfdffbfff,bm1=0xf9be3e,bm2=0x800,acl=0x3,sessions,pnfs=not configured
    sec:    flavor=1,pseudoflavor=1
    events: 67379 1692812 0 30749 0 980 1984612 0 0 0 0 0 0 0 96611 96611 0 96611 0 0 0 0 0 0 0 0 0 
    bytes:  0 0 0 0 0 0 0 0 
    RPC iostats version: 1.0  p/v: 100003/4 (nfs)
    xprt:   tcp 674 0 1 0 0 279772 279771 0 649944 0 5 1711 90409
    per-op statistics
            NULL: 0 0 0 0 0 0 0 0
            READ: 0 0 0 0 0 0 0 0
           WRITE: 0 0 0 0 0 0 0 0
          COMMIT: 0 0 0 0 0 0 0 0
            OPEN: 96612 96612 0 27824256 34007424 13349 16253 32061
    OPEN_CONFIRM: 0 0 0 0 0 0 0 0
     OPEN_NOATTR: 0 0 0 0 0 0 0 0
    OPEN_DOWNGRADE: 0 0 0 0 0 0 0 0
           CLOSE: 96610 96610 0 19708440 17003360 2936 11082 15386
         SETATTR: 0 0 0 0 0 0 0 0
          FSINFO: 1 1 0 168 152 0 0 0
           RENEW: 0 0 0 0 0 0 0 0
     SETCLIENTID: 0 0 0 0 0 0 0 0
    SETCLIENTID_CONFIRM: 0 0 0 0 0 0 0 0
            LOCK: 0 0 0 0 0 0 0 0
           LOCKT: 0 0 0 0 0 0 0 0
           LOCKU: 0 0 0 0 0 0 0 0
          ACCESS: 16932 16932 0 3183200 2844576 83 1919 2308
         GETATTR: 67380 67380 0 12128380 15632160 336 8367 10644
          LOOKUP: 1236 1236 0 247176 167784 7 153 197
     LOOKUP_ROOT: 0 0 0 0 0 0 0 0
          REMOVE: 0 0 0 0 0 0 0 0
          RENAME: 0 0 0 0 0 0 0 0
            LINK: 0 0 0 0 0 0 0 0
         SYMLINK: 0 0 0 0 0 0 0 0
          CREATE: 980 980 0 219516 305760 5 168 197
        PATHCONF: 1 1 0 164 116 0 0 0
          STATFS: 0 0 0 0 0 0 0 0
        READLINK: 0 0 0 0 0 0 0 0
         READDIR: 0 0 0 0 0 0 0 0
     SERVER_CAPS: 2 2 0 328 280 0 0 0
     DELEGRETURN: 0 0 0 0 0 0 0 0
          GETACL: 0 0 0 0 0 0 0 0
          SETACL: 0 0 0 0 0 0 0 0
    FS_LOCATIONS: 0 0 0 0 0 0 0 0
    RELEASE_LOCKOWNER: 0 0 0 0 0 0 0 0
         SECINFO: 0 0 0 0 0 0 0 0
     EXCHANGE_ID: 0 0 0 0 0 0 0 0
    CREATE_SESSION: 0 0 0 0 0 0 0 0
    DESTROY_SESSION: 0 0 0 0 0 0 0 0
        SEQUENCE: 0 0 0 0 0 0 0 0
    GET_LEASE_TIME: 0 0 0 0 0 0 0 0
    RECLAIM_COMPLETE: 0 0 0 0 0 0 0 0
       LAYOUTGET: 0 0 0 0 0 0 0 0
    GETDEVICEINFO: 0 0 0 0 0 0 0 0
    LAYOUTCOMMIT: 0 0 0 0 0 0 0 0
    LAYOUTRETURN: 0 0 0 0 0 0 0 0
    SECINFO_NO_NAME: 0 0 0 0 0 0 0 0
    TEST_STATEID: 0 0 0 0 0 0 0 0
    FREE_STATEID: 0 0 0 0 0 0 0 0
    GETDEVICELIST: 0 0 0 0 0 0 0 0
    BIND_CONN_TO_SESSION: 0 0 0 0 0 0 0 0
    DESTROY_CLIENTID: 0 0 0 0 0 0 0 0


# vim: tabstop=2:shiftwidth=2:expandtab:foldmethod=indent

此外,还有https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/linux/nfs_iostat.hhttps://utcc.utoronto.ca/~cks/space/blog/linux/NFSMountstatsIndex可供参考阅读。

1

0
你是在哪个Linux上进行编程的?因为对我来说,在Redhat上,v4的mountstats类似于这样:
[root@riau petri]# cat /proc/1511/mountstats 
device rootfs mounted on / with fstype rootfs
device /proc mounted on /proc with fstype proc
device /sys mounted on /sys with fstype sysfs
device udev mounted on /dev with fstype devtmpfs
device devpts mounted on /dev/pts with fstype devpts
device tmpfs mounted on /dev/shm with fstype tmpfs
device /dev/mapper/vg_riau-lv_root mounted on / with fstype ext4
device /proc/bus/usb mounted on /proc/bus/usb with fstype usbfs
device /dev/sda1 mounted on /boot with fstype ext4
device /dev/mapper/vg_riau-lv_home mounted on /home with fstype ext4
device none mounted on /proc/sys/fs/binfmt_misc with fstype binfmt_misc
device cgroup mounted on /cgroup/cpuset with fstype cgroup
device cgroup mounted on /cgroup/cpu with fstype cgroup
device cgroup mounted on /cgroup/cpuacct with fstype cgroup
device cgroup mounted on /cgroup/memory with fstype cgroup
device cgroup mounted on /cgroup/devices with fstype cgroup
device cgroup mounted on /cgroup/freezer with fstype cgroup
device cgroup mounted on /cgroup/net_cls with fstype cgroup
device cgroup mounted on /cgroup/blkio with fstype cgroup
device sunrpc mounted on /var/lib/nfs/rpc_pipefs with fstype rpc_pipefs
device /etc/auto.misc mounted on /misc with fstype autofs
device -hosts mounted on /net with fstype autofs
device nfsd mounted on /proc/fs/nfsd with fstype nfsd

我正在Ubuntu上进行操作,用于NFS挂载点的设备IP地址:/store已挂载到/mnt/store,并使用fstype nfs4 statvers=1.0。 选项:rw,vers=4,rsize=1048576,wsize=1048576,acregmin=3,acregmax=60,acdirmin=30,acdirmax=60,hard,nointr,proto=tcp,timeo=600,retrans=2,sec=sys。 年龄:75405。 - tiflor
@tiflor 哦,那很有用,你可以考虑将它作为一个例子添加到你的问题中 - 那会非常有帮助。 - Petriborg

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接