summaryrefslogtreecommitdiffstats
path: root/src/freebsd
diff options
context:
space:
mode:
authorvsey <54716634+vsey@users.noreply.github.com>2023-12-26 23:43:14 +0100
committerGitHub <noreply@github.com>2023-12-26 23:43:14 +0100
commit63ce0abc6471cd270c4587ab52b1087bfea5377c (patch)
treea76e2c6b2857eda0008efe2912bd409cbbb3ddda /src/freebsd
parent9dd43796fd6291298de9e0d32467f7f6df9c0298 (diff)
parentad14554f32cc9c19f3cdc8e28ea6012a974a533a (diff)
Merge branch 'aristocratos:main' into battery-power-2
Diffstat (limited to 'src/freebsd')
-rw-r--r--src/freebsd/btop_collect.cpp33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/freebsd/btop_collect.cpp b/src/freebsd/btop_collect.cpp
index d678038..38f4368 100644
--- a/src/freebsd/btop_collect.cpp
+++ b/src/freebsd/btop_collect.cpp
@@ -58,6 +58,7 @@ tab-size = 4
#include <regex>
#include <string>
#include <memory>
+#include <utility>
#include "../btop_config.hpp"
#include "../btop_shared.hpp"
@@ -98,7 +99,7 @@ namespace Cpu {
string cpu_sensor;
vector<string> core_sensors;
- unordered_flat_map<int, int> core_mapping;
+ std::unordered_map<int, int> core_mapping;
} // namespace Cpu
namespace Mem {
@@ -169,17 +170,23 @@ namespace Shared {
Cpu::current_cpu.temp.insert(Cpu::current_cpu.temp.begin(), Shared::coreCount + 1, {});
Cpu::core_old_totals.insert(Cpu::core_old_totals.begin(), Shared::coreCount, 0);
Cpu::core_old_idles.insert(Cpu::core_old_idles.begin(), Shared::coreCount, 0);
+ Logger::debug("Init -> Cpu::collect()");
Cpu::collect();
for (auto &[field, vec] : Cpu::current_cpu.cpu_percent) {
if (not vec.empty() and not v_contains(Cpu::available_fields, field)) Cpu::available_fields.push_back(field);
}
+ Logger::debug("Init -> Cpu::get_cpuName()");
Cpu::cpuName = Cpu::get_cpuName();
+ Logger::debug("Init -> Cpu::get_sensors()");
Cpu::got_sensors = Cpu::get_sensors();
+ Logger::debug("Init -> Cpu::get_core_mapping()");
Cpu::core_mapping = Cpu::get_core_mapping();
//? Init for namespace Mem
Mem::old_uptime = system_uptime();
+ Logger::debug("Init -> Mem::collect()");
Mem::collect();
+ Logger::debug("Init -> Mem::get_zpools()");
Mem::get_zpools();
}
@@ -204,7 +211,7 @@ namespace Cpu {
const array<string, 10> time_names = {"user", "nice", "system", "idle"};
- unordered_flat_map<string, long long> cpu_old = {
+ std::unordered_map<string, long long> cpu_old = {
{"totals", 0},
{"idles", 0},
{"user", 0},
@@ -323,8 +330,8 @@ namespace Cpu {
return std::to_string(freq / 1000.0 ).substr(0, 3); // seems to be in MHz
}
- auto get_core_mapping() -> unordered_flat_map<int, int> {
- unordered_flat_map<int, int> core_map;
+ auto get_core_mapping() -> std::unordered_map<int, int> {
+ std::unordered_map<int, int> core_map;
if (cpu_temp_only) return core_map;
for (long i = 0; i < Shared::coreCount; i++) {
@@ -562,7 +569,7 @@ namespace Mem {
}
}
- void collect_disk(unordered_flat_map<string, disk_info> &disks, unordered_flat_map<string, string> &mapping) {
+ void collect_disk(std::unordered_map<string, disk_info> &disks, std::unordered_map<string, string> &mapping) {
// this bit is for 'regular' mounts
static struct statinfo cur;
long double etime = 0;
@@ -577,7 +584,7 @@ namespace Mem {
auto d = cur.dinfo->devices[i];
string devStatName = "/dev/" + string(d.device_name) + std::to_string(d.unit_number);
for (auto& [ignored, disk] : disks) { // find matching mountpoints - could be multiple as d.device_name is only ada (and d.unit_number is the device number), while the disk.dev is like /dev/ada0s1
- if (disk.dev.string().rfind(devStatName, 0) == 0) {
+ if (disk.dev.string().rfind(devStatName, 0) == 0 and mapping.contains(disk.dev)) {
devstat_compute_statistics(&d, nullptr, etime, DSM_TOTAL_BYTES_READ, &total_bytes_read, DSM_TOTAL_BYTES_WRITE, &total_bytes_write, DSM_NONE);
assign_values(disk, total_bytes_read, total_bytes_write);
string mountpoint = mapping.at(disk.dev);
@@ -586,7 +593,6 @@ namespace Mem {
}
}
- Logger::debug("");
}
// this code is for ZFS mounts
@@ -696,7 +702,7 @@ namespace Mem {
}
if (show_disks) {
- unordered_flat_map<string, string> mapping; // keep mapping from device -> mountpoint, since IOKit doesn't give us the mountpoint
+ std::unordered_map<string, string> mapping; // keep mapping from device -> mountpoint, since IOKit doesn't give us the mountpoint
double uptime = system_uptime();
auto &disks_filter = Config::getS("disks_filter");
bool filter_exclude = false;
@@ -812,13 +818,13 @@ namespace Mem {
} // namespace Mem
namespace Net {
- unordered_flat_map<string, net_info> current_net;
+ std::unordered_map<string, net_info> current_net;
net_info empty_net = {};
vector<string> interfaces;
string selected_iface;
int errors = 0;
- unordered_flat_map<string, uint64_t> graph_max = {{"download", {}}, {"upload", {}}};
- unordered_flat_map<string, array<int, 2>> max_count = {{"download", {}}, {"upload", {}}};
+ std::unordered_map<string, uint64_t> graph_max = {{"download", {}}, {"upload", {}}};
+ std::unordered_map<string, array<int, 2>> max_count = {{"download", {}}, {"upload", {}}};
bool rescale = true;
uint64_t timestamp = 0;
@@ -897,7 +903,7 @@ namespace Net {
} //else, ignoring family==AF_LINK (see man 3 getifaddrs)
}
- unordered_flat_map<string, std::tuple<uint64_t, uint64_t>> ifstats;
+ std::unordered_map<string, std::tuple<uint64_t, uint64_t>> ifstats;
int mib[] = {CTL_NET, PF_ROUTE, 0, 0, NET_RT_IFLIST, 0};
size_t len;
if (sysctl(mib, 6, nullptr, &len, nullptr, 0) < 0) {
@@ -971,7 +977,6 @@ namespace Net {
else
it++;
}
- net.compact();
}
timestamp = new_timestamp;
@@ -1042,7 +1047,7 @@ namespace Net {
namespace Proc {
vector<proc_info> current_procs;
- unordered_flat_map<string, string> uid_user;
+ std::unordered_map<string, string> uid_user;
string current_sort;
string current_filter;
bool current_rev = false;