GetStats collects from sysfs files data tied to one bcache ID.
(uuidPath string, priorityStats bool)
| 374 | |
| 375 | // GetStats collects from sysfs files data tied to one bcache ID. |
| 376 | func GetStats(uuidPath string, priorityStats bool) (*Stats, error) { |
| 377 | var bs Stats |
| 378 | |
| 379 | par := parser{uuidPath: uuidPath} |
| 380 | |
| 381 | // bcache stats |
| 382 | |
| 383 | // dir <uuidPath> |
| 384 | par.setSubDir("") |
| 385 | bs.Bcache.AverageKeySize = par.readValue("average_key_size") |
| 386 | bs.Bcache.BtreeCacheSize = par.readValue("btree_cache_size") |
| 387 | bs.Bcache.CacheAvailablePercent = par.readValue("cache_available_percent") |
| 388 | bs.Bcache.Congested = par.readValue("congested") |
| 389 | bs.Bcache.RootUsagePercent = par.readValue("root_usage_percent") |
| 390 | bs.Bcache.TreeDepth = par.readValue("tree_depth") |
| 391 | |
| 392 | // bcache stats (internal) |
| 393 | |
| 394 | // dir <uuidPath>/internal |
| 395 | par.setSubDir("internal") |
| 396 | bs.Bcache.Internal.ActiveJournalEntries = par.readValue("active_journal_entries") |
| 397 | bs.Bcache.Internal.BtreeNodes = par.readValue("btree_nodes") |
| 398 | bs.Bcache.Internal.BtreeReadAverageDurationNanoSeconds = par.readValue("btree_read_average_duration_us") |
| 399 | bs.Bcache.Internal.CacheReadRaces = par.readValue("cache_read_races") |
| 400 | |
| 401 | // bcache stats (period) |
| 402 | |
| 403 | // dir <uuidPath>/stats_five_minute |
| 404 | par.setSubDir("stats_five_minute") |
| 405 | bs.Bcache.FiveMin.Bypassed = par.readValue("bypassed") |
| 406 | bs.Bcache.FiveMin.CacheHits = par.readValue("cache_hits") |
| 407 | |
| 408 | bs.Bcache.FiveMin.Bypassed = par.readValue("bypassed") |
| 409 | bs.Bcache.FiveMin.CacheBypassHits = par.readValue("cache_bypass_hits") |
| 410 | bs.Bcache.FiveMin.CacheBypassMisses = par.readValue("cache_bypass_misses") |
| 411 | bs.Bcache.FiveMin.CacheHits = par.readValue("cache_hits") |
| 412 | bs.Bcache.FiveMin.CacheMissCollisions = par.readValue("cache_miss_collisions") |
| 413 | bs.Bcache.FiveMin.CacheMisses = par.readValue("cache_misses") |
| 414 | bs.Bcache.FiveMin.CacheReadaheads = par.readValue("cache_readaheads") |
| 415 | |
| 416 | // dir <uuidPath>/stats_total |
| 417 | par.setSubDir("stats_total") |
| 418 | bs.Bcache.Total.Bypassed = par.readValue("bypassed") |
| 419 | bs.Bcache.Total.CacheHits = par.readValue("cache_hits") |
| 420 | |
| 421 | bs.Bcache.Total.Bypassed = par.readValue("bypassed") |
| 422 | bs.Bcache.Total.CacheBypassHits = par.readValue("cache_bypass_hits") |
| 423 | bs.Bcache.Total.CacheBypassMisses = par.readValue("cache_bypass_misses") |
| 424 | bs.Bcache.Total.CacheHits = par.readValue("cache_hits") |
| 425 | bs.Bcache.Total.CacheMissCollisions = par.readValue("cache_miss_collisions") |
| 426 | bs.Bcache.Total.CacheMisses = par.readValue("cache_misses") |
| 427 | bs.Bcache.Total.CacheReadaheads = par.readValue("cache_readaheads") |
| 428 | |
| 429 | if par.err != nil { |
| 430 | return nil, par.err |
| 431 | } |
| 432 | |
| 433 | // bdev stats |
no test coverage detected