diff options
author | aristocratos <gnmjpl@gmail.com> | 2023-11-25 21:01:11 +0100 |
---|---|---|
committer | aristocratos <gnmjpl@gmail.com> | 2023-11-25 21:01:11 +0100 |
commit | 19bcff894bd8f018bc3c76607b1dd91200537923 (patch) | |
tree | c4bb731a28f389874fbf000ef2b10785c3cbee41 /src | |
parent | b87772611cb6290e834c6beb27eaceea46a10d90 (diff) |
Squashed commit of the following:
commit 0267eba2bbebd6f166b24358159d7fb094fae052
Merge: 50bbab0 e81cf2b
Author: Jakob P. Liljenberg <admin@qvantnet.com>
Date: Wed Nov 15 21:43:18 2023 +0100
Merge pull request #659 from ivanp7/patch-1
Add alternative key codes for Delete, Insert, Home, End
commit 50bbab05122b2f8c35c90e4a6e01d5c52e5eca60
Merge: 9edbf27 5a14c7b
Author: Jakob P. Liljenberg <admin@qvantnet.com>
Date: Wed Nov 15 21:35:50 2023 +0100
Merge pull request #660 from stradicat/feature/elementarish
Elementarish theme: color update according to Elementary palette
commit 5a14c7b6fa41a7fe7061c0aa2f2d0c0fe530e495
Merge: 979506f 71eb414
Author: Dennis Mayr <dmayr.dev@gmail.com>
Date: Wed Nov 15 17:27:34 2023 -0300
Merge branch 'main' of https://github.com/stradicat/btop
commit 979506f18ecdc1475b882d7dadc220386169b7db
Author: Dennis Mayr <dmayr.dev@gmail.com>
Date: Wed Nov 8 11:17:47 2023 -0300
Elementarish theme: color update according to Elementary palette
commit 71eb4142e8204303af091555067b93d82e5dcec1
Author: Dennis Mayr <dmayr.dev@gmail.com>
Date: Wed Nov 8 11:17:47 2023 -0300
Elementarish theme: color update according to Elementary palette
commit e81cf2b7ff4111e279e1111127e49c6858d83d5e
Author: vân <3432246+ivanp7@users.noreply.github.com>
Date: Tue Nov 7 15:12:27 2023 +0000
Add alternative key codes for Insert, Home, End
commit f9452ff6d56af721fb5526ede11206c7d3b885b8
Author: vân <3432246+ivanp7@users.noreply.github.com>
Date: Mon Nov 6 13:31:53 2023 +0000
Add alternative Delete key code
Delete key not always produces ^[[3~, on some terminals (like st) it produces ^[[P.
commit 9edbf27f1b6d5844a97325fcda732762ba086a99
Merge: 2a864f6 ff1f51c
Author: Jakob P. Liljenberg <admin@qvantnet.com>
Date: Sat Oct 21 02:09:55 2023 +0200
Merge pull request #649 from nobounce/workflow-timeout
Set FreeBSD workflow timeout
commit ff1f51ccbb6d6133292e57ba1b8edb8b6c941fc9
Author: Steffen Winter <steffen.winter@proton.me>
Date: Wed Oct 18 22:26:36 2023 +0200
Set FreeBSD workflow timeout
Recently the FreeBSD workflow has started to hang in a boot loop when
the VM starts up. The issue is being tracked upstream but there is not
response at the moment.
To work around this set a timeout to not waste CI minutes. Other
workflows might also want this change since they don't take 20 minutes
anyway.
commit 2a864f6f2ea60df16b3f015885eb3c18a48b9b78
Merge: 636eb25 b2bf8ef
Author: Jakob P. Liljenberg <admin@qvantnet.com>
Date: Sat Oct 7 10:40:54 2023 +0200
Merge pull request #643 from DecklynKern/main
Fix scrollbar not clearing sometimes.
commit b2bf8ef504f29650f8fe0adab41c3cac35b67567
Author: DecklynKern <DecklynKern@gmail.com>
Date: Fri Oct 6 17:33:38 2023 -0600
Fix scrollbar not clearing sometimes.
commit 636eb25f5e31a7af337b024873b2ceb42650ebdb
Merge: 260c0f6 b5ba2fc
Author: Jakob P. Liljenberg <admin@qvantnet.com>
Date: Sat Sep 30 19:51:03 2023 +0200
Merge pull request #623 from rahulaggarwal965/main
Add keybind for toggling memory display mode in PROC box
commit b5ba2fc9635e540142d3dd3eccd866865c9393fd
Author: Rahul Aggarwal <rahulaggarwal965@gmail.com>
Date: Wed Sep 20 22:55:56 2023 -0400
Add keybind for toggling memory display mode in PROC box
commit 260c0f662313fe0d0df859645f5731af04fc9fa7
Merge: 52bfff7 e6a06eb
Author: Jakob P. Liljenberg <admin@qvantnet.com>
Date: Sat Sep 30 18:56:25 2023 +0200
Merge pull request #635 from lvxnull/editorconfig
Add hpp files to .editorconfig
commit e6a06eb729f11fb8b14f104a041c8504772a8c95
Author: lvxnull <86745229+lvxnull@users.noreply.github.com>
Date: Thu Sep 28 19:44:47 2023 +0200
Add hpp files to .editorconfig
commit 52bfff7ceb3d259b1a71002fcbfb20261294bdd7
Merge: 1f72e56 19dbbe1
Author: Jakob P. Liljenberg <admin@qvantnet.com>
Date: Sat Sep 30 18:55:08 2023 +0200
Merge pull request #636 from nobounce/performance-iili
Minor string initialization improvement
commit 19dbbe1a17f7e6453709c37a23859e5d73591e53
Author: nobounce <steffen.winter@proton.me>
Date: Fri Sep 29 12:20:59 2023 +0200
Minor string initialization improvement
commit 1f72e56c7d6e70f8851134c0a28e17fb0a824a71
Merge: 278a0e6 cdcf8bc
Author: Jakob P. Liljenberg <admin@qvantnet.com>
Date: Fri Sep 29 10:43:21 2023 +0200
Merge pull request #633 from crestfallnatwork/main
[fix] Made disks statvfs logic asynchronous.
commit cdcf8bc92978c826d9c1768b547df3b7484003f2
Author: crestfalln <guptahiman01@gmail.com>
Date: Fri Sep 29 09:07:27 2023 +0530
fixed bug where updated disks stats overrided disk io data
commit 9b4e85f08dc3be40d8f4904093cd2bdd096e60fa
Author: crestfalln <no-reply@crestfalln.com>
Date: Thu Sep 28 04:57:05 2023 +0530
fixed bug where updated disks stats overrided disk io data
commit 889623874ef6233610ed529bff18e1ba2c407e14
Author: crestfalln <no-reply@crestfalln.com>
Date: Wed Sep 27 23:57:06 2023 +0530
made disks stat logic async
commit 278a0e6b171a5f967e0680f679c20d9fc8d58c6f
Merge: d16adc9 e89519f
Author: Jakob P. Liljenberg <admin@qvantnet.com>
Date: Thu Sep 28 18:32:09 2023 +0200
Merge pull request #630 from lvxnull/signal-list
Fix signal list on non-linux/weird linux platforms
commit e89519fbb2cd53ddb06ab0a39093c19fc595277c
Author: lvxnull <86745229+lvxnull@users.noreply.github.com>
Date: Sun Sep 24 21:44:38 2023 +0200
Fix signal list on non-linux/weird linux platforms
commit d16adc9fd03322d46f1b84e5ebe7d426f726a5cc
Merge: 2c3ac48 f34b408
Author: Jakob P. Liljenberg <admin@qvantnet.com>
Date: Thu Sep 28 18:20:42 2023 +0200
Merge pull request #618 from nobounce/aggregate-child-processes
Add option to accumulate a child's resources in parent in tree-view
commit f34b40892fef31f657cbe8066c8b0d41ed37c0fc
Author: nobounce <steffen.winter@proton.me>
Date: Sun Sep 24 16:34:50 2023 +0200
Make process thread count better readable when wider than 5 digits
commit 6027cedd424e963bc6fe9017252ed4f1c9f8634b
Author: nobounce <steffen.winter@proton.me>
Date: Thu Sep 14 23:27:05 2023 +0200
Add option to accumulate a child's resources in parent in tree-view
commit 2c3ac4855de49563edd4ef199b0be74babc7ce32
Merge: f90dc37 5c6a281
Author: Jakob P. Liljenberg <admin@qvantnet.com>
Date: Wed Sep 13 21:14:56 2023 +0200
Merge pull request #589 from nobounce/cmake
Add CMake support for Linux
commit f90dc37c26024f28c2a88d87d041fca1f1b5db1e
Merge: 0cac861 68a49c1
Author: Jakob P. Liljenberg <admin@qvantnet.com>
Date: Wed Sep 13 20:27:05 2023 +0200
Merge pull request #610 from SidVeld/feature/horizon-theme
Horizon theme
commit 5c6a2810021c352584a0834c95eff4ece7454c0e
Author: nobounce <steffen.winter@proton.me>
Date: Tue Aug 29 20:39:00 2023 +0200
Add CMake support
Linux is completly supported
FreeBSD is not able to create a static executable for now. See
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=273398
MacOS was not tested
commit 68a49c10a63371b65beb670f7a55ccb43fe38311
Author: SidVeld <sidveld@gmail.com>
Date: Wed Sep 6 18:03:31 2023 +0300
Add horizon theme
commit 0cac8619105521999d603efaeb7d7eed8c38d746
Merge: 31be436 f798acd
Author: Jakob P. Liljenberg <admin@qvantnet.com>
Date: Tue Sep 5 19:27:38 2023 +0200
Merge pull request #609 from scorpion-26/byteconv
Fix short conversion of 1000-1023 *iB
commit f798acdaf71455684883df0ffb31d29293f788b2
Author: scorpion-26 <dev.scorpion26@gmail.com>
Date: Tue Sep 5 18:00:47 2023 +0200
Fix short conversion of 1000-1023*iB
floating_humanizer([1000-1024], true) with base 8 returns "2K", whereas it should return
"1.0K" to align with other formats. The conversion is also broken for
all other units(e.g. 1023M is also broken and returns "2G")
commit 31be4362ce122182862ac338a9a479cde3a4c8e2
Author: aristocratos <gnmjpl@gmail.com>
Date: Sun Aug 27 02:00:07 2023 +0200
FreeBSD Github action 13.1 -> 13.2 and static libgcc and libstdc++
commit fc523fd1d0ef49443367056e30653933efc8920c
Author: aristocratos <gnmjpl@gmail.com>
Date: Sun Aug 27 01:36:26 2023 +0200
Fix for FreeBSD github action not failing "correctly"...
Diffstat (limited to 'src')
-rw-r--r-- | src/btop_config.cpp | 3 | ||||
-rw-r--r-- | src/btop_draw.cpp | 19 | ||||
-rw-r--r-- | src/btop_input.cpp | 7 | ||||
-rw-r--r-- | src/btop_menu.cpp | 76 | ||||
-rw-r--r-- | src/btop_shared.cpp | 7 | ||||
-rw-r--r-- | src/btop_tools.cpp | 2 | ||||
-rw-r--r-- | src/linux/btop_collect.cpp | 65 |
7 files changed, 148 insertions, 31 deletions
diff --git a/src/btop_config.cpp b/src/btop_config.cpp index 4189c64..0f723b7 100644 --- a/src/btop_config.cpp +++ b/src/btop_config.cpp @@ -109,6 +109,8 @@ namespace Config { {"proc_filter_kernel", "#* (Linux) Filter processes tied to the Linux kernel(similar behavior to htop)."}, + {"proc_aggregate", "#* In tree-view, always accumulate child process resources in the parent process."}, + {"cpu_graph_upper", "#* Sets the CPU stat shown in upper half of the CPU graph, \"total\" is always available.\n" "#* Select from a list of detected attributes from the options menu."}, @@ -296,6 +298,7 @@ namespace Config { {"lowcolor", false}, {"show_detailed", false}, {"proc_filtering", false}, + {"proc_aggregate", false}, #ifdef GPU_SUPPORT {"nvml_measure_pcie_speeds", true}, {"gpu_mirror_graph", true}, diff --git a/src/btop_draw.cpp b/src/btop_draw.cpp index 1327562..edb1eec 100644 --- a/src/btop_draw.cpp +++ b/src/btop_draw.cpp @@ -1876,7 +1876,17 @@ namespace Proc { else mem_str.resize((mem_p < 10 or mem_p >= 100 ? 3 : 4)); mem_str += '%'; } - out += (thread_size > 0 ? t_color + rjust(to_string(min(p.threads, (size_t)9999)), thread_size) + ' ' + end : "" ) + + // Shorten process thread representation when larger than 5 digits: 10000 -> 10K ... + const std::string proc_threads_string = [&] { + if (p.threads > 9999) { + return std::to_string(p.threads / 1000) + 'K'; + } else { + return std::to_string(p.threads); + } + }(); + + out += (thread_size > 0 ? t_color + rjust(proc_threads_string, thread_size) + ' ' + end : "" ) + g_color + ljust((cmp_greater(p.user.size(), user_size) ? p.user.substr(0, user_size - 1) + '+' : p.user), user_size) + ' ' + m_color + rjust(mem_str, 5) + end + ' ' + (is_selected ? "" : Theme::c("inactive_fg")) + (show_graphs ? graph_bg * 5: "") @@ -1892,8 +1902,11 @@ namespace Proc { if (numpids > select_max) { const int scroll_pos = clamp((int)round((double)start * select_max / (numpids - select_max)), 0, height - 5); out += Mv::to(y + 1, x + width - 2) + Fx::b + Theme::c("main_fg") + Symbols::up - + Mv::to(y + height - 2, x + width - 2) + Symbols::down - + Mv::to(y + 2 + scroll_pos, x + width - 2) + "█"; + + Mv::to(y + height - 2, x + width - 2) + Symbols::down; + + for (int i = y + 2; i < y + height - 2; i++) { + out += Mv::to(i, x + width - 2) + ((i == y + 2 + scroll_pos) ? "█" : " "); + } } //? Current selection and number of processes diff --git a/src/btop_input.cpp b/src/btop_input.cpp index ce3ac48..88f307b 100644 --- a/src/btop_input.cpp +++ b/src/btop_input.cpp @@ -64,9 +64,13 @@ namespace Input { {"[C", "right"}, {"OC", "right"}, {"[2~", "insert"}, + {"[4h", "insert"}, {"[3~", "delete"}, + {"[P", "delete"}, {"[H", "home"}, + {"[1~", "home"}, {"[F", "end"}, + {"[4~", "end"}, {"[5~", "page_up"}, {"[6~", "page_down"}, {"\t", "tab"}, @@ -362,6 +366,9 @@ namespace Input { else if (key == "c") Config::flip("proc_per_core"); + else if (key == "%") + Config::flip("proc_mem_bytes"); + else if (key == "delete" and not Config::getS("proc_filter").empty()) Config::set("proc_filter", ""s); diff --git a/src/btop_menu.cpp b/src/btop_menu.cpp index 9b11f21..206052f 100644 --- a/src/btop_menu.cpp +++ b/src/btop_menu.cpp @@ -54,15 +54,73 @@ namespace Menu { int signalKillRet{}; // defaults to 0 const array<string, 32> P_Signals = { - "0", + "0", +#ifdef __linux__ +#if defined(__hppa__) + "SIGHUP", "SIGINT", "SIGQUIT", "SIGILL", + "SIGTRAP", "SIGABRT", "SIGSTKFLT", "SIGFPE", + "SIGKILL", "SIGBUS", "SIGSEGV", "SIGXCPU", + "SIGPIPE", "SIGALRM", "SIGTERM", "SIGUSR1", + "SIGUSR2", "SIGCHLD", "SIGPWR", "SIGVTALRM", + "SIGPROF", "SIGIO", "SIGWINCH", "SIGSTOP", + "SIGTSTP", "SIGCONT", "SIGTTIN", "SIGTTOU", + "SIGURG", "SIGXFSZ", "SIGSYS" +#elif defined(__mips__) + "SIGHUP", "SIGINT", "SIGQUIT", "SIGILL", + "SIGTRAP", "SIGABRT", "SIGEMT", "SIGFPE", + "SIGKILL", "SIGBUS", "SIGSEGV", "SIGSYS", + "SIGPIPE", "SIGALRM", "SIGTERM", "SIGUSR1", + "SIGUSR2", "SIGCHLD", "SIGPWR", "SIGWINCH", + "SIGURG", "SIGIO", "SIGSTOP", "SIGTSTP", + "SIGCONT", "SIGTTIN", "SIGTTOU", "SIGVTALRM", + "SIGPROF", "SIGXCPU", "SIGXFSZ" +#elif defined(__alpha__) + "SIGHUP", "SIGINT", "SIGQUIT", "SIGILL", + "SIGTRAP", "SIGABRT", "SIGEMT", "SIGFPE", + "SIGKILL", "SIGBUS", "SIGSEGV", "SIGSYS", + "SIGPIPE", "SIGALRM", "SIGTERM", "SIGURG", + "SIGSTOP", "SIGTSTP", "SIGCONT", "SIGCHLD", + "SIGTTIN", "SIGTTOU", "SIGIO", "SIGXCPU", + "SIGXFSZ", "SIGVTALRM", "SIGPROF", "SIGWINCH", + "SIGPWR", "SIGUSR1", "SIGUSR2" +#elif defined (__sparc__) + "SIGHUP", "SIGINT", "SIGQUIT", "SIGILL", + "SIGTRAP", "SIGABRT", "SIGEMT", "SIGFPE", + "SIGKILL", "SIGBUS", "SIGSEGV", "SIGSYS", + "SIGPIPE", "SIGALRM", "SIGTERM", "SIGURG", + "SIGSTOP", "SIGTSTP", "SIGCONT", "SIGCHLD", + "SIGTTIN", "SIGTTOU", "SIGIO", "SIGXCPU", + "SIGXFSZ", "SIGVTALRM", "SIGPROF", "SIGWINCH", + "SIGLOST", "SIGUSR1", "SIGUSR2" +#else "SIGHUP", "SIGINT", "SIGQUIT", "SIGILL", "SIGTRAP", "SIGABRT", "SIGBUS", "SIGFPE", "SIGKILL", "SIGUSR1", "SIGSEGV", "SIGUSR2", - "SIGPIPE", "SIGALRM", "SIGTERM", "16", "SIGCHLD", - "SIGCONT", "SIGSTOP", "SIGTSTP", "SIGTTIN", - "SIGTTOU", "SIGURG", "SIGXCPU", "SIGXFSZ", - "SIGVTALRM", "SIGPROF", "SIGWINCH", "SIGIO", - "SIGPWR", "SIGSYS" + "SIGPIPE", "SIGALRM", "SIGTERM", "SIGSTKFLT", + "SIGCHLD", "SIGCONT", "SIGSTOP", "SIGTSTP", + "SIGTTIN", "SIGTTOU", "SIGURG", "SIGXCPU", + "SIGXFSZ", "SIGVTALRM", "SIGPROF", "SIGWINCH", + "SIGIO", "SIGPWR", "SIGSYS" +#endif +#elif defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__APPLE__) + "SIGHUP", "SIGINT", "SIGQUIT", "SIGILL", + "SIGTRAP", "SIGABRT", "SIGEMT", "SIGFPE", + "SIGKILL", "SIGBUS", "SIGSEGV", "SIGSYS", + "SIGPIPE", "SIGALRM", "SIGTERM", "SIGURG", + "SIGSTOP", "SIGTSTP", "SIGCONT", "SIGCHLD", + "SIGTTIN", "SIGTTOU", "SIGIO", "SIGXCPU", + "SIGXFSZ", "SIGVTALRM", "SIGPROF", "SIGWINCH", + "SIGINFO", "SIGUSR1", "SIGUSR2" +#else + "SIGHUP", "SIGINT", "SIGQUIT", "SIGILL", + "SIGTRAP", "SIGABRT", "7", "SIGFPE", + "SIGKILL", "10", "SIGSEGV", "12", + "SIGPIPE", "SIGALRM", "SIGTERM", "16", + "17", "18", "19", "20", + "21", "22", "23", "24", + "25", "26", "27", "28", + "29", "30", "31" +#endif }; unordered_flat_map<string, Input::Mouse_loc> mouse_mappings; @@ -138,6 +196,7 @@ namespace Menu { {"c", "Toggle per-core cpu usage of processes."}, {"r", "Reverse sorting order in processes box."}, {"e", "Toggle processes tree view."}, + {"%", "Toggles memory display mode in processes box."}, {"Selected +, -", "Expand/collapse the selected process in tree view."}, {"Selected t", "Terminate selected process with SIGTERM - 15."}, {"Selected k", "Kill selected process with SIGKILL - 9."}, @@ -675,6 +734,11 @@ namespace Menu { "Set true to show processes grouped by", "parents with lines drawn between parent", "and child process."}, + {"proc_aggregate", + "Aggregate child's resources in parent.", + "", + "In tree-view, include all child resources", + "with the parent even while expanded."}, {"proc_colors", "Enable colors in process view.", "", diff --git a/src/btop_shared.cpp b/src/btop_shared.cpp index b2f70a8..fe0f334 100644 --- a/src/btop_shared.cpp +++ b/src/btop_shared.cpp @@ -18,6 +18,7 @@ tab-size = 4 #include <ranges> +#include "btop_config.hpp" #include "btop_shared.hpp" #include "btop_tools.hpp" @@ -168,6 +169,12 @@ namespace Proc { filter_found++; p.filtered = true; } + else if (Config::getB("proc_aggregate")) { + cur_proc.cpu_p += p.cpu_p; + cur_proc.cpu_c += p.cpu_c; + cur_proc.mem += p.mem; + cur_proc.threads += p.threads; + } } if (collapsed or filtering) { return; diff --git a/src/btop_tools.cpp b/src/btop_tools.cpp index 75adae9..88bf711 100644 --- a/src/btop_tools.cpp +++ b/src/btop_tools.cpp @@ -455,7 +455,7 @@ namespace Tools { out = to_string((int)round(stod(out))); } if (out.size() > 3) { - out = to_string((int)(out[0] - '0') + 1); + out = to_string((int)(out[0] - '0')) + ".0"; start++; } out.push_back(units[start][0]); diff --git a/src/linux/btop_collect.cpp b/src/linux/btop_collect.cpp index 9899224..4bb5e71 100644 --- a/src/linux/btop_collect.cpp +++ b/src/linux/btop_collect.cpp @@ -29,6 +29,7 @@ tab-size = 4 #include <net/if.h> #include <arpa/inet.h> // for inet_ntop() #include <filesystem> +#include <future> #include <dlfcn.h> #if defined(RSMI_STATIC) @@ -53,12 +54,17 @@ using std::numeric_limits; using std::round; using std::streamsize; using std::vector; +using std::future; +using std::async; +using std::pair; + namespace fs = std::filesystem; namespace rng = std::ranges; using namespace Tools; using namespace std::literals; // for operator""s +using namespace std::chrono_literals; //? --------------------------------------------------- FUNCTIONS ----------------------------------------------------- namespace Cpu { @@ -1607,6 +1613,7 @@ namespace Mem { auto only_physical = Config::getB("only_physical"); auto zfs_hide_datasets = Config::getB("zfs_hide_datasets"); auto& disks = mem.disks; + static unordered_flat_map<string, future<pair<disk_info, int>>> disks_stats_promises; ifstream diskread; vector<string> filter; @@ -1746,31 +1753,47 @@ namespace Mem { diskread.close(); //? Get disk/partition stats - bool new_ignored = false; - for (auto& [mountpoint, disk] : disks) { - if (std::error_code ec; not fs::exists(mountpoint, ec) or v_contains(ignore_list, mountpoint)) continue; - struct statvfs vfs; - if (statvfs(mountpoint.c_str(), &vfs) < 0) { - Logger::warning("Failed to get disk/partition stats for mount \""+ mountpoint + "\" with statvfs error code: " + to_string(errno) + ". Ignoring..."); - ignore_list.push_back(mountpoint); - new_ignored = true; + for (auto it = disks.begin(); it != disks.end(); ) { + auto &[mountpoint, disk] = *it; + if (v_contains(ignore_list, mountpoint)) { + it = disks.erase(it); continue; } - disk.total = vfs.f_blocks * vfs.f_frsize; - disk.free = (free_priv ? vfs.f_bfree : vfs.f_bavail) * vfs.f_frsize; - disk.used = disk.total - disk.free; - disk.used_percent = round((double)disk.used * 100 / disk.total); - disk.free_percent = 100 - disk.used_percent; - } - - //? Remove any problematic disks added to the ignore_list - if (new_ignored) { - for (auto it = disks.begin(); it != disks.end();) { - if (v_contains(ignore_list, it->first)) + if(auto promises_it = disks_stats_promises.find(mountpoint); promises_it != disks_stats_promises.end()){ + auto& promise = promises_it->second; + if(promise.valid() && + promise.wait_for(0s) == std::future_status::timeout) { + ++it; + continue; + } + auto promise_res = promises_it->second.get(); + if(promise_res.second != -1){ + ignore_list.push_back(mountpoint); + Logger::warning("Failed to get disk/partition stats for mount \""+ mountpoint + "\" with statvfs error code: " + to_string(promise_res.second) + ". Ignoring..."); it = disks.erase(it); - else - it++; + continue; + } + auto &updated_stats = promise_res.first; + disk.total = updated_stats.total; + disk.free = updated_stats.free; + disk.used = updated_stats.used; + disk.used_percent = updated_stats.used_percent; + disk.free_percent = updated_stats.free_percent; } + disks_stats_promises[mountpoint] = async(std::launch::async, [mountpoint, &free_priv]() -> pair<disk_info, int> { + struct statvfs vfs; + disk_info disk; + if (statvfs(mountpoint.c_str(), &vfs) < 0) { + return pair{disk, errno}; + } + disk.total = vfs.f_blocks * vfs.f_frsize; + disk.free = (free_priv ? vfs.f_bfree : vfs.f_bavail) * vfs.f_frsize; + disk.used = disk.total - disk.free; + disk.used_percent = round((double)disk.used * 100 / disk.total); + disk.free_percent = 100 - disk.used_percent; + return pair{disk, -1}; + }); + ++it; } //? Setup disks order in UI and add swap if enabled |