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 bcache provides access to statistics exposed by the bcache (Linux 15// block cache). 16package bcache 17 18// Stats contains bcache runtime statistics, parsed from /sys/fs/bcache/. 19// 20// The names and meanings of each statistic were taken from bcache.txt and 21// files in drivers/md/bcache in the Linux kernel source. Counters are uint64 22// (in-kernel counters are mostly unsigned long). 23type Stats struct { 24 // The name of the bcache used to source these statistics. 25 Name string 26 Bcache BcacheStats 27 Bdevs []BdevStats 28 Caches []CacheStats 29} 30 31// BcacheStats contains statistics tied to a bcache ID. 32type BcacheStats struct { 33 AverageKeySize uint64 34 BtreeCacheSize uint64 35 CacheAvailablePercent uint64 36 Congested uint64 37 RootUsagePercent uint64 38 TreeDepth uint64 39 Internal InternalStats 40 FiveMin PeriodStats 41 Total PeriodStats 42} 43 44// BdevStats contains statistics for one backing device. 45type BdevStats struct { 46 Name string 47 DirtyData uint64 48 FiveMin PeriodStats 49 Total PeriodStats 50} 51 52// CacheStats contains statistics for one cache device. 53type 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. 62type PriorityStats struct { 63 UnusedPercent uint64 64 MetadataPercent uint64 65} 66 67// InternalStats contains internal bcache statistics. 68type 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). 76type 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