|
| 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 | + |
| 14 | +// Package bcachefs provides access to statistics exposed by bcachefs. |
| 15 | +package bcachefs |
| 16 | + |
| 17 | +// Stats contains bcachefs runtime statistics, parsed from /sys/fs/bcachefs/. |
| 18 | +// |
| 19 | +// The names and meanings of each statistic were taken from bcache.txt and |
| 20 | +// files in drivers/md/bcache in the Linux kernel source. Counters are uint64 |
| 21 | +// (in-kernel counters are mostly unsigned long). |
| 22 | +type Stats struct { |
| 23 | + // The name of the bcachefs used to source these statistics. |
| 24 | + Name string |
| 25 | + Bcachefs BcachefsStats |
| 26 | + Bdevs []BdevStats |
| 27 | + Caches []CacheStats |
| 28 | +} |
| 29 | + |
| 30 | +// BcachefsStats contains statistics tied to a bcache ID. |
| 31 | +type BcachefsStats struct { // nolint:revive |
| 32 | + AverageKeySize uint64 |
| 33 | + BtreeCacheSize uint64 |
| 34 | + CacheAvailablePercent uint64 |
| 35 | + Congested uint64 |
| 36 | + RootUsagePercent uint64 |
| 37 | + TreeDepth uint64 |
| 38 | + Internal InternalStats |
| 39 | + FiveMin PeriodStats |
| 40 | + Total PeriodStats |
| 41 | +} |
| 42 | + |
| 43 | +// BdevStats contains statistics for one backing device. |
| 44 | +type BdevStats struct { |
| 45 | + Name string |
| 46 | + DirtyData uint64 |
| 47 | + FiveMin PeriodStats |
| 48 | + Total PeriodStats |
| 49 | + WritebackRateDebug WritebackRateDebugStats |
| 50 | +} |
| 51 | + |
| 52 | +// CacheStats contains statistics for one cache device. |
| 53 | +type CacheStats struct { |
| 54 | + Name string |
| 55 | + IOErrors uint64 |
| 56 | + MetadataWritten uint64 |
| 57 | + Written uint64 |
| 58 | + Priority PriorityStats |
| 59 | +} |
| 60 | + |
| 61 | +// PriorityStats contains statistics from the priority_stats file. |
| 62 | +type PriorityStats struct { |
| 63 | + UnusedPercent uint64 |
| 64 | + MetadataPercent uint64 |
| 65 | +} |
| 66 | + |
| 67 | +// InternalStats contains internal bcache statistics. |
| 68 | +type InternalStats struct { |
| 69 | + ActiveJournalEntries uint64 |
| 70 | + BtreeNodes uint64 |
| 71 | + BtreeReadAverageDurationNanoSeconds uint64 |
| 72 | + CacheReadRaces uint64 |
| 73 | +} |
| 74 | + |
| 75 | +// PeriodStats contains statistics for a time period (5 min or total). |
| 76 | +type PeriodStats struct { |
| 77 | + Bypassed uint64 |
| 78 | + CacheBypassHits uint64 |
| 79 | + CacheBypassMisses uint64 |
| 80 | + CacheHits uint64 |
| 81 | + CacheMissCollisions uint64 |
| 82 | + CacheMisses uint64 |
| 83 | + CacheReadaheads uint64 |
| 84 | +} |
| 85 | + |
| 86 | +// WritebackRateDebugStats contains bcache writeback statistics. |
| 87 | +type WritebackRateDebugStats struct { |
| 88 | + Rate uint64 |
| 89 | + Dirty uint64 |
| 90 | + Target uint64 |
| 91 | + Proportional int64 |
| 92 | + Integral int64 |
| 93 | + Change int64 |
| 94 | + NextIO int64 |
| 95 | +} |
0 commit comments