xfs.go 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. // Copyright 2017 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 xfs provides access to statistics exposed by the XFS filesystem.
  14. package xfs
  15. // Stats contains XFS filesystem runtime statistics, parsed from
  16. // /proc/fs/xfs/stat.
  17. //
  18. // The names and meanings of each statistic were taken from
  19. // http://xfs.org/index.php/Runtime_Stats and xfs_stats.h in the Linux
  20. // kernel source. Most counters are uint32s (same data types used in
  21. // xfs_stats.h), but some of the "extended precision stats" are uint64s.
  22. type Stats struct {
  23. // The name of the filesystem used to source these statistics.
  24. // If empty, this indicates aggregated statistics for all XFS
  25. // filesystems on the host.
  26. Name string
  27. ExtentAllocation ExtentAllocationStats
  28. AllocationBTree BTreeStats
  29. BlockMapping BlockMappingStats
  30. BlockMapBTree BTreeStats
  31. DirectoryOperation DirectoryOperationStats
  32. Transaction TransactionStats
  33. InodeOperation InodeOperationStats
  34. LogOperation LogOperationStats
  35. ReadWrite ReadWriteStats
  36. AttributeOperation AttributeOperationStats
  37. InodeClustering InodeClusteringStats
  38. Vnode VnodeStats
  39. Buffer BufferStats
  40. ExtendedPrecision ExtendedPrecisionStats
  41. }
  42. // ExtentAllocationStats contains statistics regarding XFS extent allocations.
  43. type ExtentAllocationStats struct {
  44. ExtentsAllocated uint32
  45. BlocksAllocated uint32
  46. ExtentsFreed uint32
  47. BlocksFreed uint32
  48. }
  49. // BTreeStats contains statistics regarding an XFS internal B-tree.
  50. type BTreeStats struct {
  51. Lookups uint32
  52. Compares uint32
  53. RecordsInserted uint32
  54. RecordsDeleted uint32
  55. }
  56. // BlockMappingStats contains statistics regarding XFS block maps.
  57. type BlockMappingStats struct {
  58. Reads uint32
  59. Writes uint32
  60. Unmaps uint32
  61. ExtentListInsertions uint32
  62. ExtentListDeletions uint32
  63. ExtentListLookups uint32
  64. ExtentListCompares uint32
  65. }
  66. // DirectoryOperationStats contains statistics regarding XFS directory entries.
  67. type DirectoryOperationStats struct {
  68. Lookups uint32
  69. Creates uint32
  70. Removes uint32
  71. Getdents uint32
  72. }
  73. // TransactionStats contains statistics regarding XFS metadata transactions.
  74. type TransactionStats struct {
  75. Sync uint32
  76. Async uint32
  77. Empty uint32
  78. }
  79. // InodeOperationStats contains statistics regarding XFS inode operations.
  80. type InodeOperationStats struct {
  81. Attempts uint32
  82. Found uint32
  83. Recycle uint32
  84. Missed uint32
  85. Duplicate uint32
  86. Reclaims uint32
  87. AttributeChange uint32
  88. }
  89. // LogOperationStats contains statistics regarding the XFS log buffer.
  90. type LogOperationStats struct {
  91. Writes uint32
  92. Blocks uint32
  93. NoInternalBuffers uint32
  94. Force uint32
  95. ForceSleep uint32
  96. }
  97. // ReadWriteStats contains statistics regarding the number of read and write
  98. // system calls for XFS filesystems.
  99. type ReadWriteStats struct {
  100. Read uint32
  101. Write uint32
  102. }
  103. // AttributeOperationStats contains statistics regarding manipulation of
  104. // XFS extended file attributes.
  105. type AttributeOperationStats struct {
  106. Get uint32
  107. Set uint32
  108. Remove uint32
  109. List uint32
  110. }
  111. // InodeClusteringStats contains statistics regarding XFS inode clustering
  112. // operations.
  113. type InodeClusteringStats struct {
  114. Iflush uint32
  115. Flush uint32
  116. FlushInode uint32
  117. }
  118. // VnodeStats contains statistics regarding XFS vnode operations.
  119. type VnodeStats struct {
  120. Active uint32
  121. Allocate uint32
  122. Get uint32
  123. Hold uint32
  124. Release uint32
  125. Reclaim uint32
  126. Remove uint32
  127. Free uint32
  128. }
  129. // BufferStats contains statistics regarding XFS read/write I/O buffers.
  130. type BufferStats struct {
  131. Get uint32
  132. Create uint32
  133. GetLocked uint32
  134. GetLockedWaited uint32
  135. BusyLocked uint32
  136. MissLocked uint32
  137. PageRetries uint32
  138. PageFound uint32
  139. GetRead uint32
  140. }
  141. // ExtendedPrecisionStats contains high precision counters used to track the
  142. // total number of bytes read, written, or flushed, during XFS operations.
  143. type ExtendedPrecisionStats struct {
  144. FlushBytes uint64
  145. WriteBytes uint64
  146. ReadBytes uint64
  147. }