mirror of
https://github.com/aristocratos/btop.git
synced 2024-10-01 15:41:36 +02:00
Merge pull request #696 from aristocratos/map_safety
This commit is contained in:
commit
a8fda16bf6
8
Makefile
8
Makefile
@ -61,6 +61,10 @@ CLANG_WORKS = false
|
|||||||
GCC_WORKS = false
|
GCC_WORKS = false
|
||||||
MIN_CLANG_VERSION = 16
|
MIN_CLANG_VERSION = 16
|
||||||
|
|
||||||
|
ifeq ($(DEBUG),true)
|
||||||
|
override ADDFLAGS += -DBTOP_DEBUG
|
||||||
|
endif
|
||||||
|
|
||||||
#? Supported is Clang 16.0.0 and later
|
#? Supported is Clang 16.0.0 and later
|
||||||
ifeq ($(CXX_IS_CLANG),true)
|
ifeq ($(CXX_IS_CLANG),true)
|
||||||
ifeq ($(shell $(CXX) --version | grep Apple >/dev/null 2>&1; echo $$?),0)
|
ifeq ($(shell $(CXX) --version | grep Apple >/dev/null 2>&1; echo $$?),0)
|
||||||
@ -279,13 +283,13 @@ directories:
|
|||||||
clean:
|
clean:
|
||||||
@printf "\033[1;91mRemoving: \033[1;97mbuilt objects...\033[0m\n"
|
@printf "\033[1;91mRemoving: \033[1;97mbuilt objects...\033[0m\n"
|
||||||
@rm -rf $(BUILDDIR)
|
@rm -rf $(BUILDDIR)
|
||||||
@cmake --build lib/rocm_smi_lib/build --target clean &> /dev/null || true
|
@test -e lib/rocm_smi_lib/build && cmake --build lib/rocm_smi_lib/build --target clean &> /dev/null || true
|
||||||
|
|
||||||
#? Clean Objects and Binaries
|
#? Clean Objects and Binaries
|
||||||
distclean: clean
|
distclean: clean
|
||||||
@printf "\033[1;91mRemoving: \033[1;97mbuilt binaries...\033[0m\n"
|
@printf "\033[1;91mRemoving: \033[1;97mbuilt binaries...\033[0m\n"
|
||||||
@rm -rf $(TARGETDIR)
|
@rm -rf $(TARGETDIR)
|
||||||
@rm -rf lib/rocm_smi_lib/build
|
@test -e lib/rocm_smi_lib/build && rm -rf lib/rocm_smi_lib/build || true
|
||||||
|
|
||||||
install:
|
install:
|
||||||
@printf "\033[1;92mInstalling binary to: \033[1;97m$(DESTDIR)$(PREFIX)/bin/btop\n"
|
@printf "\033[1;92mInstalling binary to: \033[1;97m$(DESTDIR)$(PREFIX)/bin/btop\n"
|
||||||
|
@ -391,6 +391,7 @@ Also needs a UTF8 locale and a font that covers:
|
|||||||
| `STATIC=true` | For static compilation |
|
| `STATIC=true` | For static compilation |
|
||||||
| `QUIET=true` | For less verbose output |
|
| `QUIET=true` | For less verbose output |
|
||||||
| `STRIP=true` | To force stripping of debug symbols (adds `-s` linker flag) |
|
| `STRIP=true` | To force stripping of debug symbols (adds `-s` linker flag) |
|
||||||
|
| `DEBUG=true` | Sets OPTFLAGS to `-O0 -g` and enables more verbose debug logging |
|
||||||
| `ARCH=<architecture>` | To manually set the target architecture |
|
| `ARCH=<architecture>` | To manually set the target architecture |
|
||||||
| `GPU_SUPPORT=<true\|false>` | Enable/disable GPU support (Enabled by default on X86_64 Linux) |
|
| `GPU_SUPPORT=<true\|false>` | Enable/disable GPU support (Enabled by default on X86_64 Linux) |
|
||||||
| `RSMI_STATIC=true` | To statically link the ROCm SMI library used for querying AMDGPU |
|
| `RSMI_STATIC=true` | To statically link the ROCm SMI library used for querying AMDGPU |
|
||||||
@ -561,6 +562,7 @@ Also needs a UTF8 locale and a font that covers:
|
|||||||
| `STATIC=true` | For static compilation (only libgcc and libstdc++) |
|
| `STATIC=true` | For static compilation (only libgcc and libstdc++) |
|
||||||
| `QUIET=true` | For less verbose output |
|
| `QUIET=true` | For less verbose output |
|
||||||
| `STRIP=true` | To force stripping of debug symbols (adds `-s` linker flag) |
|
| `STRIP=true` | To force stripping of debug symbols (adds `-s` linker flag) |
|
||||||
|
| `DEBUG=true` | Sets OPTFLAGS to `-O0 -g` and enables more verbose debug logging |
|
||||||
| `ARCH=<architecture>` | To manually set the target architecture |
|
| `ARCH=<architecture>` | To manually set the target architecture |
|
||||||
| `ADDFLAGS=<flags>` | For appending flags to both compiler and linker |
|
| `ADDFLAGS=<flags>` | For appending flags to both compiler and linker |
|
||||||
| `CXX=<compiler>` | Manualy set which compiler to use |
|
| `CXX=<compiler>` | Manualy set which compiler to use |
|
||||||
@ -726,6 +728,7 @@ Also needs a UTF8 locale and a font that covers:
|
|||||||
| `STATIC=true` | For static compilation (only libgcc and libstdc++) |
|
| `STATIC=true` | For static compilation (only libgcc and libstdc++) |
|
||||||
| `QUIET=true` | For less verbose output |
|
| `QUIET=true` | For less verbose output |
|
||||||
| `STRIP=true` | To force stripping of debug symbols (adds `-s` linker flag) |
|
| `STRIP=true` | To force stripping of debug symbols (adds `-s` linker flag) |
|
||||||
|
| `DEBUG=true` | Sets OPTFLAGS to `-O0 -g` and enables more verbose debug logging |
|
||||||
| `ARCH=<architecture>` | To manually set the target architecture |
|
| `ARCH=<architecture>` | To manually set the target architecture |
|
||||||
| `ADDFLAGS=<flags>` | For appending flags to both compiler and linker |
|
| `ADDFLAGS=<flags>` | For appending flags to both compiler and linker |
|
||||||
| `CXX=<compiler>` | Manualy set which compiler to use |
|
| `CXX=<compiler>` | Manualy set which compiler to use |
|
||||||
|
2544
include/robin_hood.h
2544
include/robin_hood.h
File diff suppressed because it is too large
Load Diff
@ -32,6 +32,7 @@ tab-size = 4
|
|||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <utility>
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include <CoreFoundation/CoreFoundation.h>
|
#include <CoreFoundation/CoreFoundation.h>
|
||||||
#include <mach-o/dyld.h>
|
#include <mach-o/dyld.h>
|
||||||
@ -416,7 +417,7 @@ namespace Runner {
|
|||||||
};
|
};
|
||||||
|
|
||||||
string debug_bg;
|
string debug_bg;
|
||||||
unordered_flat_map<string, array<uint64_t, 2>> debug_times;
|
std::unordered_map<string, array<uint64_t, 2>> debug_times;
|
||||||
|
|
||||||
class MyNumPunct : public std::numpunct<char>
|
class MyNumPunct : public std::numpunct<char>
|
||||||
{
|
{
|
||||||
|
@ -21,6 +21,7 @@ tab-size = 4
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <ranges>
|
#include <ranges>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
#include <fmt/core.h>
|
#include <fmt/core.h>
|
||||||
|
|
||||||
@ -215,7 +216,7 @@ namespace Config {
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
unordered_flat_map<std::string_view, string> strings = {
|
std::unordered_map<std::string_view, string> strings = {
|
||||||
{"color_theme", "Default"},
|
{"color_theme", "Default"},
|
||||||
{"shown_boxes", "cpu mem net proc"},
|
{"shown_boxes", "cpu mem net proc"},
|
||||||
{"graph_symbol", "braille"},
|
{"graph_symbol", "braille"},
|
||||||
@ -251,9 +252,9 @@ namespace Config {
|
|||||||
{"show_gpu_info", "Auto"}
|
{"show_gpu_info", "Auto"}
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
unordered_flat_map<std::string_view, string> stringsTmp;
|
std::unordered_map<std::string_view, string> stringsTmp;
|
||||||
|
|
||||||
unordered_flat_map<std::string_view, bool> bools = {
|
std::unordered_map<std::string_view, bool> bools = {
|
||||||
{"theme_background", true},
|
{"theme_background", true},
|
||||||
{"truecolor", true},
|
{"truecolor", true},
|
||||||
{"rounded_corners", true},
|
{"rounded_corners", true},
|
||||||
@ -304,9 +305,9 @@ namespace Config {
|
|||||||
{"gpu_mirror_graph", true},
|
{"gpu_mirror_graph", true},
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
unordered_flat_map<std::string_view, bool> boolsTmp;
|
std::unordered_map<std::string_view, bool> boolsTmp;
|
||||||
|
|
||||||
unordered_flat_map<std::string_view, int> ints = {
|
std::unordered_map<std::string_view, int> ints = {
|
||||||
{"update_ms", 2000},
|
{"update_ms", 2000},
|
||||||
{"net_download", 100},
|
{"net_download", 100},
|
||||||
{"net_upload", 100},
|
{"net_upload", 100},
|
||||||
@ -317,7 +318,7 @@ namespace Config {
|
|||||||
{"proc_selected", 0},
|
{"proc_selected", 0},
|
||||||
{"proc_last_selected", 0},
|
{"proc_last_selected", 0},
|
||||||
};
|
};
|
||||||
unordered_flat_map<std::string_view, int> intsTmp;
|
std::unordered_map<std::string_view, int> intsTmp;
|
||||||
|
|
||||||
bool _locked(const std::string_view name) {
|
bool _locked(const std::string_view name) {
|
||||||
atomic_wait(writelock, true);
|
atomic_wait(writelock, true);
|
||||||
|
@ -22,11 +22,10 @@ tab-size = 4
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
#include <robin_hood.h>
|
#include <unordered_map>
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
using robin_hood::unordered_flat_map;
|
|
||||||
|
|
||||||
//* Functions and variables for reading and writing the btop config file
|
//* Functions and variables for reading and writing the btop config file
|
||||||
namespace Config {
|
namespace Config {
|
||||||
@ -34,12 +33,12 @@ namespace Config {
|
|||||||
extern std::filesystem::path conf_dir;
|
extern std::filesystem::path conf_dir;
|
||||||
extern std::filesystem::path conf_file;
|
extern std::filesystem::path conf_file;
|
||||||
|
|
||||||
extern unordered_flat_map<std::string_view, string> strings;
|
extern std::unordered_map<std::string_view, string> strings;
|
||||||
extern unordered_flat_map<std::string_view, string> stringsTmp;
|
extern std::unordered_map<std::string_view, string> stringsTmp;
|
||||||
extern unordered_flat_map<std::string_view, bool> bools;
|
extern std::unordered_map<std::string_view, bool> bools;
|
||||||
extern unordered_flat_map<std::string_view, bool> boolsTmp;
|
extern std::unordered_map<std::string_view, bool> boolsTmp;
|
||||||
extern unordered_flat_map<std::string_view, int> ints;
|
extern std::unordered_map<std::string_view, int> ints;
|
||||||
extern unordered_flat_map<std::string_view, int> intsTmp;
|
extern std::unordered_map<std::string_view, int> intsTmp;
|
||||||
|
|
||||||
const vector<string> valid_graph_symbols = { "braille", "block", "tty" };
|
const vector<string> valid_graph_symbols = { "braille", "block", "tty" };
|
||||||
const vector<string> valid_graph_symbols_def = { "default", "braille", "block", "tty" };
|
const vector<string> valid_graph_symbols_def = { "default", "braille", "block", "tty" };
|
||||||
|
@ -22,6 +22,7 @@ tab-size = 4
|
|||||||
#include <ranges>
|
#include <ranges>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
#include "btop_draw.hpp"
|
#include "btop_draw.hpp"
|
||||||
#include "btop_config.hpp"
|
#include "btop_config.hpp"
|
||||||
@ -54,7 +55,7 @@ namespace Symbols {
|
|||||||
|
|
||||||
const array<string, 10> superscript = { "⁰", "¹", "²", "³", "⁴", "⁵", "⁶", "⁷", "⁸", "⁹" };
|
const array<string, 10> superscript = { "⁰", "¹", "²", "³", "⁴", "⁵", "⁶", "⁷", "⁸", "⁹" };
|
||||||
|
|
||||||
const unordered_flat_map<string, vector<string>> graph_symbols = {
|
const std::unordered_map<string, vector<string>> graph_symbols = {
|
||||||
{ "braille_up", {
|
{ "braille_up", {
|
||||||
" ", "⢀", "⢠", "⢰", "⢸",
|
" ", "⢀", "⢠", "⢰", "⢸",
|
||||||
"⡀", "⣀", "⣠", "⣰", "⣸",
|
"⡀", "⣀", "⣠", "⣰", "⣸",
|
||||||
@ -300,7 +301,7 @@ namespace Draw {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const unordered_flat_map<string, string> clock_custom_format = {
|
static const std::unordered_map<string, string> clock_custom_format = {
|
||||||
{"/user", Tools::username()},
|
{"/user", Tools::username()},
|
||||||
{"/host", Tools::hostname()},
|
{"/host", Tools::hostname()},
|
||||||
{"/uptime", ""}
|
{"/uptime", ""}
|
||||||
@ -560,12 +561,12 @@ namespace Cpu {
|
|||||||
const string& title_left = Theme::c("cpu_box") + (cpu_bottom ? Symbols::title_left_down : Symbols::title_left);
|
const string& title_left = Theme::c("cpu_box") + (cpu_bottom ? Symbols::title_left_down : Symbols::title_left);
|
||||||
const string& title_right = Theme::c("cpu_box") + (cpu_bottom ? Symbols::title_right_down : Symbols::title_right);
|
const string& title_right = Theme::c("cpu_box") + (cpu_bottom ? Symbols::title_right_down : Symbols::title_right);
|
||||||
static int bat_pos = 0, bat_len = 0;
|
static int bat_pos = 0, bat_len = 0;
|
||||||
if (cpu.cpu_percent.at("total").empty()
|
if (safeVal(cpu.cpu_percent, "total"s).empty()
|
||||||
or cpu.core_percent.at(0).empty()
|
or safeVal(cpu.core_percent, 0).empty()
|
||||||
or (show_temps and cpu.temp.at(0).empty())) return "";
|
or (show_temps and safeVal(cpu.temp, 0).empty())) return "";
|
||||||
if (cpu.cpu_percent.at("total").empty()
|
if (safeVal(cpu.cpu_percent, "total"s).empty()
|
||||||
or cpu.core_percent.at(0).empty()
|
or safeVal(cpu.core_percent, 0).empty()
|
||||||
or (show_temps and cpu.temp.at(0).empty())) return "";
|
or (show_temps and safeVal(cpu.temp, 0).empty())) return "";
|
||||||
string out;
|
string out;
|
||||||
out.reserve(width * height);
|
out.reserve(width * height);
|
||||||
|
|
||||||
@ -608,7 +609,7 @@ namespace Cpu {
|
|||||||
if (gpu.supported_functions.temp_info)
|
if (gpu.supported_functions.temp_info)
|
||||||
gpu_temp_graphs[i] = Draw::Graph{ 5, 1, "temp", gpu.temp, graph_symbol, false, false, gpu.temp_max, -23 };
|
gpu_temp_graphs[i] = Draw::Graph{ 5, 1, "temp", gpu.temp, graph_symbol, false, false, gpu.temp_max, -23 };
|
||||||
if (gpu.supported_functions.mem_used and gpu.supported_functions.mem_total)
|
if (gpu.supported_functions.mem_used and gpu.supported_functions.mem_total)
|
||||||
gpu_mem_graphs[i] = Draw::Graph{ 5, 1, "used", gpu.gpu_percent.at("gpu-vram-totals"), graph_symbol };
|
gpu_mem_graphs[i] = Draw::Graph{ 5, 1, "used", safeVal(gpu.gpu_percent, "gpu-vram-totals"s), graph_symbol };
|
||||||
if (gpu.supported_functions.gpu_utilization) {
|
if (gpu.supported_functions.gpu_utilization) {
|
||||||
gpu_meter_width = b_width - 12 - (int)floating_humanizer(gpu.mem_total, true).size() - (show_temps ? 24 : 12) - (int)to_string(i).size() + (gpus.size() == 1)*2 - (gpus.size() > 9 and i <= 9);
|
gpu_meter_width = b_width - 12 - (int)floating_humanizer(gpu.mem_total, true).size() - (show_temps ? 24 : 12) - (int)to_string(i).size() + (gpus.size() == 1)*2 - (gpus.size() > 9 and i <= 9);
|
||||||
gpu_meters[i] = Draw::Meter{gpu_meter_width, "cpu" };
|
gpu_meters[i] = Draw::Meter{gpu_meter_width, "cpu" };
|
||||||
@ -617,12 +618,12 @@ namespace Cpu {
|
|||||||
bool utilization_support = gpu.supported_functions.gpu_utilization;
|
bool utilization_support = gpu.supported_functions.gpu_utilization;
|
||||||
if (++i < gpus.size()) {
|
if (++i < gpus.size()) {
|
||||||
if (utilization_support)
|
if (utilization_support)
|
||||||
graph = Draw::Graph{graph_width, graph_height, "cpu", gpu.gpu_percent.at(graph_field), graph_symbol, invert, true};
|
graph = Draw::Graph{graph_width, graph_height, "cpu", safeVal(gpu.gpu_percent, graph_field), graph_symbol, invert, true};
|
||||||
} else {
|
} else {
|
||||||
if (utilization_support)
|
if (utilization_support)
|
||||||
graph = Draw::Graph{
|
graph = Draw::Graph{
|
||||||
graph_width + graph_default_width%graph_width - (int)gpus.size() + 1,
|
graph_width + graph_default_width%graph_width - (int)gpus.size() + 1,
|
||||||
graph_height, "cpu", gpu.gpu_percent.at(graph_field), graph_symbol, invert, true
|
graph_height, "cpu", safeVal(gpu.gpu_percent, graph_field), graph_symbol, invert, true
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -630,7 +631,7 @@ namespace Cpu {
|
|||||||
} else {
|
} else {
|
||||||
graphs.resize(1);
|
graphs.resize(1);
|
||||||
graph_width = graph_default_width;
|
graph_width = graph_default_width;
|
||||||
graphs[0] = Draw::Graph{ graph_width, graph_height, "cpu", Gpu::shared_gpu_percent.at(graph_field), graph_symbol, invert, true };
|
graphs[0] = Draw::Graph{ graph_width, graph_height, "cpu", safeVal(Gpu::shared_gpu_percent, graph_field), graph_symbol, invert, true };
|
||||||
gpu_temp_graphs.resize(gpus.size());
|
gpu_temp_graphs.resize(gpus.size());
|
||||||
gpu_mem_graphs.resize(gpus.size());
|
gpu_mem_graphs.resize(gpus.size());
|
||||||
gpu_meters.resize(gpus.size());
|
gpu_meters.resize(gpus.size());
|
||||||
@ -638,7 +639,7 @@ namespace Cpu {
|
|||||||
if (gpus[i].supported_functions.temp_info)
|
if (gpus[i].supported_functions.temp_info)
|
||||||
gpu_temp_graphs[i] = Draw::Graph{ 5, 1, "temp", gpus[i].temp, graph_symbol, false, false, gpus[i].temp_max, -23 };
|
gpu_temp_graphs[i] = Draw::Graph{ 5, 1, "temp", gpus[i].temp, graph_symbol, false, false, gpus[i].temp_max, -23 };
|
||||||
if (gpus[i].supported_functions.mem_used and gpus[i].supported_functions.mem_total)
|
if (gpus[i].supported_functions.mem_used and gpus[i].supported_functions.mem_total)
|
||||||
gpu_mem_graphs[i] = Draw::Graph{ 5, 1, "used", gpus[i].gpu_percent.at("gpu-vram-totals"), graph_symbol };
|
gpu_mem_graphs[i] = Draw::Graph{ 5, 1, "used", safeVal(gpus[i].gpu_percent, "gpu-vram-totals"s), graph_symbol };
|
||||||
if (gpus[i].supported_functions.gpu_utilization) {
|
if (gpus[i].supported_functions.gpu_utilization) {
|
||||||
gpu_meter_width = b_width - 12 - (int)floating_humanizer(gpus[i].mem_total, true).size() - (show_temps ? 24 : 12) - (int)to_string(i).size() + (gpus.size() == 1)*2 - (gpus.size() > 9 and i <= 9);
|
gpu_meter_width = b_width - 12 - (int)floating_humanizer(gpus[i].mem_total, true).size() - (show_temps ? 24 : 12) - (int)to_string(i).size() + (gpus.size() == 1)*2 - (gpus.size() > 9 and i <= 9);
|
||||||
gpu_meters[i] = Draw::Meter{gpu_meter_width, "cpu" };
|
gpu_meters[i] = Draw::Meter{gpu_meter_width, "cpu" };
|
||||||
@ -649,7 +650,7 @@ namespace Cpu {
|
|||||||
#endif
|
#endif
|
||||||
graphs.resize(1);
|
graphs.resize(1);
|
||||||
graph_width = graph_default_width;
|
graph_width = graph_default_width;
|
||||||
graphs[0] = Draw::Graph{ graph_width, graph_height, "cpu", cpu.cpu_percent.at(graph_field), graph_symbol, invert, true };
|
graphs[0] = Draw::Graph{ graph_width, graph_height, "cpu", safeVal(cpu.cpu_percent, graph_field), graph_symbol, invert, true };
|
||||||
#ifdef GPU_SUPPORT
|
#ifdef GPU_SUPPORT
|
||||||
if (std::cmp_less(Gpu::shown, gpus.size())) {
|
if (std::cmp_less(Gpu::shown, gpus.size())) {
|
||||||
gpu_temp_graphs.resize(gpus.size());
|
gpu_temp_graphs.resize(gpus.size());
|
||||||
@ -659,7 +660,7 @@ namespace Cpu {
|
|||||||
if (gpus[i].supported_functions.temp_info)
|
if (gpus[i].supported_functions.temp_info)
|
||||||
gpu_temp_graphs[i] = Draw::Graph{ 5, 1, "temp", gpus[i].temp, graph_symbol, false, false, gpus[i].temp_max, -23 };
|
gpu_temp_graphs[i] = Draw::Graph{ 5, 1, "temp", gpus[i].temp, graph_symbol, false, false, gpus[i].temp_max, -23 };
|
||||||
if (gpus[i].supported_functions.mem_used and gpus[i].supported_functions.mem_total)
|
if (gpus[i].supported_functions.mem_used and gpus[i].supported_functions.mem_total)
|
||||||
gpu_mem_graphs[i] = Draw::Graph{ 5, 1, "used", gpus[i].gpu_percent.at("gpu-vram-totals"), graph_symbol };
|
gpu_mem_graphs[i] = Draw::Graph{ 5, 1, "used", safeVal(gpus[i].gpu_percent, "gpu-vram-totals"s), graph_symbol };
|
||||||
if (gpus[i].supported_functions.gpu_utilization) {
|
if (gpus[i].supported_functions.gpu_utilization) {
|
||||||
gpu_meter_width = b_width - 12 - (int)floating_humanizer(gpus[i].mem_total, true).size() - (show_temps ? 24 : 12) - (int)to_string(i).size() + (gpus.size() == 1)*2 - (gpus.size() > 9 and i <= 9);
|
gpu_meter_width = b_width - 12 - (int)floating_humanizer(gpus[i].mem_total, true).size() - (show_temps ? 24 : 12) - (int)to_string(i).size() + (gpus.size() == 1)*2 - (gpus.size() > 9 and i <= 9);
|
||||||
gpu_meters[i] = Draw::Meter{gpu_meter_width, "cpu" };
|
gpu_meters[i] = Draw::Meter{gpu_meter_width, "cpu" };
|
||||||
@ -692,10 +693,10 @@ namespace Cpu {
|
|||||||
|
|
||||||
if (show_temps) {
|
if (show_temps) {
|
||||||
temp_graphs.clear();
|
temp_graphs.clear();
|
||||||
temp_graphs.emplace_back(5, 1, "temp", cpu.temp.at(0), graph_symbol, false, false, cpu.temp_max, -23);
|
temp_graphs.emplace_back(5, 1, "temp", safeVal(cpu.temp, 0), graph_symbol, false, false, cpu.temp_max, -23);
|
||||||
if (not hide_cores and b_column_size > 1) {
|
if (not hide_cores and b_column_size > 1) {
|
||||||
for (const auto& i : iota((size_t)1, cpu.temp.size())) {
|
for (const auto& i : iota((size_t)1, cpu.temp.size())) {
|
||||||
temp_graphs.emplace_back(5, 1, "temp", cpu.temp.at(i), graph_symbol, false, false, cpu.temp_max, -23);
|
temp_graphs.emplace_back(5, 1, "temp", safeVal(cpu.temp, i), graph_symbol, false, false, cpu.temp_max, -23);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -707,7 +708,7 @@ namespace Cpu {
|
|||||||
static long old_seconds{}; // defaults to = 0
|
static long old_seconds{}; // defaults to = 0
|
||||||
static string old_status;
|
static string old_status;
|
||||||
static Draw::Meter bat_meter {10, "cpu", true};
|
static Draw::Meter bat_meter {10, "cpu", true};
|
||||||
static const unordered_flat_map<string, string> bat_symbols = {
|
static const std::unordered_map<string, string> bat_symbols = {
|
||||||
{"charging", "▲"},
|
{"charging", "▲"},
|
||||||
{"discharging", "▼"},
|
{"discharging", "▼"},
|
||||||
{"full", "■"},
|
{"full", "■"},
|
||||||
@ -749,7 +750,7 @@ namespace Cpu {
|
|||||||
if (graph_field.starts_with("gpu"))
|
if (graph_field.starts_with("gpu"))
|
||||||
if (graph_field.find("totals") != string::npos)
|
if (graph_field.find("totals") != string::npos)
|
||||||
for (unsigned long i = 0;;) {
|
for (unsigned long i = 0;;) {
|
||||||
out += graphs[i](gpus[i].gpu_percent.at(graph_field), (data_same or redraw));
|
out += graphs[i](safeVal(gpus[i].gpu_percent, graph_field), (data_same or redraw));
|
||||||
if (gpus.size() > 1) {
|
if (gpus.size() > 1) {
|
||||||
auto i_str = to_string(i);
|
auto i_str = to_string(i);
|
||||||
out += Mv::l(graph_width-1) + Mv::u(graph_height/2) + (graph_width > 5 ? "GPU " : "") + i_str
|
out += Mv::l(graph_width-1) + Mv::u(graph_height/2) + (graph_width > 5 ? "GPU " : "") + i_str
|
||||||
@ -761,13 +762,13 @@ namespace Cpu {
|
|||||||
else break;
|
else break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
out += graphs[0](Gpu::shared_gpu_percent.at(graph_field), (data_same or redraw));
|
out += graphs[0](safeVal(Gpu::shared_gpu_percent, graph_field), (data_same or redraw));
|
||||||
else
|
else
|
||||||
#else
|
#else
|
||||||
(void)graph_height;
|
(void)graph_height;
|
||||||
(void)graph_width;
|
(void)graph_width;
|
||||||
#endif
|
#endif
|
||||||
out += graphs[0](cpu.cpu_percent.at(graph_field), (data_same or redraw));
|
out += graphs[0](safeVal(cpu.cpu_percent, graph_field), (data_same or redraw));
|
||||||
};
|
};
|
||||||
|
|
||||||
draw_graphs(graphs_upper, graph_up_height, graph_up_width, graph_up_field);
|
draw_graphs(graphs_upper, graph_up_height, graph_up_width, graph_up_field);
|
||||||
@ -792,14 +793,14 @@ namespace Cpu {
|
|||||||
out += Mv::to(b_y, b_x + b_width - 10) + Fx::ub + Theme::c("div_line") + Symbols::h_line * (7 - cpuHz.size())
|
out += Mv::to(b_y, b_x + b_width - 10) + Fx::ub + Theme::c("div_line") + Symbols::h_line * (7 - cpuHz.size())
|
||||||
+ Symbols::title_left + Fx::b + Theme::c("title") + cpuHz + Fx::ub + Theme::c("div_line") + Symbols::title_right;
|
+ Symbols::title_left + Fx::b + Theme::c("title") + cpuHz + Fx::ub + Theme::c("div_line") + Symbols::title_right;
|
||||||
|
|
||||||
out += Mv::to(b_y + 1, b_x + 1) + Theme::c("main_fg") + Fx::b + "CPU " + cpu_meter(cpu.cpu_percent.at("total").back())
|
out += Mv::to(b_y + 1, b_x + 1) + Theme::c("main_fg") + Fx::b + "CPU " + cpu_meter(safeVal(cpu.cpu_percent, "total"s).back())
|
||||||
+ Theme::g("cpu").at(clamp(cpu.cpu_percent.at("total").back(), 0ll, 100ll)) + rjust(to_string(cpu.cpu_percent.at("total").back()), 4) + Theme::c("main_fg") + '%';
|
+ Theme::g("cpu").at(clamp(safeVal(cpu.cpu_percent, "total"s).back(), 0ll, 100ll)) + rjust(to_string(safeVal(cpu.cpu_percent, "total"s).back()), 4) + Theme::c("main_fg") + '%';
|
||||||
if (show_temps) {
|
if (show_temps) {
|
||||||
const auto [temp, unit] = celsius_to(cpu.temp.at(0).back(), temp_scale);
|
const auto [temp, unit] = celsius_to(safeVal(cpu.temp, 0).back(), temp_scale);
|
||||||
const auto& temp_color = Theme::g("temp").at(clamp(cpu.temp.at(0).back() * 100 / cpu.temp_max, 0ll, 100ll));
|
const auto& temp_color = Theme::g("temp").at(clamp(safeVal(cpu.temp, 0).back() * 100 / cpu.temp_max, 0ll, 100ll));
|
||||||
if (b_column_size > 1 or b_columns > 1)
|
if ((b_column_size > 1 or b_columns > 1) and temp_graphs.size() >= 1ll)
|
||||||
out += ' ' + Theme::c("inactive_fg") + graph_bg * 5 + Mv::l(5) + temp_color
|
out += ' ' + Theme::c("inactive_fg") + graph_bg * 5 + Mv::l(5) + temp_color
|
||||||
+ temp_graphs.at(0)(cpu.temp.at(0), data_same or redraw);
|
+ temp_graphs.at(0)(safeVal(cpu.temp, 0), data_same or redraw);
|
||||||
out += rjust(to_string(temp), 4) + Theme::c("main_fg") + unit;
|
out += rjust(to_string(temp), 4) + Theme::c("main_fg") + unit;
|
||||||
}
|
}
|
||||||
out += Theme::c("div_line") + Symbols::v_line;
|
out += Theme::c("div_line") + Symbols::v_line;
|
||||||
@ -810,21 +811,22 @@ namespace Cpu {
|
|||||||
int cx = 0, cy = 1, cc = 0, core_width = (b_column_size == 0 ? 2 : 3);
|
int cx = 0, cy = 1, cc = 0, core_width = (b_column_size == 0 ? 2 : 3);
|
||||||
if (Shared::coreCount >= 100) core_width++;
|
if (Shared::coreCount >= 100) core_width++;
|
||||||
for (const auto& n : iota(0, Shared::coreCount)) {
|
for (const auto& n : iota(0, Shared::coreCount)) {
|
||||||
|
if (cmp_less(core_graphs.size(), n+1)) break;
|
||||||
out += Mv::to(b_y + cy + 1, b_x + cx + 1) + Theme::c("main_fg") + (Shared::coreCount < 100 ? Fx::b + 'C' + Fx::ub : "")
|
out += Mv::to(b_y + cy + 1, b_x + cx + 1) + Theme::c("main_fg") + (Shared::coreCount < 100 ? Fx::b + 'C' + Fx::ub : "")
|
||||||
+ ljust(to_string(n), core_width);
|
+ ljust(to_string(n), core_width);
|
||||||
if (b_column_size > 0 or extra_width > 0)
|
if (b_column_size > 0 or extra_width > 0)
|
||||||
out += Theme::c("inactive_fg") + graph_bg * (5 * b_column_size + extra_width) + Mv::l(5 * b_column_size + extra_width)
|
out += Theme::c("inactive_fg") + graph_bg * (5 * b_column_size + extra_width) + Mv::l(5 * b_column_size + extra_width)
|
||||||
+ core_graphs.at(n)(cpu.core_percent.at(n), data_same or redraw);
|
+ core_graphs.at(n)(safeVal(cpu.core_percent, n), data_same or redraw);
|
||||||
|
|
||||||
out += Theme::g("cpu").at(clamp(cpu.core_percent.at(n).back(), 0ll, 100ll));
|
out += Theme::g("cpu").at(clamp(safeVal(cpu.core_percent, n).back(), 0ll, 100ll));
|
||||||
out += rjust(to_string(cpu.core_percent.at(n).back()), (b_column_size < 2 ? 3 : 4)) + Theme::c("main_fg") + '%';
|
out += rjust(to_string(safeVal(cpu.core_percent, n).back()), (b_column_size < 2 ? 3 : 4)) + Theme::c("main_fg") + '%';
|
||||||
|
|
||||||
if (show_temps and not hide_cores) {
|
if (show_temps and not hide_cores and std::cmp_greater_equal(temp_graphs.size(), n)) {
|
||||||
const auto [temp, unit] = celsius_to(cpu.temp.at(n+1).back(), temp_scale);
|
const auto [temp, unit] = celsius_to(safeVal(cpu.temp, n+1).back(), temp_scale);
|
||||||
const auto& temp_color = Theme::g("temp").at(clamp(cpu.temp.at(n+1).back() * 100 / cpu.temp_max, 0ll, 100ll));
|
const auto& temp_color = Theme::g("temp").at(clamp(safeVal(cpu.temp, n+1).back() * 100 / cpu.temp_max, 0ll, 100ll));
|
||||||
if (b_column_size > 1)
|
if (b_column_size > 1)
|
||||||
out += ' ' + Theme::c("inactive_fg") + graph_bg * 5 + Mv::l(5)
|
out += ' ' + Theme::c("inactive_fg") + graph_bg * 5 + Mv::l(5)
|
||||||
+ temp_graphs.at(n+1)(cpu.temp.at(n+1), data_same or redraw);
|
+ temp_graphs.at(n+1)(safeVal(cpu.temp, n+1), data_same or redraw);
|
||||||
out += temp_color + rjust(to_string(temp), 4) + Theme::c("main_fg") + unit;
|
out += temp_color + rjust(to_string(temp), 4) + Theme::c("main_fg") + unit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -882,14 +884,14 @@ namespace Cpu {
|
|||||||
}
|
}
|
||||||
if (gpus.size() > 1) out += rjust(to_string(i), 1 + (gpus.size() > 9));
|
if (gpus.size() > 1) out += rjust(to_string(i), 1 + (gpus.size() > 9));
|
||||||
if (gpus[i].supported_functions.gpu_utilization) {
|
if (gpus[i].supported_functions.gpu_utilization) {
|
||||||
string meter = gpu_meters[i](gpus[i].gpu_percent.at("gpu-totals").back());
|
string meter = gpu_meters[i](safeVal(gpus[i].gpu_percent, "gpu-totals"s).back());
|
||||||
out += (meter.size() > 1 ? " " : "") + meter
|
out += (meter.size() > 1 ? " " : "") + meter
|
||||||
+ Theme::g("cpu").at(gpus[i].gpu_percent.at("gpu-totals").back()) + rjust(to_string(gpus[i].gpu_percent.at("gpu-totals").back()), 4) + Theme::c("main_fg") + '%';
|
+ Theme::g("cpu").at(clamp(safeVal(gpus[i].gpu_percent, "gpu-totals"s).back(), 0ll, 100ll)) + rjust(to_string(safeVal(gpus[i].gpu_percent, "gpu-totals"s).back()), 4) + Theme::c("main_fg") + '%';
|
||||||
} else out += Mv::r(gpu_meter_width);
|
} else out += Mv::r(gpu_meter_width);
|
||||||
|
|
||||||
if (gpus[i].supported_functions.mem_used) {
|
if (gpus[i].supported_functions.mem_used) {
|
||||||
out += ' ' + Theme::c("inactive_fg") + graph_bg * 6 + Mv::l(6) + Theme::g("used").at(gpus[i].gpu_percent.at("gpu-vram-totals").back())
|
out += ' ' + Theme::c("inactive_fg") + graph_bg * 6 + Mv::l(6) + Theme::g("used").at(safeVal(gpus[i].gpu_percent, "gpu-vram-totals"s).back())
|
||||||
+ gpu_mem_graphs[i](gpus[i].gpu_percent.at("gpu-vram-totals"), data_same or redraw) + Theme::c("main_fg")
|
+ gpu_mem_graphs[i](safeVal(gpus[i].gpu_percent, "gpu-vram-totals"s), data_same or redraw) + Theme::c("main_fg")
|
||||||
+ rjust(floating_humanizer(gpus[i].mem_used, true), 5);
|
+ rjust(floating_humanizer(gpus[i].mem_used, true), 5);
|
||||||
if (gpus[i].supported_functions.mem_total)
|
if (gpus[i].supported_functions.mem_total)
|
||||||
out += Theme::c("inactive_fg") + '/' + Theme::c("main_fg") + floating_humanizer(gpus[i].mem_total, true);
|
out += Theme::c("inactive_fg") + '/' + Theme::c("main_fg") + floating_humanizer(gpus[i].mem_total, true);
|
||||||
@ -967,12 +969,12 @@ namespace Gpu {
|
|||||||
out += box[index];
|
out += box[index];
|
||||||
|
|
||||||
if (gpu.supported_functions.gpu_utilization) {
|
if (gpu.supported_functions.gpu_utilization) {
|
||||||
graph_upper = Draw::Graph{x + width - b_width - 3, graph_up_height, "cpu", gpu.gpu_percent.at("gpu-totals"), graph_symbol, false, true}; // TODO cpu -> gpu
|
graph_upper = Draw::Graph{x + width - b_width - 3, graph_up_height, "cpu", safeVal(gpu.gpu_percent, "gpu-totals"s), graph_symbol, false, true}; // TODO cpu -> gpu
|
||||||
if (not single_graph) {
|
if (not single_graph) {
|
||||||
graph_lower = Draw::Graph{
|
graph_lower = Draw::Graph{
|
||||||
x + width - b_width - 3,
|
x + width - b_width - 3,
|
||||||
graph_low_height, "cpu",
|
graph_low_height, "cpu",
|
||||||
gpu.gpu_percent.at("gpu-totals"),
|
safeVal(gpu.gpu_percent, "gpu-totals"s),
|
||||||
graph_symbol,
|
graph_symbol,
|
||||||
Config::getB("cpu_invert_lower"), true
|
Config::getB("cpu_invert_lower"), true
|
||||||
};
|
};
|
||||||
@ -986,7 +988,7 @@ namespace Gpu {
|
|||||||
if (gpu.supported_functions.mem_utilization)
|
if (gpu.supported_functions.mem_utilization)
|
||||||
mem_util_graph = Draw::Graph{b_width/2 - 1, 2, "free", gpu.mem_utilization_percent, graph_symbol, 0, 0, 100, 4}; // offset so the graph isn't empty at 0-5% utilization
|
mem_util_graph = Draw::Graph{b_width/2 - 1, 2, "free", gpu.mem_utilization_percent, graph_symbol, 0, 0, 100, 4}; // offset so the graph isn't empty at 0-5% utilization
|
||||||
if (gpu.supported_functions.mem_used and gpu.supported_functions.mem_total)
|
if (gpu.supported_functions.mem_used and gpu.supported_functions.mem_total)
|
||||||
mem_used_graph = Draw::Graph{b_width/2 - 2, 2 + 2*(gpu.supported_functions.mem_utilization), "used", gpu.gpu_percent.at("gpu-vram-totals"), graph_symbol};
|
mem_used_graph = Draw::Graph{b_width/2 - 2, 2 + 2*(gpu.supported_functions.mem_utilization), "used", safeVal(gpu.gpu_percent, "gpu-vram-totals"s), graph_symbol};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -994,12 +996,12 @@ namespace Gpu {
|
|||||||
|
|
||||||
//? Gpu graph, meter & clock speed
|
//? Gpu graph, meter & clock speed
|
||||||
if (gpu.supported_functions.gpu_utilization) {
|
if (gpu.supported_functions.gpu_utilization) {
|
||||||
out += Fx::ub + Mv::to(y + 1, x + 1) + graph_upper(gpu.gpu_percent.at("gpu-totals"), (data_same or redraw[index]));
|
out += Fx::ub + Mv::to(y + 1, x + 1) + graph_upper(safeVal(gpu.gpu_percent, "gpu-totals"s), (data_same or redraw[index]));
|
||||||
if (not single_graph)
|
if (not single_graph)
|
||||||
out += Mv::to(y + graph_up_height + 1, x + 1) + graph_lower(gpu.gpu_percent.at("gpu-totals"), (data_same or redraw[index]));
|
out += Mv::to(y + graph_up_height + 1, x + 1) + graph_lower(safeVal(gpu.gpu_percent, "gpu-totals"s), (data_same or redraw[index]));
|
||||||
|
|
||||||
out += Mv::to(b_y + 1, b_x + 1) + Theme::c("main_fg") + Fx::b + "GPU " + gpu_meter(gpu.gpu_percent.at("gpu-totals").back())
|
out += Mv::to(b_y + 1, b_x + 1) + Theme::c("main_fg") + Fx::b + "GPU " + gpu_meter(safeVal(gpu.gpu_percent, "gpu-totals"s).back())
|
||||||
+ Theme::g("cpu").at(gpu.gpu_percent.at("gpu-totals").back()) + rjust(to_string(gpu.gpu_percent.at("gpu-totals").back()), 4) + Theme::c("main_fg") + '%';
|
+ Theme::g("cpu").at(clamp(safeVal(gpu.gpu_percent, "gpu-totals"s).back(), 0ll, 100ll)) + rjust(to_string(safeVal(gpu.gpu_percent, "gpu-totals"s).back()), 4) + Theme::c("main_fg") + '%';
|
||||||
|
|
||||||
//? Temperature graph, I assume the device supports utilization if it supports temperature
|
//? Temperature graph, I assume the device supports utilization if it supports temperature
|
||||||
if (show_temps) {
|
if (show_temps) {
|
||||||
@ -1019,10 +1021,10 @@ namespace Gpu {
|
|||||||
|
|
||||||
//? Power usage meter, power state
|
//? Power usage meter, power state
|
||||||
if (gpu.supported_functions.pwr_usage) {
|
if (gpu.supported_functions.pwr_usage) {
|
||||||
out += Mv::to(b_y + 2, b_x + 1) + Theme::c("main_fg") + Fx::b + "PWR " + pwr_meter(gpu.gpu_percent.at("gpu-pwr-totals").back())
|
out += Mv::to(b_y + 2, b_x + 1) + Theme::c("main_fg") + Fx::b + "PWR " + pwr_meter(safeVal(gpu.gpu_percent, "gpu-pwr-totals"s).back())
|
||||||
+ Theme::g("cached").at(gpu.gpu_percent.at("gpu-pwr-totals").back()) + rjust(to_string(gpu.pwr_usage/1000), 4) + Theme::c("main_fg") + 'W';
|
+ Theme::g("cached").at(clamp(safeVal(gpu.gpu_percent, "gpu-pwr-totals"s).back(), 0ll, 100ll)) + rjust(to_string(gpu.pwr_usage/1000), 4) + Theme::c("main_fg") + 'W';
|
||||||
if (gpu.supported_functions.pwr_state and gpu.pwr_state != 32) // NVML_PSTATE_UNKNOWN; unsupported or non-nvidia card
|
if (gpu.supported_functions.pwr_state and gpu.pwr_state != 32) // NVML_PSTATE_UNKNOWN; unsupported or non-nvidia card
|
||||||
out += std::string(" P-state: ") + (gpu.pwr_state > 9 ? "" : " ") + 'P' + Theme::g("cached").at(gpu.pwr_state) + to_string(gpu.pwr_state);
|
out += std::string(" P-state: ") + (gpu.pwr_state > 9 ? "" : " ") + 'P' + Theme::g("cached").at(clamp(gpu.pwr_state, 0ll, 100ll)) + to_string(gpu.pwr_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gpu.supported_functions.mem_total or gpu.supported_functions.mem_used) {
|
if (gpu.supported_functions.mem_total or gpu.supported_functions.mem_used) {
|
||||||
@ -1038,9 +1040,9 @@ namespace Gpu {
|
|||||||
+ Symbols::h_line*(b_width/2-8) + Symbols::div_up + Mv::d(offset)+Mv::l(1) + Symbols::div_down + Mv::l(1)+Mv::u(1) + (Symbols::v_line + Mv::l(1)+Mv::u(1))*(offset-1) + Symbols::div_up
|
+ Symbols::h_line*(b_width/2-8) + Symbols::div_up + Mv::d(offset)+Mv::l(1) + Symbols::div_down + Mv::l(1)+Mv::u(1) + (Symbols::v_line + Mv::l(1)+Mv::u(1))*(offset-1) + Symbols::div_up
|
||||||
+ Symbols::h_line + Theme::c("title") + "Used:" + Theme::c("div_line")
|
+ Symbols::h_line + Theme::c("title") + "Used:" + Theme::c("div_line")
|
||||||
+ Symbols::h_line*(b_width/2+b_width%2-9-used_memory_string.size()) + Theme::c("title") + used_memory_string + Theme::c("div_line") + Symbols::h_line + Symbols::div_right
|
+ Symbols::h_line*(b_width/2+b_width%2-9-used_memory_string.size()) + Theme::c("title") + used_memory_string + Theme::c("div_line") + Symbols::h_line + Symbols::div_right
|
||||||
+ Mv::d(1) + Mv::l(b_width/2-1) + mem_used_graph(gpu.gpu_percent.at("gpu-vram-totals"), (data_same or redraw[index]))
|
+ Mv::d(1) + Mv::l(b_width/2-1) + mem_used_graph(safeVal(gpu.gpu_percent, "gpu-vram-totals"s), (data_same or redraw[index]))
|
||||||
+ Mv::l(b_width-3) + Mv::u(1+2*gpu.supported_functions.mem_utilization) + Theme::c("main_fg") + Fx::b + "Total:" + rjust(floating_humanizer(gpu.mem_total), b_width/2-9) + Fx::ub
|
+ Mv::l(b_width-3) + Mv::u(1+2*gpu.supported_functions.mem_utilization) + Theme::c("main_fg") + Fx::b + "Total:" + rjust(floating_humanizer(gpu.mem_total), b_width/2-9) + Fx::ub
|
||||||
+ Mv::r(3) + rjust(to_string(gpu.gpu_percent.at("gpu-vram-totals").back()), 3) + '%';
|
+ Mv::r(3) + rjust(to_string(safeVal(gpu.gpu_percent, "gpu-vram-totals"s).back()), 3) + '%';
|
||||||
|
|
||||||
//? Memory utilization
|
//? Memory utilization
|
||||||
if (gpu.supported_functions.mem_utilization)
|
if (gpu.supported_functions.mem_utilization)
|
||||||
@ -1096,11 +1098,11 @@ namespace Mem {
|
|||||||
int disks_io_half = 0;
|
int disks_io_half = 0;
|
||||||
bool shown = true, redraw = true;
|
bool shown = true, redraw = true;
|
||||||
string box;
|
string box;
|
||||||
unordered_flat_map<string, Draw::Meter> mem_meters;
|
std::unordered_map<string, Draw::Meter> mem_meters;
|
||||||
unordered_flat_map<string, Draw::Graph> mem_graphs;
|
std::unordered_map<string, Draw::Graph> mem_graphs;
|
||||||
unordered_flat_map<string, Draw::Meter> disk_meters_used;
|
std::unordered_map<string, Draw::Meter> disk_meters_used;
|
||||||
unordered_flat_map<string, Draw::Meter> disk_meters_free;
|
std::unordered_map<string, Draw::Meter> disk_meters_free;
|
||||||
unordered_flat_map<string, Draw::Graph> io_graphs;
|
std::unordered_map<string, Draw::Graph> io_graphs;
|
||||||
|
|
||||||
string draw(const mem_info& mem, bool force_redraw, bool data_same) {
|
string draw(const mem_info& mem, bool force_redraw, bool data_same) {
|
||||||
if (Runner::stopping) return "";
|
if (Runner::stopping) return "";
|
||||||
@ -1132,14 +1134,14 @@ namespace Mem {
|
|||||||
for (const auto& name : mem_names) {
|
for (const auto& name : mem_names) {
|
||||||
|
|
||||||
if (use_graphs)
|
if (use_graphs)
|
||||||
mem_graphs[name] = Draw::Graph{mem_meter, graph_height, name, mem.percent.at(name), graph_symbol};
|
mem_graphs[name] = Draw::Graph{mem_meter, graph_height, name, safeVal(mem.percent, name), graph_symbol};
|
||||||
else
|
else
|
||||||
mem_meters[name] = Draw::Meter{mem_meter, name};
|
mem_meters[name] = Draw::Meter{mem_meter, name};
|
||||||
}
|
}
|
||||||
if (show_swap and has_swap) {
|
if (show_swap and has_swap) {
|
||||||
for (const auto& name : swap_names) {
|
for (const auto& name : swap_names) {
|
||||||
if (use_graphs)
|
if (use_graphs)
|
||||||
mem_graphs[name] = Draw::Graph{mem_meter, graph_height, name.substr(5), mem.percent.at(name), graph_symbol};
|
mem_graphs[name] = Draw::Graph{mem_meter, graph_height, name.substr(5), safeVal(mem.percent, name), graph_symbol};
|
||||||
else
|
else
|
||||||
mem_meters[name] = Draw::Meter{mem_meter, name.substr(5)};
|
mem_meters[name] = Draw::Meter{mem_meter, name.substr(5)};
|
||||||
}
|
}
|
||||||
@ -1148,7 +1150,7 @@ namespace Mem {
|
|||||||
//? Disk meters and io graphs
|
//? Disk meters and io graphs
|
||||||
if (show_disks) {
|
if (show_disks) {
|
||||||
if (show_io_stat or io_mode) {
|
if (show_io_stat or io_mode) {
|
||||||
unordered_flat_map<string, int> custom_speeds;
|
std::unordered_map<string, int> custom_speeds;
|
||||||
int half_height = 0;
|
int half_height = 0;
|
||||||
if (io_mode) {
|
if (io_mode) {
|
||||||
disks_io_h = max((int)floor((double)(height - 2 - (disk_ios * 2)) / max(1, disk_ios)), (io_graph_combined ? 1 : 2));
|
disks_io_h = max((int)floor((double)(height - 2 - (disk_ios * 2)) / max(1, disk_ios)), (io_graph_combined ? 1 : 2));
|
||||||
@ -1230,7 +1232,7 @@ namespace Mem {
|
|||||||
if (graph_height > 0) out += Mv::to(y+1+cy, x+1+cx) + divider;
|
if (graph_height > 0) out += Mv::to(y+1+cy, x+1+cx) + divider;
|
||||||
cy += 1;
|
cy += 1;
|
||||||
}
|
}
|
||||||
out += Mv::to(y+1+cy, x+1+cx) + Theme::c("title") + Fx::b + "Swap:" + rjust(floating_humanizer(mem.stats.at("swap_total")), mem_width - 8)
|
out += Mv::to(y+1+cy, x+1+cx) + Theme::c("title") + Fx::b + "Swap:" + rjust(floating_humanizer(safeVal(mem.stats, "swap_total"s)), mem_width - 8)
|
||||||
+ Theme::c("main_fg") + Fx::ub;
|
+ Theme::c("main_fg") + Fx::ub;
|
||||||
cy += 1;
|
cy += 1;
|
||||||
title = "Used";
|
title = "Used";
|
||||||
@ -1239,13 +1241,16 @@ namespace Mem {
|
|||||||
title = "Free";
|
title = "Free";
|
||||||
|
|
||||||
if (title.empty()) title = capitalize(name);
|
if (title.empty()) title = capitalize(name);
|
||||||
const string humanized = floating_humanizer(mem.stats.at(name));
|
const string humanized = floating_humanizer(safeVal(mem.stats, name));
|
||||||
const int offset = max(0, divider.empty() ? 9 - (int)humanized.size() : 0);
|
const int offset = max(0, divider.empty() ? 9 - (int)humanized.size() : 0);
|
||||||
const string graphics = (use_graphs ? mem_graphs.at(name)(mem.percent.at(name), redraw or data_same) : mem_meters.at(name)(mem.percent.at(name).back()));
|
const string graphics = (
|
||||||
|
use_graphs and mem_graphs.contains(name) ? mem_graphs.at(name)(safeVal(mem.percent, name), redraw or data_same)
|
||||||
|
: mem_meters.contains(name) ? mem_meters.at(name)(safeVal(mem.percent, name).back())
|
||||||
|
: "");
|
||||||
if (mem_size > 2) {
|
if (mem_size > 2) {
|
||||||
out += Mv::to(y+1+cy, x+1+cx) + divider + title.substr(0, big_mem ? 10 : 5) + ":"
|
out += Mv::to(y+1+cy, x+1+cx) + divider + title.substr(0, big_mem ? 10 : 5) + ":"
|
||||||
+ Mv::to(y+1+cy, x+cx + mem_width - 2 - humanized.size()) + (divider.empty() ? Mv::l(offset) + string(" ") * offset + humanized : trans(humanized))
|
+ Mv::to(y+1+cy, x+cx + mem_width - 2 - humanized.size()) + (divider.empty() ? Mv::l(offset) + string(" ") * offset + humanized : trans(humanized))
|
||||||
+ Mv::to(y+2+cy, x+cx + (graph_height >= 2 ? 0 : 1)) + graphics + up + rjust(to_string(mem.percent.at(name).back()) + "%", 4);
|
+ Mv::to(y+2+cy, x+cx + (graph_height >= 2 ? 0 : 1)) + graphics + up + rjust(to_string(safeVal(mem.percent, name).back()) + "%", 4);
|
||||||
cy += (graph_height == 0 ? 2 : graph_height + 1);
|
cy += (graph_height == 0 ? 2 : graph_height + 1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -1268,7 +1273,7 @@ namespace Mem {
|
|||||||
for (const auto& mount : mem.disks_order) {
|
for (const auto& mount : mem.disks_order) {
|
||||||
if (not disks.contains(mount)) continue;
|
if (not disks.contains(mount)) continue;
|
||||||
if (cy > height - 3) break;
|
if (cy > height - 3) break;
|
||||||
const auto& disk = disks.at(mount);
|
const auto& disk = safeVal(disks, mount);
|
||||||
if (disk.io_read.empty()) continue;
|
if (disk.io_read.empty()) continue;
|
||||||
const string total = floating_humanizer(disk.total, not big_disk);
|
const string total = floating_humanizer(disk.total, not big_disk);
|
||||||
out += Mv::to(y+1+cy, x+1+cx) + divider + Theme::c("title") + Fx::b + uresize(disk.name, disks_width - 8) + Mv::to(y+1+cy, x+cx + disks_width - total.size())
|
out += Mv::to(y+1+cy, x+1+cx) + divider + Theme::c("title") + Fx::b + uresize(disk.name, disks_width - 8) + Mv::to(y+1+cy, x+cx + disks_width - total.size())
|
||||||
@ -1277,9 +1282,12 @@ namespace Mem {
|
|||||||
const string used_percent = to_string(disk.used_percent);
|
const string used_percent = to_string(disk.used_percent);
|
||||||
out += Mv::to(y+1+cy, x+1+cx + round((double)disks_width / 2) - round((double)used_percent.size() / 2) - 1) + hu_div + used_percent + '%' + hu_div;
|
out += Mv::to(y+1+cy, x+1+cx + round((double)disks_width / 2) - round((double)used_percent.size() / 2) - 1) + hu_div + used_percent + '%' + hu_div;
|
||||||
}
|
}
|
||||||
|
if (io_graphs.contains(mount + "_activity")) {
|
||||||
out += Mv::to(y+2+cy++, x+1+cx) + (big_disk ? " IO% " : " IO " + Mv::l(2)) + Theme::c("inactive_fg") + graph_bg * (disks_width - 6)
|
out += Mv::to(y+2+cy++, x+1+cx) + (big_disk ? " IO% " : " IO " + Mv::l(2)) + Theme::c("inactive_fg") + graph_bg * (disks_width - 6)
|
||||||
+ Mv::l(disks_width - 6) + io_graphs.at(mount + "_activity")(disk.io_activity, redraw or data_same) + Theme::c("main_fg");
|
+ Mv::l(disks_width - 6) + io_graphs.at(mount + "_activity")(disk.io_activity, redraw or data_same) + Theme::c("main_fg");
|
||||||
|
}
|
||||||
if (++cy > height - 3) break;
|
if (++cy > height - 3) break;
|
||||||
|
if (not io_graphs.contains(mount)) continue;
|
||||||
if (io_graph_combined) {
|
if (io_graph_combined) {
|
||||||
auto comb_val = disk.io_read.back() + disk.io_write.back();
|
auto comb_val = disk.io_read.back() + disk.io_write.back();
|
||||||
const string humanized = (disk.io_write.back() > 0 ? "▼"s : ""s) + (disk.io_read.back() > 0 ? "▲"s : ""s)
|
const string humanized = (disk.io_write.back() > 0 ? "▼"s : ""s) + (disk.io_read.back() > 0 ? "▲"s : ""s)
|
||||||
@ -1304,7 +1312,8 @@ namespace Mem {
|
|||||||
for (const auto& mount : mem.disks_order) {
|
for (const auto& mount : mem.disks_order) {
|
||||||
if (not disks.contains(mount)) continue;
|
if (not disks.contains(mount)) continue;
|
||||||
if (cy > height - 3) break;
|
if (cy > height - 3) break;
|
||||||
const auto& disk = disks.at(mount);
|
const auto& disk = safeVal(disks, mount);
|
||||||
|
if (disk.name.empty() or not disk_meters_used.contains(mount)) continue;
|
||||||
auto comb_val = (not disk.io_read.empty() ? disk.io_read.back() + disk.io_write.back() : 0ll);
|
auto comb_val = (not disk.io_read.empty() ? disk.io_read.back() + disk.io_write.back() : 0ll);
|
||||||
const string human_io = (comb_val > 0 ? (disk.io_write.back() > 0 and big_disk ? "▼"s : ""s) + (disk.io_read.back() > 0 and big_disk ? "▲"s : ""s)
|
const string human_io = (comb_val > 0 ? (disk.io_write.back() > 0 and big_disk ? "▼"s : ""s) + (disk.io_read.back() > 0 and big_disk ? "▲"s : ""s)
|
||||||
+ floating_humanizer(comb_val, true) : "");
|
+ floating_humanizer(comb_val, true) : "");
|
||||||
@ -1328,7 +1337,7 @@ namespace Mem {
|
|||||||
+ disk_meters_used.at(mount)(disk.used_percent) + rjust(human_used, (big_disk ? 9 : 5));
|
+ disk_meters_used.at(mount)(disk.used_percent) + rjust(human_used, (big_disk ? 9 : 5));
|
||||||
if (++cy > height - 3) break;
|
if (++cy > height - 3) break;
|
||||||
|
|
||||||
if (cmp_less_equal(disks.size() * 3 + (show_io_stat ? disk_ios : 0), height - 1)) {
|
if (disk_meters_free.contains(mount) and cmp_less_equal(disks.size() * 3 + (show_io_stat ? disk_ios : 0), height - 1)) {
|
||||||
out += Mv::to(y+1+cy, x+1+cx) + (big_disk ? " Free:" + rjust(to_string(disk.free_percent) + '%', 4) : "F") + ' '
|
out += Mv::to(y+1+cy, x+1+cx) + (big_disk ? " Free:" + rjust(to_string(disk.free_percent) + '%', 4) : "F") + ' '
|
||||||
+ disk_meters_free.at(mount)(disk.free_percent) + rjust(human_free, (big_disk ? 9 : 5));
|
+ disk_meters_free.at(mount)(disk.free_percent) + rjust(human_free, (big_disk ? 9 : 5));
|
||||||
cy++;
|
cy++;
|
||||||
@ -1353,7 +1362,7 @@ namespace Net {
|
|||||||
int b_x, b_y, b_width, b_height, d_graph_height, u_graph_height;
|
int b_x, b_y, b_width, b_height, d_graph_height, u_graph_height;
|
||||||
bool shown = true, redraw = true;
|
bool shown = true, redraw = true;
|
||||||
string old_ip;
|
string old_ip;
|
||||||
unordered_flat_map<string, Draw::Graph> graphs;
|
std::unordered_map<string, Draw::Graph> graphs;
|
||||||
string box;
|
string box;
|
||||||
|
|
||||||
string draw(const net_info& net, bool force_redraw, bool data_same) {
|
string draw(const net_info& net, bool force_redraw, bool data_same) {
|
||||||
@ -1373,15 +1382,15 @@ namespace Net {
|
|||||||
const string title_left = Theme::c("net_box") + Fx::ub + Symbols::title_left;
|
const string title_left = Theme::c("net_box") + Fx::ub + Symbols::title_left;
|
||||||
const string title_right = Theme::c("net_box") + Fx::ub + Symbols::title_right;
|
const string title_right = Theme::c("net_box") + Fx::ub + Symbols::title_right;
|
||||||
const int i_size = min((int)selected_iface.size(), 10);
|
const int i_size = min((int)selected_iface.size(), 10);
|
||||||
const long long down_max = (net_auto ? graph_max.at("download") : ((long long)(Config::getI("net_download")) << 20) / 8);
|
const long long down_max = (net_auto ? safeVal(graph_max, "download"s) : ((long long)(Config::getI("net_download")) << 20) / 8);
|
||||||
const long long up_max = (net_auto ? graph_max.at("upload") : ((long long)(Config::getI("net_upload")) << 20) / 8);
|
const long long up_max = (net_auto ? safeVal(graph_max, "upload"s) : ((long long)(Config::getI("net_upload")) << 20) / 8);
|
||||||
|
|
||||||
//* Redraw elements not needed to be updated every cycle
|
//* Redraw elements not needed to be updated every cycle
|
||||||
if (redraw) {
|
if (redraw) {
|
||||||
out = box;
|
out = box;
|
||||||
//? Graphs
|
//? Graphs
|
||||||
graphs.clear();
|
graphs.clear();
|
||||||
if (net.bandwidth.at("download").empty() or net.bandwidth.at("upload").empty())
|
if (safeVal(net.bandwidth, "download"s).empty() or safeVal(net.bandwidth, "upload"s).empty())
|
||||||
return out + Fx::reset;
|
return out + Fx::reset;
|
||||||
graphs["download"] = Draw::Graph{
|
graphs["download"] = Draw::Graph{
|
||||||
width - b_width - 2, u_graph_height, "download",
|
width - b_width - 2, u_graph_height, "download",
|
||||||
@ -1395,7 +1404,7 @@ namespace Net {
|
|||||||
|
|
||||||
out += Mv::to(y, x+width - i_size - 9) + title_left + Fx::b + Theme::c("hi_fg") + "<b " + Theme::c("title")
|
out += Mv::to(y, x+width - i_size - 9) + title_left + Fx::b + Theme::c("hi_fg") + "<b " + Theme::c("title")
|
||||||
+ uresize(selected_iface, 10) + Theme::c("hi_fg") + " n>" + title_right
|
+ uresize(selected_iface, 10) + Theme::c("hi_fg") + " n>" + title_right
|
||||||
+ Mv::to(y, x+width - i_size - 15) + title_left + Theme::c("hi_fg") + (net.stat.at("download").offset + net.stat.at("upload").offset > 0 ? Fx::b : "") + 'z'
|
+ Mv::to(y, x+width - i_size - 15) + title_left + Theme::c("hi_fg") + (safeVal(net.stat, "download"s).offset + safeVal(net.stat, "upload"s).offset > 0 ? Fx::b : "") + 'z'
|
||||||
+ Theme::c("title") + "ero" + title_right;
|
+ Theme::c("title") + "ero" + title_right;
|
||||||
Input::mouse_mappings["b"] = {y, x+width - i_size - 8, 1, 3};
|
Input::mouse_mappings["b"] = {y, x+width - i_size - 8, 1, 3};
|
||||||
Input::mouse_mappings["n"] = {y, x+width - 6, 1, 3};
|
Input::mouse_mappings["n"] = {y, x+width - 6, 1, 3};
|
||||||
@ -1419,13 +1428,13 @@ namespace Net {
|
|||||||
//? Graphs and stats
|
//? Graphs and stats
|
||||||
int cy = 0;
|
int cy = 0;
|
||||||
for (const string dir : {"download", "upload"}) {
|
for (const string dir : {"download", "upload"}) {
|
||||||
out += Mv::to(y+1 + (dir == "upload" ? u_graph_height : 0), x + 1) + graphs.at(dir)(net.bandwidth.at(dir), redraw or data_same or not net.connected)
|
out += Mv::to(y+1 + (dir == "upload" ? u_graph_height : 0), x + 1) + graphs.at(dir)(safeVal(net.bandwidth, dir), redraw or data_same or not net.connected)
|
||||||
+ Mv::to(y+1 + (dir == "upload" ? height - 3: 0), x + 1) + Fx::ub + Theme::c("graph_text")
|
+ Mv::to(y+1 + (dir == "upload" ? height - 3: 0), x + 1) + Fx::ub + Theme::c("graph_text")
|
||||||
+ floating_humanizer((dir == "upload" ? up_max : down_max), true);
|
+ floating_humanizer((dir == "upload" ? up_max : down_max), true);
|
||||||
const string speed = floating_humanizer(net.stat.at(dir).speed, false, 0, false, true);
|
const string speed = floating_humanizer(safeVal(net.stat, dir).speed, false, 0, false, true);
|
||||||
const string speed_bits = (b_width >= 20 ? floating_humanizer(net.stat.at(dir).speed, false, 0, true, true) : "");
|
const string speed_bits = (b_width >= 20 ? floating_humanizer(safeVal(net.stat, dir).speed, false, 0, true, true) : "");
|
||||||
const string top = floating_humanizer(net.stat.at(dir).top, false, 0, true, true);
|
const string top = floating_humanizer(safeVal(net.stat, dir).top, false, 0, true, true);
|
||||||
const string total = floating_humanizer(net.stat.at(dir).total);
|
const string total = floating_humanizer(safeVal(net.stat, dir).total);
|
||||||
const string symbol = (dir == "upload" ? "▲" : "▼");
|
const string symbol = (dir == "upload" ? "▲" : "▼");
|
||||||
out += Mv::to(b_y+1+cy, b_x+1) + Fx::ub + Theme::c("main_fg") + symbol + ' ' + ljust(speed, 10) + (b_width >= 20 ? rjust('(' + speed_bits + ')', 13) : "");
|
out += Mv::to(b_y+1+cy, b_x+1) + Fx::ub + Theme::c("main_fg") + symbol + ' ' + ljust(speed, 10) + (b_width >= 20 ? rjust('(' + speed_bits + ')', 13) : "");
|
||||||
cy += (b_height == 5 ? 2 : 1);
|
cy += (b_height == 5 ? 2 : 1);
|
||||||
@ -1453,9 +1462,9 @@ namespace Proc {
|
|||||||
bool shown = true, redraw = true;
|
bool shown = true, redraw = true;
|
||||||
int selected_pid = 0, selected_depth = 0;
|
int selected_pid = 0, selected_depth = 0;
|
||||||
string selected_name;
|
string selected_name;
|
||||||
unordered_flat_map<size_t, Draw::Graph> p_graphs;
|
std::unordered_map<size_t, Draw::Graph> p_graphs;
|
||||||
unordered_flat_map<size_t, bool> p_wide_cmd;
|
std::unordered_map<size_t, bool> p_wide_cmd;
|
||||||
unordered_flat_map<size_t, int> p_counters;
|
std::unordered_map<size_t, int> p_counters;
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
Draw::TextEdit filter;
|
Draw::TextEdit filter;
|
||||||
Draw::Graph detailed_cpu_graph;
|
Draw::Graph detailed_cpu_graph;
|
||||||
@ -1794,7 +1803,7 @@ namespace Proc {
|
|||||||
p_counters.erase(p.pid);
|
p_counters.erase(p.pid);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
p_counters.at(p.pid) = 0;
|
p_counters[p.pid] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
out += Fx::reset;
|
out += Fx::reset;
|
||||||
@ -1926,8 +1935,6 @@ namespace Proc {
|
|||||||
else
|
else
|
||||||
++element;
|
++element;
|
||||||
}
|
}
|
||||||
p_graphs.compact();
|
|
||||||
p_counters.compact();
|
|
||||||
|
|
||||||
for (auto element = p_wide_cmd.begin(); element != p_wide_cmd.end();) {
|
for (auto element = p_wide_cmd.begin(); element != p_wide_cmd.end();) {
|
||||||
if (rng::find(plist, element->first, &proc_info::pid) == plist.end()) {
|
if (rng::find(plist, element->first, &proc_info::pid) == plist.end()) {
|
||||||
@ -1936,7 +1943,6 @@ namespace Proc {
|
|||||||
else
|
else
|
||||||
++element;
|
++element;
|
||||||
}
|
}
|
||||||
p_wide_cmd.compact();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selected == 0 and selected_pid != 0) {
|
if (selected == 0 and selected_pid != 0) {
|
||||||
|
@ -21,10 +21,9 @@ tab-size = 4
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <robin_hood.h>
|
#include <unordered_map>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
|
||||||
using robin_hood::unordered_flat_map;
|
|
||||||
using std::array;
|
using std::array;
|
||||||
using std::deque;
|
using std::deque;
|
||||||
using std::string;
|
using std::string;
|
||||||
@ -108,7 +107,7 @@ namespace Draw {
|
|||||||
long long offset;
|
long long offset;
|
||||||
long long last = 0, max_value = 0;
|
long long last = 0, max_value = 0;
|
||||||
bool current = true, tty_mode = false;
|
bool current = true, tty_mode = false;
|
||||||
unordered_flat_map<bool, vector<string>> graphs = { {true, {}}, {false, {}}};
|
std::unordered_map<bool, vector<string>> graphs = { {true, {}}, {false, {}}};
|
||||||
|
|
||||||
//* Create two representations of the graph to switch between to represent two values for each braille character
|
//* Create two representations of the graph to switch between to represent two values for each braille character
|
||||||
void _create(const deque<long long>& data, int data_offset);
|
void _create(const deque<long long>& data, int data_offset);
|
||||||
@ -135,6 +134,6 @@ namespace Draw {
|
|||||||
|
|
||||||
namespace Proc {
|
namespace Proc {
|
||||||
extern Draw::TextEdit filter;
|
extern Draw::TextEdit filter;
|
||||||
extern unordered_flat_map<size_t, Draw::Graph> p_graphs;
|
extern std::unordered_map<size_t, Draw::Graph> p_graphs;
|
||||||
extern unordered_flat_map<size_t, int> p_counters;
|
extern std::unordered_map<size_t, int> p_counters;
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ namespace rng = std::ranges;
|
|||||||
namespace Input {
|
namespace Input {
|
||||||
|
|
||||||
//* Map for translating key codes to readable values
|
//* Map for translating key codes to readable values
|
||||||
const unordered_flat_map<string, string> Key_escapes = {
|
const std::unordered_map<string, string> Key_escapes = {
|
||||||
{"\033", "escape"},
|
{"\033", "escape"},
|
||||||
{"\n", "enter"},
|
{"\n", "enter"},
|
||||||
{" ", "space"},
|
{" ", "space"},
|
||||||
@ -92,7 +92,7 @@ namespace Input {
|
|||||||
std::atomic<bool> interrupt (false);
|
std::atomic<bool> interrupt (false);
|
||||||
std::atomic<bool> polling (false);
|
std::atomic<bool> polling (false);
|
||||||
array<int, 2> mouse_pos;
|
array<int, 2> mouse_pos;
|
||||||
unordered_flat_map<string, Mouse_loc> mouse_mappings;
|
std::unordered_map<string, Mouse_loc> mouse_mappings;
|
||||||
|
|
||||||
deque<string> history(50, "");
|
deque<string> history(50, "");
|
||||||
string old_filter;
|
string old_filter;
|
||||||
|
@ -21,10 +21,9 @@ tab-size = 4
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <robin_hood.h>
|
#include <unordered_map>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
|
||||||
using robin_hood::unordered_flat_map;
|
|
||||||
using std::array;
|
using std::array;
|
||||||
using std::atomic;
|
using std::atomic;
|
||||||
using std::deque;
|
using std::deque;
|
||||||
@ -44,7 +43,7 @@ namespace Input {
|
|||||||
};
|
};
|
||||||
|
|
||||||
//? line, col, height, width
|
//? line, col, height, width
|
||||||
extern unordered_flat_map<string, Mouse_loc> mouse_mappings;
|
extern std::unordered_map<string, Mouse_loc> mouse_mappings;
|
||||||
|
|
||||||
extern atomic<bool> interrupt;
|
extern atomic<bool> interrupt;
|
||||||
extern atomic<bool> polling;
|
extern atomic<bool> polling;
|
||||||
|
@ -17,7 +17,7 @@ tab-size = 4
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <robin_hood.h>
|
#include <unordered_map>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@ -31,7 +31,6 @@ tab-size = 4
|
|||||||
#include "btop_draw.hpp"
|
#include "btop_draw.hpp"
|
||||||
#include "btop_shared.hpp"
|
#include "btop_shared.hpp"
|
||||||
|
|
||||||
using robin_hood::unordered_flat_map;
|
|
||||||
using std::array;
|
using std::array;
|
||||||
using std::ceil;
|
using std::ceil;
|
||||||
using std::max;
|
using std::max;
|
||||||
@ -123,7 +122,7 @@ namespace Menu {
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
unordered_flat_map<string, Input::Mouse_loc> mouse_mappings;
|
std::unordered_map<string, Input::Mouse_loc> mouse_mappings;
|
||||||
|
|
||||||
const array<array<string, 3>, 3> menu_normal = {
|
const array<array<string, 3>, 3> menu_normal = {
|
||||||
array<string, 3>{
|
array<string, 3>{
|
||||||
@ -1165,7 +1164,7 @@ namespace Menu {
|
|||||||
static Draw::TextEdit editor;
|
static Draw::TextEdit editor;
|
||||||
static string warnings;
|
static string warnings;
|
||||||
static bitset<8> selPred;
|
static bitset<8> selPred;
|
||||||
static const unordered_flat_map<string, std::reference_wrapper<const vector<string>>> optionsList = {
|
static const std::unordered_map<string, std::reference_wrapper<const vector<string>>> optionsList = {
|
||||||
{"color_theme", std::cref(Theme::themes)},
|
{"color_theme", std::cref(Theme::themes)},
|
||||||
{"log_level", std::cref(Logger::log_levels)},
|
{"log_level", std::cref(Logger::log_levels)},
|
||||||
{"temp_scale", std::cref(Config::temp_scales)},
|
{"temp_scale", std::cref(Config::temp_scales)},
|
||||||
|
@ -38,7 +38,7 @@ namespace Menu {
|
|||||||
extern bool redraw;
|
extern bool redraw;
|
||||||
|
|
||||||
//? line, col, height, width
|
//? line, col, height, width
|
||||||
extern unordered_flat_map<string, Input::Mouse_loc> mouse_mappings;
|
extern std::unordered_map<string, Input::Mouse_loc> mouse_mappings;
|
||||||
|
|
||||||
//* Creates a message box centered on screen
|
//* Creates a message box centered on screen
|
||||||
//? Height of box is determined by size of content vector
|
//? Height of box is determined by size of content vector
|
||||||
|
@ -29,7 +29,7 @@ using namespace Tools;
|
|||||||
namespace Gpu {
|
namespace Gpu {
|
||||||
vector<string> gpu_names;
|
vector<string> gpu_names;
|
||||||
vector<int> gpu_b_height_offsets;
|
vector<int> gpu_b_height_offsets;
|
||||||
unordered_flat_map<string, deque<long long>> shared_gpu_percent = {
|
std::unordered_map<string, deque<long long>> shared_gpu_percent = {
|
||||||
{"gpu-average", {}},
|
{"gpu-average", {}},
|
||||||
{"gpu-vram-total", {}},
|
{"gpu-vram-total", {}},
|
||||||
{"gpu-pwr-total", {}},
|
{"gpu-pwr-total", {}},
|
||||||
|
@ -26,10 +26,9 @@ tab-size = 4
|
|||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <ifaddrs.h>
|
#include <ifaddrs.h>
|
||||||
#include <robin_hood.h>
|
#include <unordered_map>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
using robin_hood::unordered_flat_map;
|
|
||||||
using std::array;
|
using std::array;
|
||||||
using std::atomic;
|
using std::atomic;
|
||||||
using std::deque;
|
using std::deque;
|
||||||
@ -98,7 +97,7 @@ namespace Gpu {
|
|||||||
extern vector<int> gpu_b_height_offsets;
|
extern vector<int> gpu_b_height_offsets;
|
||||||
extern long long gpu_pwr_total_max;
|
extern long long gpu_pwr_total_max;
|
||||||
|
|
||||||
extern unordered_flat_map<string, deque<long long>> shared_gpu_percent; // averages, power/vram total
|
extern std::unordered_map<string, deque<long long>> shared_gpu_percent; // averages, power/vram total
|
||||||
|
|
||||||
const array mem_names { "used"s, "free"s };
|
const array mem_names { "used"s, "free"s };
|
||||||
|
|
||||||
@ -124,7 +123,7 @@ namespace Gpu {
|
|||||||
|
|
||||||
//* Per-device container for GPU info
|
//* Per-device container for GPU info
|
||||||
struct gpu_info {
|
struct gpu_info {
|
||||||
unordered_flat_map<string, deque<long long>> gpu_percent = {
|
std::unordered_map<string, deque<long long>> gpu_percent = {
|
||||||
{"gpu-totals", {}},
|
{"gpu-totals", {}},
|
||||||
{"gpu-vram-totals", {}},
|
{"gpu-vram-totals", {}},
|
||||||
{"gpu-pwr-totals", {}},
|
{"gpu-pwr-totals", {}},
|
||||||
@ -181,7 +180,7 @@ namespace Cpu {
|
|||||||
extern tuple<int, long, string> current_bat;
|
extern tuple<int, long, string> current_bat;
|
||||||
|
|
||||||
struct cpu_info {
|
struct cpu_info {
|
||||||
unordered_flat_map<string, deque<long long>> cpu_percent = {
|
std::unordered_map<string, deque<long long>> cpu_percent = {
|
||||||
{"total", {}},
|
{"total", {}},
|
||||||
{"user", {}},
|
{"user", {}},
|
||||||
{"nice", {}},
|
{"nice", {}},
|
||||||
@ -207,8 +206,8 @@ namespace Cpu {
|
|||||||
string draw(const cpu_info& cpu, const vector<Gpu::gpu_info>& gpu, bool force_redraw = false, bool data_same = false);
|
string draw(const cpu_info& cpu, const vector<Gpu::gpu_info>& gpu, bool force_redraw = false, bool data_same = false);
|
||||||
|
|
||||||
//* Parse /proc/cpu info for mapping of core ids
|
//* Parse /proc/cpu info for mapping of core ids
|
||||||
auto get_core_mapping() -> unordered_flat_map<int, int>;
|
auto get_core_mapping() -> std::unordered_map<int, int>;
|
||||||
extern unordered_flat_map<int, int> core_mapping;
|
extern std::unordered_map<int, int> core_mapping;
|
||||||
|
|
||||||
auto get_cpuHz() -> string;
|
auto get_cpuHz() -> string;
|
||||||
|
|
||||||
@ -242,13 +241,13 @@ namespace Mem {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct mem_info {
|
struct mem_info {
|
||||||
unordered_flat_map<string, uint64_t> stats =
|
std::unordered_map<string, uint64_t> stats =
|
||||||
{{"used", 0}, {"available", 0}, {"cached", 0}, {"free", 0},
|
{{"used", 0}, {"available", 0}, {"cached", 0}, {"free", 0},
|
||||||
{"swap_total", 0}, {"swap_used", 0}, {"swap_free", 0}};
|
{"swap_total", 0}, {"swap_used", 0}, {"swap_free", 0}};
|
||||||
unordered_flat_map<string, deque<long long>> percent =
|
std::unordered_map<string, deque<long long>> percent =
|
||||||
{{"used", {}}, {"available", {}}, {"cached", {}}, {"free", {}},
|
{{"used", {}}, {"available", {}}, {"cached", {}}, {"free", {}},
|
||||||
{"swap_total", {}}, {"swap_used", {}}, {"swap_free", {}}};
|
{"swap_total", {}}, {"swap_used", {}}, {"swap_free", {}}};
|
||||||
unordered_flat_map<string, disk_info> disks;
|
std::unordered_map<string, disk_info> disks;
|
||||||
vector<string> disks_order;
|
vector<string> disks_order;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -270,7 +269,7 @@ namespace Net {
|
|||||||
extern string selected_iface;
|
extern string selected_iface;
|
||||||
extern vector<string> interfaces;
|
extern vector<string> interfaces;
|
||||||
extern bool rescale;
|
extern bool rescale;
|
||||||
extern unordered_flat_map<string, uint64_t> graph_max;
|
extern std::unordered_map<string, uint64_t> graph_max;
|
||||||
|
|
||||||
struct net_stat {
|
struct net_stat {
|
||||||
uint64_t speed{}; // defaults to 0
|
uint64_t speed{}; // defaults to 0
|
||||||
@ -282,14 +281,14 @@ namespace Net {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct net_info {
|
struct net_info {
|
||||||
unordered_flat_map<string, deque<long long>> bandwidth = { {"download", {}}, {"upload", {}} };
|
std::unordered_map<string, deque<long long>> bandwidth = { {"download", {}}, {"upload", {}} };
|
||||||
unordered_flat_map<string, net_stat> stat = { {"download", {}}, {"upload", {}} };
|
std::unordered_map<string, net_stat> stat = { {"download", {}}, {"upload", {}} };
|
||||||
string ipv4{}; // defaults to ""
|
string ipv4{}; // defaults to ""
|
||||||
string ipv6{}; // defaults to ""
|
string ipv6{}; // defaults to ""
|
||||||
bool connected{}; // defaults to false
|
bool connected{}; // defaults to false
|
||||||
};
|
};
|
||||||
|
|
||||||
extern unordered_flat_map<string, net_info> current_net;
|
extern std::unordered_map<string, net_info> current_net;
|
||||||
|
|
||||||
//* Collect net upload/download stats
|
//* Collect net upload/download stats
|
||||||
auto collect(bool no_update=false) -> net_info&;
|
auto collect(bool no_update=false) -> net_info&;
|
||||||
@ -322,7 +321,7 @@ namespace Proc {
|
|||||||
};
|
};
|
||||||
|
|
||||||
//? Translation from process state char to explanative string
|
//? Translation from process state char to explanative string
|
||||||
const unordered_flat_map<char, string> proc_states = {
|
const std::unordered_map<char, string> proc_states = {
|
||||||
{'R', "Running"},
|
{'R', "Running"},
|
||||||
{'S', "Sleeping"},
|
{'S', "Sleeping"},
|
||||||
{'D', "Waiting"},
|
{'D', "Waiting"},
|
||||||
|
@ -42,11 +42,11 @@ namespace Theme {
|
|||||||
fs::path theme_dir;
|
fs::path theme_dir;
|
||||||
fs::path user_theme_dir;
|
fs::path user_theme_dir;
|
||||||
vector<string> themes;
|
vector<string> themes;
|
||||||
unordered_flat_map<string, string> colors;
|
std::unordered_map<string, string> colors;
|
||||||
unordered_flat_map<string, array<int, 3>> rgbs;
|
std::unordered_map<string, array<int, 3>> rgbs;
|
||||||
unordered_flat_map<string, array<string, 101>> gradients;
|
std::unordered_map<string, array<string, 101>> gradients;
|
||||||
|
|
||||||
const unordered_flat_map<string, string> Default_theme = {
|
const std::unordered_map<string, string> Default_theme = {
|
||||||
{ "main_bg", "#00" },
|
{ "main_bg", "#00" },
|
||||||
{ "main_fg", "#cc" },
|
{ "main_fg", "#cc" },
|
||||||
{ "title", "#ee" },
|
{ "title", "#ee" },
|
||||||
@ -91,7 +91,7 @@ namespace Theme {
|
|||||||
{ "process_end", "#d45454" }
|
{ "process_end", "#d45454" }
|
||||||
};
|
};
|
||||||
|
|
||||||
const unordered_flat_map<string, string> TTY_theme = {
|
const std::unordered_map<string, string> TTY_theme = {
|
||||||
{ "main_bg", "\x1b[0;40m" },
|
{ "main_bg", "\x1b[0;40m" },
|
||||||
{ "main_fg", "\x1b[37m" },
|
{ "main_fg", "\x1b[37m" },
|
||||||
{ "title", "\x1b[97m" },
|
{ "title", "\x1b[97m" },
|
||||||
@ -224,7 +224,7 @@ namespace Theme {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//* Generate colors and rgb decimal vectors for the theme
|
//* Generate colors and rgb decimal vectors for the theme
|
||||||
void generateColors(const unordered_flat_map<string, string>& source) {
|
void generateColors(const std::unordered_map<string, string>& source) {
|
||||||
vector<string> t_rgb;
|
vector<string> t_rgb;
|
||||||
string depth;
|
string depth;
|
||||||
bool t_to_256 = Config::getB("lowcolor");
|
bool t_to_256 = Config::getB("lowcolor");
|
||||||
@ -372,7 +372,7 @@ namespace Theme {
|
|||||||
|
|
||||||
//* Load a .theme file from disk
|
//* Load a .theme file from disk
|
||||||
auto loadFile(const string& filename) {
|
auto loadFile(const string& filename) {
|
||||||
unordered_flat_map<string, string> theme_out;
|
std::unordered_map<string, string> theme_out;
|
||||||
const fs::path filepath = filename;
|
const fs::path filepath = filename;
|
||||||
if (not fs::exists(filepath))
|
if (not fs::exists(filepath))
|
||||||
return Default_theme;
|
return Default_theme;
|
||||||
|
@ -22,12 +22,11 @@ tab-size = 4
|
|||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <robin_hood.h>
|
#include <unordered_map>
|
||||||
|
|
||||||
using std::array;
|
using std::array;
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
using robin_hood::unordered_flat_map;
|
|
||||||
|
|
||||||
namespace Theme {
|
namespace Theme {
|
||||||
extern std::filesystem::path theme_dir;
|
extern std::filesystem::path theme_dir;
|
||||||
@ -54,9 +53,9 @@ namespace Theme {
|
|||||||
//* Set current theme from current "color_theme" value in config
|
//* Set current theme from current "color_theme" value in config
|
||||||
void setTheme();
|
void setTheme();
|
||||||
|
|
||||||
extern unordered_flat_map<string, string> colors;
|
extern std::unordered_map<string, string> colors;
|
||||||
extern unordered_flat_map<string, array<int, 3>> rgbs;
|
extern std::unordered_map<string, array<int, 3>> rgbs;
|
||||||
extern unordered_flat_map<string, array<string, 101>> gradients;
|
extern std::unordered_map<string, array<string, 101>> gradients;
|
||||||
|
|
||||||
//* Return escape code for color <name>
|
//* Return escape code for color <name>
|
||||||
inline const string& c(const string& name) { return colors.at(name); }
|
inline const string& c(const string& name) { return colors.at(name); }
|
||||||
|
@ -30,7 +30,7 @@ tab-size = 4
|
|||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
|
||||||
#include "robin_hood.h"
|
#include "unordered_map"
|
||||||
#include "widechar_width.hpp"
|
#include "widechar_width.hpp"
|
||||||
#include "btop_shared.hpp"
|
#include "btop_shared.hpp"
|
||||||
#include "btop_tools.hpp"
|
#include "btop_tools.hpp"
|
||||||
@ -43,7 +43,6 @@ using std::flush;
|
|||||||
using std::max;
|
using std::max;
|
||||||
using std::string_view;
|
using std::string_view;
|
||||||
using std::to_string;
|
using std::to_string;
|
||||||
using robin_hood::unordered_flat_map;
|
|
||||||
|
|
||||||
using namespace std::literals; // to use operator""s
|
using namespace std::literals; // to use operator""s
|
||||||
|
|
||||||
|
@ -31,6 +31,10 @@ tab-size = 4
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
#include <unordered_map>
|
||||||
|
#ifdef BTOP_DEBUG
|
||||||
|
#include <source_location>
|
||||||
|
#endif
|
||||||
#ifndef HOST_NAME_MAX
|
#ifndef HOST_NAME_MAX
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#define HOST_NAME_MAX 255
|
#define HOST_NAME_MAX 255
|
||||||
@ -146,6 +150,35 @@ namespace Term {
|
|||||||
void restore();
|
void restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//* Simple logging implementation
|
||||||
|
namespace Logger {
|
||||||
|
const vector<string> log_levels = {
|
||||||
|
"DISABLED",
|
||||||
|
"ERROR",
|
||||||
|
"WARNING",
|
||||||
|
"INFO",
|
||||||
|
"DEBUG",
|
||||||
|
};
|
||||||
|
extern std::filesystem::path logfile;
|
||||||
|
|
||||||
|
enum Level : size_t {
|
||||||
|
DISABLED = 0,
|
||||||
|
ERROR = 1,
|
||||||
|
WARNING = 2,
|
||||||
|
INFO = 3,
|
||||||
|
DEBUG = 4,
|
||||||
|
};
|
||||||
|
|
||||||
|
//* Set log level, valid arguments: "DISABLED", "ERROR", "WARNING", "INFO" and "DEBUG"
|
||||||
|
void set(const string& level);
|
||||||
|
|
||||||
|
void log_write(const Level level, const string& msg);
|
||||||
|
inline void error(const string msg) { log_write(ERROR, msg); }
|
||||||
|
inline void warning(const string msg) { log_write(WARNING, msg); }
|
||||||
|
inline void info(const string msg) { log_write(INFO, msg); }
|
||||||
|
inline void debug(const string msg) { log_write(DEBUG, msg); }
|
||||||
|
}
|
||||||
|
|
||||||
//? --------------------------------------------------- FUNCTIONS -----------------------------------------------------
|
//? --------------------------------------------------- FUNCTIONS -----------------------------------------------------
|
||||||
|
|
||||||
namespace Tools {
|
namespace Tools {
|
||||||
@ -304,6 +337,50 @@ namespace Tools {
|
|||||||
//* Add std::string operator * : Repeat string <str> <n> number of times
|
//* Add std::string operator * : Repeat string <str> <n> number of times
|
||||||
std::string operator*(const string& str, int64_t n);
|
std::string operator*(const string& str, int64_t n);
|
||||||
|
|
||||||
|
template <typename K, typename T>
|
||||||
|
#ifdef BTOP_DEBUG
|
||||||
|
const T& safeVal(const std::unordered_map<K, T>& map, const K& key, const T& fallback = T{}, std::source_location loc = std::source_location::current()) {
|
||||||
|
if (map.contains(key)) {
|
||||||
|
return map.at(key);
|
||||||
|
} else {
|
||||||
|
Logger::error(fmt::format("safeVal() called with invalid key: [{}] in file: {} on line: {}", key, loc.file_name(), loc.line()));
|
||||||
|
return fallback;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#else
|
||||||
|
const T& safeVal(const std::unordered_map<K, T>& map, const K& key, const T& fallback = T{}) {
|
||||||
|
if (map.contains(key)) {
|
||||||
|
return map.at(key);
|
||||||
|
} else {
|
||||||
|
Logger::error(fmt::format("safeVal() called with invalid key: [{}] (Compile btop with DEBUG=true for more extensive logging!)", key));
|
||||||
|
return fallback;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
#ifdef BTOP_DEBUG
|
||||||
|
const T& safeVal(const std::vector<T>& vec, const size_t& index, const T& fallback = T{}, std::source_location loc = std::source_location::current()) {
|
||||||
|
if (index < vec.size()) {
|
||||||
|
return vec.at(index);
|
||||||
|
} else {
|
||||||
|
Logger::error(fmt::format("safeVal() called with invalid index: [{}] in file: {} on line: {}", index, loc.file_name(), loc.line()));
|
||||||
|
return fallback;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#else
|
||||||
|
const T& safeVal(const std::vector<T>& vec, const size_t& index, const T& fallback = T{}) {
|
||||||
|
if (index < vec.size()) {
|
||||||
|
return vec.at(index);
|
||||||
|
} else {
|
||||||
|
Logger::error(fmt::format("safeVal() called with invalid index: [{}] (Compile btop with DEBUG=true for more extensive logging!)", index));
|
||||||
|
return fallback;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//* Return current time in <strf> format
|
//* Return current time in <strf> format
|
||||||
string strf_time(const string& strf);
|
string strf_time(const string& strf);
|
||||||
|
|
||||||
@ -342,35 +419,6 @@ namespace Tools {
|
|||||||
auto celsius_to(const long long& celsius, const string& scale) -> tuple<long long, string>;
|
auto celsius_to(const long long& celsius, const string& scale) -> tuple<long long, string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
//* Simple logging implementation
|
|
||||||
namespace Logger {
|
|
||||||
const vector<string> log_levels = {
|
|
||||||
"DISABLED",
|
|
||||||
"ERROR",
|
|
||||||
"WARNING",
|
|
||||||
"INFO",
|
|
||||||
"DEBUG",
|
|
||||||
};
|
|
||||||
extern std::filesystem::path logfile;
|
|
||||||
|
|
||||||
enum Level : size_t {
|
|
||||||
DISABLED = 0,
|
|
||||||
ERROR = 1,
|
|
||||||
WARNING = 2,
|
|
||||||
INFO = 3,
|
|
||||||
DEBUG = 4,
|
|
||||||
};
|
|
||||||
|
|
||||||
//* Set log level, valid arguments: "DISABLED", "ERROR", "WARNING", "INFO" and "DEBUG"
|
|
||||||
void set(const string& level);
|
|
||||||
|
|
||||||
void log_write(const Level level, const string& msg);
|
|
||||||
inline void error(const string msg) { log_write(ERROR, msg); }
|
|
||||||
inline void warning(const string msg) { log_write(WARNING, msg); }
|
|
||||||
inline void info(const string msg) { log_write(INFO, msg); }
|
|
||||||
inline void debug(const string msg) { log_write(DEBUG, msg); }
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Tools {
|
namespace Tools {
|
||||||
//* Creates a named timer that is started on construct (by default) and reports elapsed time in microseconds to Logger::debug() on destruct if running
|
//* Creates a named timer that is started on construct (by default) and reports elapsed time in microseconds to Logger::debug() on destruct if running
|
||||||
//* Unless delayed_report is set to false, all reporting is buffered and delayed until DebugTimer is destructed or .force_report() is called
|
//* Unless delayed_report is set to false, all reporting is buffered and delayed until DebugTimer is destructed or .force_report() is called
|
||||||
|
@ -58,6 +58,7 @@ tab-size = 4
|
|||||||
#include <regex>
|
#include <regex>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
#include "../btop_config.hpp"
|
#include "../btop_config.hpp"
|
||||||
#include "../btop_shared.hpp"
|
#include "../btop_shared.hpp"
|
||||||
@ -98,7 +99,7 @@ namespace Cpu {
|
|||||||
|
|
||||||
string cpu_sensor;
|
string cpu_sensor;
|
||||||
vector<string> core_sensors;
|
vector<string> core_sensors;
|
||||||
unordered_flat_map<int, int> core_mapping;
|
std::unordered_map<int, int> core_mapping;
|
||||||
} // namespace Cpu
|
} // namespace Cpu
|
||||||
|
|
||||||
namespace Mem {
|
namespace Mem {
|
||||||
@ -169,17 +170,23 @@ namespace Shared {
|
|||||||
Cpu::current_cpu.temp.insert(Cpu::current_cpu.temp.begin(), Shared::coreCount + 1, {});
|
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_totals.insert(Cpu::core_old_totals.begin(), Shared::coreCount, 0);
|
||||||
Cpu::core_old_idles.insert(Cpu::core_old_idles.begin(), Shared::coreCount, 0);
|
Cpu::core_old_idles.insert(Cpu::core_old_idles.begin(), Shared::coreCount, 0);
|
||||||
|
Logger::debug("Init -> Cpu::collect()");
|
||||||
Cpu::collect();
|
Cpu::collect();
|
||||||
for (auto &[field, vec] : Cpu::current_cpu.cpu_percent) {
|
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);
|
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();
|
Cpu::cpuName = Cpu::get_cpuName();
|
||||||
|
Logger::debug("Init -> Cpu::get_sensors()");
|
||||||
Cpu::got_sensors = Cpu::get_sensors();
|
Cpu::got_sensors = Cpu::get_sensors();
|
||||||
|
Logger::debug("Init -> Cpu::get_core_mapping()");
|
||||||
Cpu::core_mapping = Cpu::get_core_mapping();
|
Cpu::core_mapping = Cpu::get_core_mapping();
|
||||||
|
|
||||||
//? Init for namespace Mem
|
//? Init for namespace Mem
|
||||||
Mem::old_uptime = system_uptime();
|
Mem::old_uptime = system_uptime();
|
||||||
|
Logger::debug("Init -> Mem::collect()");
|
||||||
Mem::collect();
|
Mem::collect();
|
||||||
|
Logger::debug("Init -> Mem::get_zpools()");
|
||||||
Mem::get_zpools();
|
Mem::get_zpools();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,7 +211,7 @@ namespace Cpu {
|
|||||||
|
|
||||||
const array<string, 10> time_names = {"user", "nice", "system", "idle"};
|
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},
|
{"totals", 0},
|
||||||
{"idles", 0},
|
{"idles", 0},
|
||||||
{"user", 0},
|
{"user", 0},
|
||||||
@ -323,8 +330,8 @@ namespace Cpu {
|
|||||||
return std::to_string(freq / 1000.0 ).substr(0, 3); // seems to be in MHz
|
return std::to_string(freq / 1000.0 ).substr(0, 3); // seems to be in MHz
|
||||||
}
|
}
|
||||||
|
|
||||||
auto get_core_mapping() -> unordered_flat_map<int, int> {
|
auto get_core_mapping() -> std::unordered_map<int, int> {
|
||||||
unordered_flat_map<int, int> core_map;
|
std::unordered_map<int, int> core_map;
|
||||||
if (cpu_temp_only) return core_map;
|
if (cpu_temp_only) return core_map;
|
||||||
|
|
||||||
for (long i = 0; i < Shared::coreCount; i++) {
|
for (long i = 0; i < Shared::coreCount; i++) {
|
||||||
@ -557,7 +564,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
|
// this bit is for 'regular' mounts
|
||||||
static struct statinfo cur;
|
static struct statinfo cur;
|
||||||
long double etime = 0;
|
long double etime = 0;
|
||||||
@ -572,7 +579,7 @@ namespace Mem {
|
|||||||
auto d = cur.dinfo->devices[i];
|
auto d = cur.dinfo->devices[i];
|
||||||
string devStatName = "/dev/" + string(d.device_name) + std::to_string(d.unit_number);
|
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
|
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);
|
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);
|
assign_values(disk, total_bytes_read, total_bytes_write);
|
||||||
string mountpoint = mapping.at(disk.dev);
|
string mountpoint = mapping.at(disk.dev);
|
||||||
@ -581,7 +588,6 @@ namespace Mem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Logger::debug("");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// this code is for ZFS mounts
|
// this code is for ZFS mounts
|
||||||
@ -691,7 +697,7 @@ namespace Mem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (show_disks) {
|
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();
|
double uptime = system_uptime();
|
||||||
auto &disks_filter = Config::getS("disks_filter");
|
auto &disks_filter = Config::getS("disks_filter");
|
||||||
bool filter_exclude = false;
|
bool filter_exclude = false;
|
||||||
@ -807,13 +813,13 @@ namespace Mem {
|
|||||||
} // namespace Mem
|
} // namespace Mem
|
||||||
|
|
||||||
namespace Net {
|
namespace Net {
|
||||||
unordered_flat_map<string, net_info> current_net;
|
std::unordered_map<string, net_info> current_net;
|
||||||
net_info empty_net = {};
|
net_info empty_net = {};
|
||||||
vector<string> interfaces;
|
vector<string> interfaces;
|
||||||
string selected_iface;
|
string selected_iface;
|
||||||
int errors = 0;
|
int errors = 0;
|
||||||
unordered_flat_map<string, uint64_t> graph_max = {{"download", {}}, {"upload", {}}};
|
std::unordered_map<string, uint64_t> graph_max = {{"download", {}}, {"upload", {}}};
|
||||||
unordered_flat_map<string, array<int, 2>> max_count = {{"download", {}}, {"upload", {}}};
|
std::unordered_map<string, array<int, 2>> max_count = {{"download", {}}, {"upload", {}}};
|
||||||
bool rescale = true;
|
bool rescale = true;
|
||||||
uint64_t timestamp = 0;
|
uint64_t timestamp = 0;
|
||||||
|
|
||||||
@ -892,7 +898,7 @@ namespace Net {
|
|||||||
} //else, ignoring family==AF_LINK (see man 3 getifaddrs)
|
} //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};
|
int mib[] = {CTL_NET, PF_ROUTE, 0, 0, NET_RT_IFLIST, 0};
|
||||||
size_t len;
|
size_t len;
|
||||||
if (sysctl(mib, 6, nullptr, &len, nullptr, 0) < 0) {
|
if (sysctl(mib, 6, nullptr, &len, nullptr, 0) < 0) {
|
||||||
@ -966,7 +972,6 @@ namespace Net {
|
|||||||
else
|
else
|
||||||
it++;
|
it++;
|
||||||
}
|
}
|
||||||
net.compact();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
timestamp = new_timestamp;
|
timestamp = new_timestamp;
|
||||||
@ -1037,7 +1042,7 @@ namespace Net {
|
|||||||
namespace Proc {
|
namespace Proc {
|
||||||
|
|
||||||
vector<proc_info> current_procs;
|
vector<proc_info> current_procs;
|
||||||
unordered_flat_map<string, string> uid_user;
|
std::unordered_map<string, string> uid_user;
|
||||||
string current_sort;
|
string current_sort;
|
||||||
string current_filter;
|
string current_filter;
|
||||||
bool current_rev = false;
|
bool current_rev = false;
|
||||||
|
@ -17,7 +17,8 @@ tab-size = 4
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <robin_hood.h>
|
#include <unordered_map>
|
||||||
|
#include <unordered_set>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <ranges>
|
#include <ranges>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
@ -31,6 +32,8 @@ tab-size = 4
|
|||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <future>
|
#include <future>
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
#if defined(RSMI_STATIC)
|
#if defined(RSMI_STATIC)
|
||||||
#include <rocm_smi/rocm_smi.h>
|
#include <rocm_smi/rocm_smi.h>
|
||||||
@ -94,10 +97,10 @@ namespace Cpu {
|
|||||||
int64_t crit{}; // defaults to 0
|
int64_t crit{}; // defaults to 0
|
||||||
};
|
};
|
||||||
|
|
||||||
unordered_flat_map<string, Sensor> found_sensors;
|
std::unordered_map<string, Sensor> found_sensors;
|
||||||
string cpu_sensor;
|
string cpu_sensor;
|
||||||
vector<string> core_sensors;
|
vector<string> core_sensors;
|
||||||
unordered_flat_map<int, int> core_mapping;
|
std::unordered_map<int, int> core_mapping;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Gpu {
|
namespace Gpu {
|
||||||
@ -298,7 +301,7 @@ namespace Cpu {
|
|||||||
"irq"s, "softirq"s, "steal"s, "guest"s, "guest_nice"s
|
"irq"s, "softirq"s, "steal"s, "guest"s, "guest_nice"s
|
||||||
};
|
};
|
||||||
|
|
||||||
unordered_flat_map<string, long long> cpu_old = {
|
std::unordered_map<string, long long> cpu_old = {
|
||||||
{"totals", 0},
|
{"totals", 0},
|
||||||
{"idles", 0},
|
{"idles", 0},
|
||||||
{"user", 0},
|
{"user", 0},
|
||||||
@ -595,8 +598,8 @@ namespace Cpu {
|
|||||||
return cpuhz;
|
return cpuhz;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto get_core_mapping() -> unordered_flat_map<int, int> {
|
auto get_core_mapping() -> std::unordered_map<int, int> {
|
||||||
unordered_flat_map<int, int> core_map;
|
std::unordered_map<int, int> core_map;
|
||||||
if (cpu_temp_only) return core_map;
|
if (cpu_temp_only) return core_map;
|
||||||
|
|
||||||
//? Try to get core mapping from /proc/cpuinfo
|
//? Try to get core mapping from /proc/cpuinfo
|
||||||
@ -669,7 +672,7 @@ namespace Cpu {
|
|||||||
auto get_battery() -> tuple<int, long, string> {
|
auto get_battery() -> tuple<int, long, string> {
|
||||||
if (not has_battery) return {0, 0, ""};
|
if (not has_battery) return {0, 0, ""};
|
||||||
static string auto_sel;
|
static string auto_sel;
|
||||||
static unordered_flat_map<string, battery> batteries;
|
static std::unordered_map<string, battery> batteries;
|
||||||
|
|
||||||
//? Get paths to needed files and check for valid values on first run
|
//? Get paths to needed files and check for valid values on first run
|
||||||
if (batteries.empty() and has_battery) {
|
if (batteries.empty() and has_battery) {
|
||||||
@ -1613,7 +1616,7 @@ namespace Mem {
|
|||||||
auto only_physical = Config::getB("only_physical");
|
auto only_physical = Config::getB("only_physical");
|
||||||
auto zfs_hide_datasets = Config::getB("zfs_hide_datasets");
|
auto zfs_hide_datasets = Config::getB("zfs_hide_datasets");
|
||||||
auto& disks = mem.disks;
|
auto& disks = mem.disks;
|
||||||
static unordered_flat_map<string, future<pair<disk_info, int>>> disks_stats_promises;
|
static std::unordered_map<string, future<pair<disk_info, int>>> disks_stats_promises;
|
||||||
ifstream diskread;
|
ifstream diskread;
|
||||||
|
|
||||||
vector<string> filter;
|
vector<string> filter;
|
||||||
@ -2048,13 +2051,13 @@ namespace Mem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace Net {
|
namespace Net {
|
||||||
unordered_flat_map<string, net_info> current_net;
|
std::unordered_map<string, net_info> current_net;
|
||||||
net_info empty_net = {};
|
net_info empty_net = {};
|
||||||
vector<string> interfaces;
|
vector<string> interfaces;
|
||||||
string selected_iface;
|
string selected_iface;
|
||||||
int errors{}; // defaults to 0
|
int errors{}; // defaults to 0
|
||||||
unordered_flat_map<string, uint64_t> graph_max = { {"download", {}}, {"upload", {}} };
|
std::unordered_map<string, uint64_t> graph_max = { {"download", {}}, {"upload", {}} };
|
||||||
unordered_flat_map<string, array<int, 2>> max_count = { {"download", {}}, {"upload", {}} };
|
std::unordered_map<string, array<int, 2>> max_count = { {"download", {}}, {"upload", {}} };
|
||||||
bool rescale{true};
|
bool rescale{true};
|
||||||
uint64_t timestamp{}; // defaults to 0
|
uint64_t timestamp{}; // defaults to 0
|
||||||
|
|
||||||
@ -2193,7 +2196,6 @@ namespace Net {
|
|||||||
else
|
else
|
||||||
it++;
|
it++;
|
||||||
}
|
}
|
||||||
net.compact();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
timestamp = new_timestamp;
|
timestamp = new_timestamp;
|
||||||
@ -2263,7 +2265,7 @@ namespace Net {
|
|||||||
namespace Proc {
|
namespace Proc {
|
||||||
|
|
||||||
vector<proc_info> current_procs;
|
vector<proc_info> current_procs;
|
||||||
unordered_flat_map<string, string> uid_user;
|
std::unordered_map<string, string> uid_user;
|
||||||
string current_sort;
|
string current_sort;
|
||||||
string current_filter;
|
string current_filter;
|
||||||
bool current_rev{}; // defaults to false
|
bool current_rev{}; // defaults to false
|
||||||
@ -2278,7 +2280,7 @@ namespace Proc {
|
|||||||
|
|
||||||
detail_container detailed;
|
detail_container detailed;
|
||||||
constexpr size_t KTHREADD = 2;
|
constexpr size_t KTHREADD = 2;
|
||||||
static robin_hood::unordered_set<size_t> kernels_procs = {KTHREADD};
|
static std::unordered_set<size_t> kernels_procs = {KTHREADD};
|
||||||
|
|
||||||
//* Get detailed info for selected process
|
//* Get detailed info for selected process
|
||||||
void _collect_details(const size_t pid, const uint64_t uptime, vector<proc_info>& procs) {
|
void _collect_details(const size_t pid, const uint64_t uptime, vector<proc_info>& procs) {
|
||||||
|
@ -45,6 +45,7 @@ tab-size = 4
|
|||||||
#include <netinet/in.h> // for inet_ntop
|
#include <netinet/in.h> // for inet_ntop
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
@ -98,7 +99,7 @@ namespace Cpu {
|
|||||||
|
|
||||||
string cpu_sensor;
|
string cpu_sensor;
|
||||||
vector<string> core_sensors;
|
vector<string> core_sensors;
|
||||||
unordered_flat_map<int, int> core_mapping;
|
std::unordered_map<int, int> core_mapping;
|
||||||
} // namespace Cpu
|
} // namespace Cpu
|
||||||
|
|
||||||
namespace Mem {
|
namespace Mem {
|
||||||
@ -194,7 +195,7 @@ namespace Cpu {
|
|||||||
|
|
||||||
const array<string, 10> time_names = {"user", "nice", "system", "idle"};
|
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},
|
{"totals", 0},
|
||||||
{"idles", 0},
|
{"idles", 0},
|
||||||
{"user", 0},
|
{"user", 0},
|
||||||
@ -337,8 +338,8 @@ namespace Cpu {
|
|||||||
return std::to_string(freq / 1000.0 / 1000.0 / 1000.0).substr(0, 3);
|
return std::to_string(freq / 1000.0 / 1000.0 / 1000.0).substr(0, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto get_core_mapping() -> unordered_flat_map<int, int> {
|
auto get_core_mapping() -> std::unordered_map<int, int> {
|
||||||
unordered_flat_map<int, int> core_map;
|
std::unordered_map<int, int> core_map;
|
||||||
if (cpu_temp_only) return core_map;
|
if (cpu_temp_only) return core_map;
|
||||||
|
|
||||||
natural_t cpu_count;
|
natural_t cpu_count;
|
||||||
@ -599,7 +600,7 @@ namespace Mem {
|
|||||||
io_object_t &object;
|
io_object_t &object;
|
||||||
};
|
};
|
||||||
|
|
||||||
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) {
|
||||||
io_registry_entry_t drive;
|
io_registry_entry_t drive;
|
||||||
io_iterator_t drive_list;
|
io_iterator_t drive_list;
|
||||||
|
|
||||||
@ -716,7 +717,7 @@ namespace Mem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (show_disks) {
|
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();
|
double uptime = system_uptime();
|
||||||
auto &disks_filter = Config::getS("disks_filter");
|
auto &disks_filter = Config::getS("disks_filter");
|
||||||
bool filter_exclude = false;
|
bool filter_exclude = false;
|
||||||
@ -829,13 +830,13 @@ namespace Mem {
|
|||||||
} // namespace Mem
|
} // namespace Mem
|
||||||
|
|
||||||
namespace Net {
|
namespace Net {
|
||||||
unordered_flat_map<string, net_info> current_net;
|
std::unordered_map<string, net_info> current_net;
|
||||||
net_info empty_net = {};
|
net_info empty_net = {};
|
||||||
vector<string> interfaces;
|
vector<string> interfaces;
|
||||||
string selected_iface;
|
string selected_iface;
|
||||||
int errors = 0;
|
int errors = 0;
|
||||||
unordered_flat_map<string, uint64_t> graph_max = {{"download", {}}, {"upload", {}}};
|
std::unordered_map<string, uint64_t> graph_max = {{"download", {}}, {"upload", {}}};
|
||||||
unordered_flat_map<string, array<int, 2>> max_count = {{"download", {}}, {"upload", {}}};
|
std::unordered_map<string, array<int, 2>> max_count = {{"download", {}}, {"upload", {}}};
|
||||||
bool rescale = true;
|
bool rescale = true;
|
||||||
uint64_t timestamp = 0;
|
uint64_t timestamp = 0;
|
||||||
|
|
||||||
@ -912,7 +913,7 @@ namespace Net {
|
|||||||
} // else, ignoring family==AF_LINK (see man 3 getifaddrs)
|
} // 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_IFLIST2, 0};
|
int mib[] = {CTL_NET, PF_ROUTE, 0, 0, NET_RT_IFLIST2, 0};
|
||||||
size_t len;
|
size_t len;
|
||||||
if (sysctl(mib, 6, nullptr, &len, nullptr, 0) < 0) {
|
if (sysctl(mib, 6, nullptr, &len, nullptr, 0) < 0) {
|
||||||
@ -986,7 +987,6 @@ namespace Net {
|
|||||||
else
|
else
|
||||||
it++;
|
it++;
|
||||||
}
|
}
|
||||||
net.compact();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
timestamp = new_timestamp;
|
timestamp = new_timestamp;
|
||||||
@ -1057,7 +1057,7 @@ namespace Net {
|
|||||||
namespace Proc {
|
namespace Proc {
|
||||||
|
|
||||||
vector<proc_info> current_procs;
|
vector<proc_info> current_procs;
|
||||||
unordered_flat_map<string, string> uid_user;
|
std::unordered_map<string, string> uid_user;
|
||||||
string current_sort;
|
string current_sort;
|
||||||
string current_filter;
|
string current_filter;
|
||||||
bool current_rev = false;
|
bool current_rev = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user