nfs.go 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. // Copyright 2018 The Prometheus Authors
  2. // Licensed under the Apache License, Version 2.0 (the "License");
  3. // you may not use this file except in compliance with the License.
  4. // You may obtain a copy of the License at
  5. //
  6. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. // Package nfs implements parsing of /proc/net/rpc/nfsd.
  14. // Fields are documented in https://www.svennd.be/nfsd-stats-explained-procnetrpcnfsd/
  15. package nfs
  16. // ReplyCache models the "rc" line.
  17. type ReplyCache struct {
  18. Hits uint64
  19. Misses uint64
  20. NoCache uint64
  21. }
  22. // FileHandles models the "fh" line.
  23. type FileHandles struct {
  24. Stale uint64
  25. TotalLookups uint64
  26. AnonLookups uint64
  27. DirNoCache uint64
  28. NoDirNoCache uint64
  29. }
  30. // InputOutput models the "io" line.
  31. type InputOutput struct {
  32. Read uint64
  33. Write uint64
  34. }
  35. // Threads models the "th" line.
  36. type Threads struct {
  37. Threads uint64
  38. FullCnt uint64
  39. }
  40. // ReadAheadCache models the "ra" line.
  41. type ReadAheadCache struct {
  42. CacheSize uint64
  43. CacheHistogram []uint64
  44. NotFound uint64
  45. }
  46. // Network models the "net" line.
  47. type Network struct {
  48. NetCount uint64
  49. UDPCount uint64
  50. TCPCount uint64
  51. TCPConnect uint64
  52. }
  53. // ClientRPC models the nfs "rpc" line.
  54. type ClientRPC struct {
  55. RPCCount uint64
  56. Retransmissions uint64
  57. AuthRefreshes uint64
  58. }
  59. // ServerRPC models the nfsd "rpc" line.
  60. type ServerRPC struct {
  61. RPCCount uint64
  62. BadCnt uint64
  63. BadFmt uint64
  64. BadAuth uint64
  65. BadcInt uint64
  66. }
  67. // V2Stats models the "proc2" line.
  68. type V2Stats struct {
  69. Null uint64
  70. GetAttr uint64
  71. SetAttr uint64
  72. Root uint64
  73. Lookup uint64
  74. ReadLink uint64
  75. Read uint64
  76. WrCache uint64
  77. Write uint64
  78. Create uint64
  79. Remove uint64
  80. Rename uint64
  81. Link uint64
  82. SymLink uint64
  83. MkDir uint64
  84. RmDir uint64
  85. ReadDir uint64
  86. FsStat uint64
  87. }
  88. // V3Stats models the "proc3" line.
  89. type V3Stats struct {
  90. Null uint64
  91. GetAttr uint64
  92. SetAttr uint64
  93. Lookup uint64
  94. Access uint64
  95. ReadLink uint64
  96. Read uint64
  97. Write uint64
  98. Create uint64
  99. MkDir uint64
  100. SymLink uint64
  101. MkNod uint64
  102. Remove uint64
  103. RmDir uint64
  104. Rename uint64
  105. Link uint64
  106. ReadDir uint64
  107. ReadDirPlus uint64
  108. FsStat uint64
  109. FsInfo uint64
  110. PathConf uint64
  111. Commit uint64
  112. }
  113. // ClientV4Stats models the nfs "proc4" line.
  114. type ClientV4Stats struct {
  115. Null uint64
  116. Read uint64
  117. Write uint64
  118. Commit uint64
  119. Open uint64
  120. OpenConfirm uint64
  121. OpenNoattr uint64
  122. OpenDowngrade uint64
  123. Close uint64
  124. Setattr uint64
  125. FsInfo uint64
  126. Renew uint64
  127. SetClientID uint64
  128. SetClientIDConfirm uint64
  129. Lock uint64
  130. Lockt uint64
  131. Locku uint64
  132. Access uint64
  133. Getattr uint64
  134. Lookup uint64
  135. LookupRoot uint64
  136. Remove uint64
  137. Rename uint64
  138. Link uint64
  139. Symlink uint64
  140. Create uint64
  141. Pathconf uint64
  142. StatFs uint64
  143. ReadLink uint64
  144. ReadDir uint64
  145. ServerCaps uint64
  146. DelegReturn uint64
  147. GetACL uint64
  148. SetACL uint64
  149. FsLocations uint64
  150. ReleaseLockowner uint64
  151. Secinfo uint64
  152. FsidPresent uint64
  153. ExchangeID uint64
  154. CreateSession uint64
  155. DestroySession uint64
  156. Sequence uint64
  157. GetLeaseTime uint64
  158. ReclaimComplete uint64
  159. LayoutGet uint64
  160. GetDeviceInfo uint64
  161. LayoutCommit uint64
  162. LayoutReturn uint64
  163. SecinfoNoName uint64
  164. TestStateID uint64
  165. FreeStateID uint64
  166. GetDeviceList uint64
  167. BindConnToSession uint64
  168. DestroyClientID uint64
  169. Seek uint64
  170. Allocate uint64
  171. DeAllocate uint64
  172. LayoutStats uint64
  173. Clone uint64
  174. }
  175. // ServerV4Stats models the nfsd "proc4" line.
  176. type ServerV4Stats struct {
  177. Null uint64
  178. Compound uint64
  179. }
  180. // V4Ops models the "proc4ops" line: NFSv4 operations
  181. // Variable list, see:
  182. // v4.0 https://tools.ietf.org/html/rfc3010 (38 operations)
  183. // v4.1 https://tools.ietf.org/html/rfc5661 (58 operations)
  184. // v4.2 https://tools.ietf.org/html/draft-ietf-nfsv4-minorversion2-41 (71 operations)
  185. type V4Ops struct {
  186. //Values uint64 // Variable depending on v4.x sub-version. TODO: Will this always at least include the fields in this struct?
  187. Op0Unused uint64
  188. Op1Unused uint64
  189. Op2Future uint64
  190. Access uint64
  191. Close uint64
  192. Commit uint64
  193. Create uint64
  194. DelegPurge uint64
  195. DelegReturn uint64
  196. GetAttr uint64
  197. GetFH uint64
  198. Link uint64
  199. Lock uint64
  200. Lockt uint64
  201. Locku uint64
  202. Lookup uint64
  203. LookupRoot uint64
  204. Nverify uint64
  205. Open uint64
  206. OpenAttr uint64
  207. OpenConfirm uint64
  208. OpenDgrd uint64
  209. PutFH uint64
  210. PutPubFH uint64
  211. PutRootFH uint64
  212. Read uint64
  213. ReadDir uint64
  214. ReadLink uint64
  215. Remove uint64
  216. Rename uint64
  217. Renew uint64
  218. RestoreFH uint64
  219. SaveFH uint64
  220. SecInfo uint64
  221. SetAttr uint64
  222. Verify uint64
  223. Write uint64
  224. RelLockOwner uint64
  225. }
  226. // ClientRPCStats models all stats from /proc/net/rpc/nfs.
  227. type ClientRPCStats struct {
  228. Network Network
  229. ClientRPC ClientRPC
  230. V2Stats V2Stats
  231. V3Stats V3Stats
  232. ClientV4Stats ClientV4Stats
  233. }
  234. // ServerRPCStats models all stats from /proc/net/rpc/nfsd.
  235. type ServerRPCStats struct {
  236. ReplyCache ReplyCache
  237. FileHandles FileHandles
  238. InputOutput InputOutput
  239. Threads Threads
  240. ReadAheadCache ReadAheadCache
  241. Network Network
  242. ServerRPC ServerRPC
  243. V2Stats V2Stats
  244. V3Stats V3Stats
  245. ServerV4Stats ServerV4Stats
  246. V4Ops V4Ops
  247. }