summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakob P. Liljenberg <admin@qvantnet.com>2023-08-26 19:20:18 +0200
committerGitHub <noreply@github.com>2023-08-26 19:20:18 +0200
commit9a1e760a661c9a160dd83e6d3ab710bf36b19b04 (patch)
tree29fa83258150d0842b59ce9af639337e34fb1ce2
parent9c8af4df436c2847eefa66d2e0eb7ebfd75d70cf (diff)
parent22e64caaff3d5877b7a494980a8ee3f17ea8f824 (diff)
Merge pull request #602 from jfouquart/main
Fix getting zfs pool name with '.' char in freebsd
-rw-r--r--src/freebsd/btop_collect.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/freebsd/btop_collect.cpp b/src/freebsd/btop_collect.cpp
index d69eab9..47598f0 100644
--- a/src/freebsd/btop_collect.cpp
+++ b/src/freebsd/btop_collect.cpp
@@ -543,14 +543,16 @@ namespace Mem {
// find all zpools in the system. Do this only at startup.
void get_zpools() {
+ std::regex toReplace("\\.");
PipeWrapper poolPipe = PipeWrapper("zpool list -H -o name", "r");
+
while (not std::feof(poolPipe())) {
char poolName[512];
size_t len = 512;
if (fgets(poolName, len, poolPipe())) {
poolName[strcspn(poolName, "\n")] = 0;
Logger::debug("zpool found: " + string(poolName));
- Mem::zpools.push_back(poolName);
+ Mem::zpools.push_back(std::regex_replace(poolName, toReplace, "%25"));
}
}
}
@@ -583,7 +585,7 @@ namespace Mem {
}
// this code is for ZFS mounts
- for (string poolName : Mem::zpools) {
+ for (const auto &poolName : Mem::zpools) {
char sysCtl[1024];
snprintf(sysCtl, sizeof(sysCtl), "sysctl kstat.zfs.%s.dataset | egrep \'dataset_name|nread|nwritten\'", poolName.c_str());
PipeWrapper f = PipeWrapper(sysCtl, "r");