Skip to content

Commit 8f85620

Browse files
committed
refactor(sysmon): readZfsEvictableArcKb internal linkage
1 parent 72f0d03 commit 8f85620

1 file changed

Lines changed: 30 additions & 30 deletions

File tree

src/system/system_monitor_service.cpp

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,36 @@ namespace {
553553

554554
constexpr Logger kLog("sysmon");
555555

556+
std::uint64_t readZfsEvictableArcKb() {
557+
std::ifstream file{"/proc/spl/kstat/zfs/arcstats"};
558+
if (!file.is_open()) {
559+
return 0;
560+
}
561+
562+
std::uint64_t arcSize = 0;
563+
std::uint64_t arcMin = 0;
564+
std::string line;
565+
while (std::getline(file, line)) {
566+
std::string key;
567+
std::uint32_t type = 0;
568+
std::uint64_t value = 0;
569+
570+
std::istringstream iss{line};
571+
if (iss >> key >> type >> value) {
572+
if (key == "size") {
573+
arcSize = value;
574+
} else if (key == "c_min") {
575+
arcMin = value;
576+
}
577+
}
578+
}
579+
580+
if (arcSize > arcMin) {
581+
return (arcSize - arcMin) / 1024;
582+
}
583+
return 0;
584+
}
585+
556586
} // namespace
557587

558588
struct SystemMonitorService::AmdRsmiReader {
@@ -1333,36 +1363,6 @@ std::optional<SystemMonitorService::CpuTotals> SystemMonitorService::readCpuTota
13331363
return totals;
13341364
}
13351365

1336-
std::uint64_t readZfsEvictableArcKb() {
1337-
std::ifstream file{"/proc/spl/kstat/zfs/arcstats"};
1338-
if (!file.is_open()) {
1339-
return 0;
1340-
}
1341-
1342-
std::uint64_t arcSize = 0;
1343-
std::uint64_t arcMin = 0;
1344-
std::string line;
1345-
while (std::getline(file, line)) {
1346-
std::string key;
1347-
std::uint32_t type = 0;
1348-
std::uint64_t value = 0;
1349-
1350-
std::istringstream iss{line};
1351-
if (iss >> key >> type >> value) {
1352-
if (key == "size") {
1353-
arcSize = value;
1354-
} else if (key == "c_min") {
1355-
arcMin = value;
1356-
}
1357-
}
1358-
}
1359-
1360-
if (arcSize > arcMin) {
1361-
return (arcSize - arcMin) / 1024;
1362-
}
1363-
return 0;
1364-
}
1365-
13661366
std::optional<SystemMonitorService::MemData> SystemMonitorService::readMemoryKb() {
13671367
std::ifstream file{"/proc/meminfo"};
13681368
if (!file.is_open()) {

0 commit comments

Comments
 (0)