I can get local disk I/O requests and read/write bytes using the following snmp MIB:
SNMP table: UCD-DISKIO-MIB::diskIOTable
diskIOIndex diskIODevice diskIONRead diskIONWritten diskIOReads diskIOWrites diskIOLA1 diskIOLA5 diskIOLA15 diskIONReadX diskIONWrittenX
25 sda 845276160 2882477056 576632 42597061 ? ? ? 5140243456 883350772736
But I also want to get the number of read write operations and no of read write bytes performed on NFS. I can get these details from iostat and sar. But how to get the same in snmp. Is there any standard MIB? Or do I need to use custom extend scripts?
Or any other stat for NFS to figure out if most of the IO is happening at NFS, instead of local disk and so there can be a latency.
I found that the raw data for related stats can be obtained from /proc/self/mountstats:
device mynfsserver:/nfs_share mounted on /mymount with fstype nfs statvers=1.0
opts: rw,vers=3,rsize=32768,wsize=32768,namlen=255,acregmin=3,acregmax=60,acdirmin=30,acdirmax=60,hard,nolock,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=10.135.8.219,mountvers=3,mountport=635,mountproto=udp,local_lock=all
age: 7184080
caps: caps=0x3fc7,wtmult=512,dtsize=32768,bsize=0,namlen=255
sec: flavor=1,pseudoflavor=1
events: 23331256 3491358524 223430 34366227 20158408 4179180 3619183247 450869771 371431 3544366 197926586 148912797 10786030 411945 12060216 12447048 1085729 11498039 0 258831 374376252 3931 0 0 0 0 0
bytes: 3455127430558 844517501111 0 0 659354518154 767911744066 164859517 197926586
RPC iostats version: 1.0 p/v: 100003/3 (nfs)
xprt: tcp 1007 1 1 0 0 1351660808 1351660639 169 169982940422 0
per-op statistics
NULL: 0 0 0 0 0 0 0 0
GETATTR: 23331180 23331225 0 3814573636 2613094092 140133 6769125 7120537
SETATTR: 444530 444531 0 86616532 64012464 3667 1082898 1090583
LOOKUP: 4520965 4520971 0 874292460 724505228 30313 1414063 1487652
ACCESS: 4726427 4726432 0 784158880 567169024 19371 1345959 1403405
READLINK: 68743 68743 0 10762652 19401144 136 34100 34910
READ: 21839179 21839189 0 3810780152 662139940856 660836 29894300 41202619
WRITE: 38137920 38137933 0 774902293256 6102069168 3241864861 311329293 3567700419
CREATE: 965107 965109 0 216440696 274091600 10734 642120 670102
MKDIR: 120488 120488 0 24932640 33865172 628 75665 77588
SYMLINK: 272747 272747 0 115599248 77454572 612 138034 141631
MKNOD: 0 0 0 0 0 0 0 0
REMOVE: 1046577 1046577 0 205445268 150706692 5240 570230 586529
RMDIR: 97898 97898 0 17397756 14086104 281 64178 65378
RENAME: 64795 64795 0 17146680 16846700 5115 45625 51897
LINK: 1842 1842 0 427356 426576 5 1201 1227
READDIR: 0 0 0 0 0 0 0 0
READDIRPLUS: 294315 294315 0 54252732 1059559056 904 119156 122929
FSSTAT: 22346 22346 0 3648168 3754128 78 6586 6830
FSINFO: 2 2 0 280 328 0 0 0
PATHCONF: 1 1 0 140 140 0 0 0
COMMIT: 0 0 0 0 0 0 0 0
But, I am unable to decide which is the least resource consuming option: to use iostat or to use /proc/self/mountstat. Does iostat retrieves data from any cache and hence, can have faster results?
And also I can't find an explanation of the output anywhere. I just need raw counters for total operations, read-write operatoins and bytes transferred.
Having raw counters is best option for me (if it would have been added to snmp. But, now as it's not added to snmp, if I use external script to get the data, I am unable to decide to choose iostat or raw counters.)