diff options
Diffstat (limited to 'src/freebsd/btop_collect.cpp')
-rw-r--r-- | src/freebsd/btop_collect.cpp | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/src/freebsd/btop_collect.cpp b/src/freebsd/btop_collect.cpp index a9eeae9..a9cdf00 100644 --- a/src/freebsd/btop_collect.cpp +++ b/src/freebsd/btop_collect.cpp @@ -4,7 +4,7 @@ you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -120,12 +120,12 @@ namespace Shared { //? Shared global variables init int mib[2]; mib[0] = CTL_HW; - mib[1] = HW_NCPU; + mib[1] = HW_NCPU; int ncpu; - size_t len = sizeof(ncpu); - if (sysctl(mib, 2, &ncpu, &len, NULL, 0) == -1) { + size_t len = sizeof(ncpu); + if (sysctl(mib, 2, &ncpu, &len, NULL, 0) == -1) { Logger::warning("Could not determine number of cores, defaulting to 1."); - } else { + } else { coreCount = ncpu; } @@ -205,12 +205,12 @@ namespace Cpu { const array<string, 10> time_names = {"user", "nice", "system", "idle"}; unordered_flat_map<string, long long> cpu_old = { - {"totals", 0}, - {"idles", 0}, - {"user", 0}, - {"nice", 0}, - {"system", 0}, - {"idle", 0} + {"totals", 0}, + {"idles", 0}, + {"user", 0}, + {"nice", 0}, + {"system", 0}, + {"idle", 0} }; string get_cpuName() { @@ -398,7 +398,7 @@ namespace Cpu { return {percent, seconds, status}; } - auto collect(bool no_update) -> cpu_info & { + auto collect(bool no_update) -> cpu_info & { if (Runner::stopping or (no_update and not current_cpu.cpu_percent.at("total").empty())) return current_cpu; auto &cpu = current_cpu; @@ -555,17 +555,17 @@ namespace Mem { } } - void collect_disk(unordered_flat_map<string, disk_info> &disks, unordered_flat_map<string, string> &mapping) { + void collect_disk(unordered_flat_map<string, disk_info> &disks, unordered_flat_map<string, string> &mapping) { // this bit is for 'regular' mounts - static struct statinfo cur; - long double etime = 0; - uint64_t total_bytes_read; + static struct statinfo cur; + long double etime = 0; + uint64_t total_bytes_read; uint64_t total_bytes_write; static std::unique_ptr<struct devinfo, decltype(std::free)*> curDevInfo (reinterpret_cast<struct devinfo*>(std::calloc(1, sizeof(struct devinfo))), std::free); cur.dinfo = curDevInfo.get(); - if (devstat_getdevs(NULL, &cur) != -1) { + if (devstat_getdevs(NULL, &cur) != -1) { for (int i = 0; i < cur.dinfo->numdevs; i++) { auto d = cur.dinfo->devices[i]; string devStatName = "/dev/" + string(d.device_name) + std::to_string(d.unit_number); @@ -617,17 +617,17 @@ namespace Mem { } } - } + } - auto collect(bool no_update) -> mem_info & { + auto collect(bool no_update) -> mem_info & { if (Runner::stopping or (no_update and not current_mem.percent.at("used").empty())) return current_mem; - auto show_swap = Config::getB("show_swap"); - auto show_disks = Config::getB("show_disks"); - auto swap_disk = Config::getB("swap_disk"); + auto show_swap = Config::getB("show_swap"); + auto show_disks = Config::getB("show_disks"); + auto swap_disk = Config::getB("swap_disk"); auto &mem = current_mem; - static bool snapped = (getenv("BTOP_SNAPPED") != NULL); + static bool snapped = (getenv("BTOP_SNAPPED") != NULL); int mib[4]; u_int memActive, memWire, cachedMem, freeMem; @@ -693,7 +693,7 @@ namespace Mem { double uptime = system_uptime(); auto &disks_filter = Config::getS("disks_filter"); bool filter_exclude = false; - // auto only_physical = Config::getB("only_physical"); + // auto only_physical = Config::getB("only_physical"); auto &disks = mem.disks; vector<string> filter; if (not disks_filter.empty()) { @@ -711,7 +711,7 @@ namespace Mem { for (int i = 0; i < count; i++) { auto fstype = string(stfs[i].f_fstypename); if (fstype == "autofs" || fstype == "devfs" || fstype == "linprocfs" || fstype == "procfs" || fstype == "tmpfs" || fstype == "linsysfs" || - fstype == "fdesckfs") { + fstype == "fdesckfs") { // in memory filesystems -> not useful to show continue; } @@ -826,11 +826,11 @@ namespace Net { auto operator()() -> struct ifaddrs * { return ifaddr; } }; - auto collect(bool no_update) -> net_info & { + auto collect(bool no_update) -> net_info & { auto &net = current_net; auto &config_iface = Config::getS("net_iface"); - auto net_sync = Config::getB("net_sync"); - auto net_auto = Config::getB("net_auto"); + auto net_sync = Config::getB("net_sync"); + auto net_auto = Config::getB("net_auto"); auto new_timestamp = time_ms(); if (not no_update and errors < 3) { @@ -985,7 +985,7 @@ namespace Net { auto sorted_interfaces = interfaces; rng::sort(sorted_interfaces, [&](const auto &a, const auto &b) { return cmp_greater(net.at(a).stat["download"].total + net.at(a).stat["upload"].total, - net.at(b).stat["download"].total + net.at(b).stat["upload"].total); + net.at(b).stat["download"].total + net.at(b).stat["upload"].total); }); selected_iface.clear(); //? Try to set to a connected interface @@ -1008,8 +1008,8 @@ namespace Net { for (const auto &sel : {0, 1}) { if (rescale or max_count[dir][sel] >= 5) { const long long avg_speed = (net[selected_iface].bandwidth[dir].size() > 5 - ? std::accumulate(net.at(selected_iface).bandwidth.at(dir).rbegin(), net.at(selected_iface).bandwidth.at(dir).rbegin() + 5, 0ll) / 5 - : net[selected_iface].stat[dir].speed); + ? std::accumulate(net.at(selected_iface).bandwidth.at(dir).rbegin(), net.at(selected_iface).bandwidth.at(dir).rbegin() + 5, 0ll) / 5 + : net[selected_iface].stat[dir].speed); graph_max[dir] = max(uint64_t(avg_speed * (sel == 0 ? 1.3 : 3.0)), (uint64_t)10 << 10); max_count[dir][0] = max_count[dir][1] = 0; redraw = true; @@ -1110,17 +1110,17 @@ namespace Proc { } //* Collects and sorts process information from /proc - auto collect(bool no_update) -> vector<proc_info> & { + auto collect(bool no_update) -> vector<proc_info> & { const auto &sorting = Config::getS("proc_sorting"); - auto reverse = Config::getB("proc_reversed"); + auto reverse = Config::getB("proc_reversed"); const auto &filter = Config::getS("proc_filter"); - auto per_core = Config::getB("proc_per_core"); - auto tree = Config::getB("proc_tree"); - auto show_detailed = Config::getB("show_detailed"); + auto per_core = Config::getB("proc_per_core"); + auto tree = Config::getB("proc_tree"); + auto show_detailed = Config::getB("show_detailed"); const size_t detailed_pid = Config::getI("detailed_pid"); bool should_filter = current_filter != filter; if (should_filter) current_filter = filter; - bool sorted_change = (sorting != current_sort or reverse != current_rev or should_filter); + bool sorted_change = (sorting != current_sort or reverse != current_rev or should_filter); if (sorted_change) { current_sort = sorting; current_rev = reverse; @@ -1156,12 +1156,12 @@ namespace Proc { const double timeNow = currentTime.tv_sec + (currentTime.tv_usec / 1'000'000); int count = 0; - char buf[_POSIX2_LINE_MAX]; + char buf[_POSIX2_LINE_MAX]; Shared::kvm_openfiles_wrapper kd(NULL, _PATH_DEVNULL, NULL, O_RDONLY, buf); const struct kinfo_proc* kprocs = kvm_getprocs(kd(), KERN_PROC_PROC, 0, &count); for (int i = 0; i < count; i++) { - const struct kinfo_proc* kproc = &kprocs[i]; + const struct kinfo_proc* kproc = &kprocs[i]; const size_t pid = (size_t)kproc->ki_pid; if (pid < 1) continue; found.push_back(pid); |