mirror of
https://github.com/ClementTsang/bottom.git
synced 2026-08-25 21:06:30 +00:00
other: move cpu and memory settings over (#2064)
This commit is contained in:
@@ -51,7 +51,7 @@ jobs:
|
||||
needs: pre-job
|
||||
if: ${{ needs.pre-job.outputs.should_skip != 'true' }}
|
||||
runs-on: ${{ matrix.info.os }}
|
||||
timeout-minutes: 12
|
||||
timeout-minutes: 20
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
@@ -276,7 +276,7 @@ jobs:
|
||||
}
|
||||
runs-on: ${{ matrix.info.os }}
|
||||
if: ${{ needs.pre-job.outputs.should_skip != 'true' }}
|
||||
timeout-minutes: 12
|
||||
timeout-minutes: 20
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
|
||||
@@ -48,6 +48,8 @@ That said, these are more guidelines rather than hard rules, though the project
|
||||
- [#2062](https://github.com/ClementTsang/bottom/pull/2062): Rename `[network]` to `[network_graph]` in the config file; `[network]` remains valid as an alias.
|
||||
- [#2062](https://github.com/ClementTsang/bottom/pull/2062): Move network and memory graph config file options from `[flags]` to be under `[network_graph]` and `[memory_graph]`.
|
||||
- [#2063](https://github.com/ClementTsang/bottom/pull/2063): Move process config file options from `[flags]` to be under `[processes]`.
|
||||
- [#2064](https://github.com/ClementTsang/bottom/pull/2064): Move CPU config file options from `[flags]` to be under `[cpu]`.
|
||||
- [#2064](https://github.com/ClementTsang/bottom/pull/2064): Move memory config file options from `[flags]` to be under `[memory_graph]`.
|
||||
|
||||
### Other
|
||||
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
# CPU
|
||||
|
||||
If you want to change some of the default behaviour of the CPU graph widget, you can configure things under the `[cpu]` section.
|
||||
|
||||
## Default CPU graph selection
|
||||
|
||||
You can configure which CPU graph is shown by default on startup by setting `cpu.default`. Defaults to `"all"`, which
|
||||
shows all entries.
|
||||
|
||||
```toml
|
||||
[cpu]
|
||||
# One of "all" (default), "average"/"avg"
|
||||
default = "average"
|
||||
```
|
||||
|
||||
## Show decimal
|
||||
|
||||
You can configure whether CPU usage values are shown with a decimal place by setting `cpu.show_decimal`. Defaults
|
||||
to `false`.
|
||||
|
||||
```toml
|
||||
[cpu]
|
||||
show_decimal = true
|
||||
```
|
||||
|
||||
## Hide average CPU entry
|
||||
|
||||
You can hide the average CPU entry entirely by setting `cpu.hide_avg_cpu`. Defaults to `false`.
|
||||
|
||||
```toml
|
||||
[cpu]
|
||||
hide_avg_cpu = true
|
||||
```
|
||||
|
||||
## Place legend on the left
|
||||
|
||||
You can place the CPU chart legend on the left side by setting `cpu.left_legend`. Defaults to `false`.
|
||||
|
||||
```toml
|
||||
[cpu]
|
||||
left_legend = true
|
||||
```
|
||||
|
||||
## Average CPU row
|
||||
|
||||
In basic mode, you can give the average CPU entry a dedicated row by setting `cpu.basic_average_cpu_row`. Defaults to `false`.
|
||||
|
||||
```toml
|
||||
[cpu]
|
||||
basic_average_cpu_row = true
|
||||
```
|
||||
@@ -1,20 +0,0 @@
|
||||
# CPU
|
||||
|
||||
## Default CPU Graph Selection
|
||||
|
||||
You can configure which CPU graph is shown by default when starting up bottom by setting `cpu.default`.
|
||||
|
||||
```toml
|
||||
[cpu]
|
||||
# One of "all" (default), "average"/"avg"
|
||||
default = "average"
|
||||
```
|
||||
|
||||
## Show Decimal
|
||||
|
||||
You can configure whether CPU usage values are shown with a decimal place by setting `cpu.show_decimal`. Defaults to `false`.
|
||||
|
||||
```toml
|
||||
[cpu]
|
||||
show_decimal = true
|
||||
```
|
||||
@@ -1,9 +1,34 @@
|
||||
# Memory Graph
|
||||
|
||||
## Settings
|
||||
If you want to change some of the default behaviour of the memory graph widget, you can configure things under the `[memory_graph]` (or `[memory]`) section.
|
||||
|
||||
If you want to change some of the default behaviour of the memory graph widget, you can configure some things in the config file.
|
||||
## Graph legend position
|
||||
|
||||
| Field | Type | Functionality |
|
||||
| ----------------- | ------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------- |
|
||||
| `legend_position` | String (one of ["none", "top-left", "top", "top-right", "left", "right", "bottom-left", "bottom", "bottom-right"]) | Where to place the legend for the memory widget. |
|
||||
You can change where the legend for the graph is placed within the widget itself (or hidden with `"none"`). The default is `"top-right"`.
|
||||
|
||||
```toml
|
||||
[memory_graph]
|
||||
# One of ["none", "top-left", "top", "top-right", "left", "right", "bottom-left", "bottom", "bottom-right"]
|
||||
legend_position = "top-left"
|
||||
```
|
||||
|
||||
## Collect/show cache memory
|
||||
|
||||
On Linux, you can change whether the memory used by [cache/slabs](https://serverfault.com/a/1025189) is collected and
|
||||
shown. By default, it is `false`.
|
||||
|
||||
```toml
|
||||
[memory_graph]
|
||||
cache_memory = true
|
||||
```
|
||||
|
||||
## Subtract free-able ARC from memory
|
||||
|
||||
If ZFS is detected (note that the `zfs` feature must be enabled if built manually), you can enable `memory_graph.free_arc` to
|
||||
not count [ARC](https://www.45drives.com/community/articles/zfs-caching/) memory in the RAM usage calculations. Disabled
|
||||
by default.
|
||||
|
||||
```toml
|
||||
[memory_graph]
|
||||
free_arc = true
|
||||
```
|
||||
|
||||
+2
-2
@@ -161,7 +161,7 @@ nav:
|
||||
- "General Usage": usage/general-usage.md
|
||||
- "Basic Mode": usage/basic-mode.md
|
||||
- "Widgets":
|
||||
- "CPU Widget": usage/widgets/cpu.md
|
||||
- "CPU Widget": usage/widgets/cpu-graph.md
|
||||
- "Memory Graph Widget": usage/widgets/memory-graph.md
|
||||
- "Network Graph Widget": usage/widgets/network-graph.md
|
||||
- "Process Widget": usage/widgets/process.md
|
||||
@@ -174,7 +174,7 @@ nav:
|
||||
- "Command-line Options": configuration/command-line-options.md
|
||||
- "Config File":
|
||||
- configuration/config-file/index.md
|
||||
- "CPU Widget": configuration/config-file/cpu.md
|
||||
- "CPU Widget": configuration/config-file/cpu-graph.md
|
||||
- "Disk Table Widget": configuration/config-file/disk-table.md
|
||||
- "Memory Graph Widget": configuration/config-file/memory-graph.md
|
||||
- "Network Graph Widget": configuration/config-file/network-graph.md
|
||||
|
||||
@@ -152,10 +152,31 @@
|
||||
"description": "CPU column settings.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"basic_average_cpu_row": {
|
||||
"description": "Whether to give the average CPU entry a dedicated row in basic mode.",
|
||||
"type": [
|
||||
"boolean",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"default": {
|
||||
"description": "The default selected entry of the CPU widget.",
|
||||
"$ref": "#/$defs/CpuDefault"
|
||||
},
|
||||
"hide_avg_cpu": {
|
||||
"description": "Whether to hide the average CPU entry.",
|
||||
"type": [
|
||||
"boolean",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"left_legend": {
|
||||
"description": "Whether to put the CPU chart legend on the left side.",
|
||||
"type": [
|
||||
"boolean",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"show_decimal": {
|
||||
"description": "Whether to show a decimal place for CPU usage values.",
|
||||
"type": [
|
||||
@@ -665,6 +686,20 @@
|
||||
"description": "Memory-related configuration file options.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"cache_memory": {
|
||||
"description": "Whether to collect and display cache and buffer memory. Not available on Windows.",
|
||||
"type": [
|
||||
"boolean",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"free_arc": {
|
||||
"description": "Whether to subtract freeable ARC from memory usage.",
|
||||
"type": [
|
||||
"boolean",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"legend_position": {
|
||||
"description": "Where to place the legend for the memory chart widget.",
|
||||
"type": [
|
||||
@@ -980,7 +1015,7 @@
|
||||
]
|
||||
},
|
||||
"hide_k_threads": {
|
||||
"description": "Hide kernel threads from being shown.",
|
||||
"description": "Hide kernel threads from being shown. Linux only.",
|
||||
"type": [
|
||||
"boolean",
|
||||
"null"
|
||||
|
||||
+36
-7
@@ -275,8 +275,14 @@ pub(crate) fn init_app(args: BottomArgs, config: Config) -> Result<(App, BottomL
|
||||
|
||||
let use_basic_mode = is_flag_enabled!(basic, args.general, config);
|
||||
let expanded = is_flag_enabled!(expanded, args.general, config);
|
||||
|
||||
#[cfg(feature = "zfs")]
|
||||
let free_arc = is_flag_enabled!(free_arc, args.memory, config);
|
||||
let free_arc = enabled_option_with_deprecated!(
|
||||
args.memory.free_arc,
|
||||
config,
|
||||
memory_graph.free_arc,
|
||||
flags.free_arc,
|
||||
);
|
||||
|
||||
// For processes
|
||||
let is_grouped = enabled_option_with_deprecated!(
|
||||
@@ -402,7 +408,12 @@ pub(crate) fn init_app(args: BottomArgs, config: Config) -> Result<(App, BottomL
|
||||
show_average_cpu: get_show_average_cpu(args, config),
|
||||
show_cpu_decimal: config_or!(config, cpu.show_decimal, false),
|
||||
use_dot: is_flag_enabled!(dot_marker, args.general, config),
|
||||
cpu_left_legend: is_flag_enabled!(cpu_left_legend, args.cpu, config),
|
||||
cpu_left_legend: enabled_option_with_deprecated!(
|
||||
args.cpu.cpu_left_legend,
|
||||
config,
|
||||
cpu.left_legend,
|
||||
flags.cpu_left_legend,
|
||||
),
|
||||
use_current_cpu_total: enabled_option_with_deprecated!(
|
||||
args.process.current_usage,
|
||||
config,
|
||||
@@ -445,7 +456,12 @@ pub(crate) fn init_app(args: BottomArgs, config: Config) -> Result<(App, BottomL
|
||||
network_use_binary_prefix,
|
||||
network_show_packets,
|
||||
retention_ms,
|
||||
dedicated_average_row: config_or!(config, flags.average_cpu_row, false),
|
||||
dedicated_average_row: enabled_option_with_deprecated!(
|
||||
false,
|
||||
config,
|
||||
cpu.basic_average_cpu_row,
|
||||
flags.average_cpu_row,
|
||||
),
|
||||
default_tree_collapse: is_default_tree_collapsed,
|
||||
#[cfg(feature = "zfs")]
|
||||
free_arc,
|
||||
@@ -716,7 +732,12 @@ pub(crate) fn init_app(args: BottomArgs, config: Config) -> Result<(App, BottomL
|
||||
fn get_widget_layout(
|
||||
args: &BottomArgs, config: &Config,
|
||||
) -> OptionResult<(BottomLayout, u64, Option<BottomWidgetType>)> {
|
||||
let cpu_left_legend = is_flag_enabled!(cpu_left_legend, args.cpu, config);
|
||||
let cpu_left_legend = enabled_option_with_deprecated!(
|
||||
args.cpu.cpu_left_legend,
|
||||
config,
|
||||
cpu.left_legend,
|
||||
flags.cpu_left_legend,
|
||||
);
|
||||
|
||||
let (default_widget_type, mut default_widget_count) =
|
||||
get_default_widget_and_count(args, config)?;
|
||||
@@ -903,9 +924,12 @@ fn get_temperature(args: &BottomArgs, config: &Config) -> OptionResult<Temperatu
|
||||
fn get_show_average_cpu(args: &BottomArgs, config: &Config) -> bool {
|
||||
if args.cpu.hide_avg_cpu {
|
||||
return false;
|
||||
} else if let Some(cpu) = &config.cpu {
|
||||
return !cpu.hide_avg_cpu.unwrap_or(false);
|
||||
} else if let Some(flags) = &config.flags {
|
||||
if let Some(avg_cpu) = flags.hide_avg_cpu {
|
||||
return !avg_cpu;
|
||||
if let Some(hide) = flags.hide_avg_cpu {
|
||||
deprecated_warning("hide_avg_cpu", "cpu.hide_avg_cpu");
|
||||
return !hide;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1057,7 +1081,12 @@ fn get_enable_gpu(_: &BottomArgs, _: &Config) -> bool {
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
fn get_enable_cache_memory(args: &BottomArgs, config: &Config) -> bool {
|
||||
is_flag_enabled!(enable_cache_memory, args.memory, config)
|
||||
enabled_option_with_deprecated!(
|
||||
args.memory.enable_cache_memory,
|
||||
config,
|
||||
memory_graph.cache_memory,
|
||||
flags.enable_cache_memory,
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
|
||||
@@ -36,6 +36,7 @@ pub struct Config {
|
||||
pub(crate) temperature_graph: Option<TempGraphConfig>,
|
||||
#[serde(alias = "network")]
|
||||
pub(crate) network_graph: Option<NetworkGraphConfig>,
|
||||
#[serde(alias = "memory")]
|
||||
pub(crate) memory_graph: Option<MemoryGraphConfig>,
|
||||
pub(crate) cpu: Option<CpuConfig>,
|
||||
}
|
||||
|
||||
@@ -23,6 +23,15 @@ pub(crate) struct CpuConfig {
|
||||
|
||||
/// Whether to show a decimal place for CPU usage values.
|
||||
pub(crate) show_decimal: Option<bool>,
|
||||
|
||||
/// Whether to hide the average CPU entry.
|
||||
pub(crate) hide_avg_cpu: Option<bool>,
|
||||
|
||||
/// Whether to put the CPU chart legend on the left side.
|
||||
pub(crate) left_legend: Option<bool>,
|
||||
|
||||
/// Whether to give the average CPU entry a dedicated row in basic mode.
|
||||
pub(crate) basic_average_cpu_row: Option<bool>,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -27,11 +27,9 @@ impl TableGap {
|
||||
#[cfg_attr(feature = "generate_schema", derive(schemars::JsonSchema))]
|
||||
#[cfg_attr(test, serde(deny_unknown_fields), derive(PartialEq, Eq))]
|
||||
pub(crate) struct GeneralConfig {
|
||||
pub(crate) hide_avg_cpu: Option<bool>,
|
||||
pub(crate) dot_marker: Option<bool>,
|
||||
pub(crate) temperature_type: Option<String>,
|
||||
pub(crate) rate: Option<StringOrNum>,
|
||||
pub(crate) cpu_left_legend: Option<bool>,
|
||||
pub(crate) basic: Option<bool>,
|
||||
pub(crate) default_time_value: Option<StringOrNum>,
|
||||
pub(crate) time_delta: Option<StringOrNum>,
|
||||
@@ -50,16 +48,16 @@ pub(crate) struct GeneralConfig {
|
||||
pub(crate) show_table_scroll_position: Option<bool>,
|
||||
pub(crate) show_table_scroll_bar: Option<bool>,
|
||||
pub(crate) read_only: Option<bool>,
|
||||
// #[cfg(feature = "zfs")]
|
||||
pub(crate) free_arc: Option<bool>,
|
||||
pub(crate) disable_gpu: Option<bool>,
|
||||
// FIXME: This makes no sense outside of basic mode, add a basic mode config section.
|
||||
// FIXME: This also should be moved to CPU-specific... same with all the other entries.
|
||||
pub(crate) average_cpu_row: Option<bool>,
|
||||
pub(crate) enable_cache_memory: Option<bool>,
|
||||
pub(crate) retention: Option<StringOrNum>,
|
||||
|
||||
// FIXME: Deprecate these in the future.
|
||||
pub(crate) hide_avg_cpu: Option<bool>,
|
||||
pub(crate) cpu_left_legend: Option<bool>,
|
||||
pub(crate) average_cpu_row: Option<bool>,
|
||||
pub(crate) enable_cache_memory: Option<bool>,
|
||||
// #[cfg(feature = "zfs")]
|
||||
pub(crate) free_arc: Option<bool>,
|
||||
pub(crate) network_use_bytes: Option<bool>,
|
||||
pub(crate) network_use_log: Option<bool>,
|
||||
pub(crate) network_use_binary_prefix: Option<bool>,
|
||||
|
||||
@@ -11,4 +11,12 @@ pub struct MemoryGraphConfig {
|
||||
// (e.g. table-style, list-style) then we probably need a new system outright.
|
||||
/// Where to place the legend for the memory chart widget.
|
||||
pub(crate) legend_position: Option<String>,
|
||||
|
||||
/// Whether to collect and display cache and buffer memory. Not available on Windows.
|
||||
#[cfg_attr(target_os = "windows", allow(dead_code))]
|
||||
pub(crate) cache_memory: Option<bool>,
|
||||
|
||||
/// Whether to subtract freeable ARC from memory usage.
|
||||
#[cfg_attr(not(feature = "zfs"), allow(dead_code))]
|
||||
pub(crate) free_arc: Option<bool>,
|
||||
}
|
||||
|
||||
@@ -212,14 +212,13 @@ fn test_proc_default_sort() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_newer_mem_network() {
|
||||
run_and_kill(&["-C", "./tests/valid_configs/newer_mem_network.toml"]);
|
||||
fn test_newer_memory() {
|
||||
run_and_kill(&["-C", "./tests/valid_configs/newer_memory.toml"]);
|
||||
}
|
||||
|
||||
/// This uses deprecated network and memory settings - once they are removed, this test file should be moved to invalid configs.
|
||||
#[test]
|
||||
fn test_deprecated_mem_network() {
|
||||
run_and_kill(&["-C", "./tests/valid_configs/deprecated/mem_network.toml"]);
|
||||
fn test_newer_cpu() {
|
||||
run_and_kill(&["-C", "./tests/valid_configs/newer_cpu.toml"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -227,13 +226,36 @@ fn test_newer_processes() {
|
||||
run_and_kill(&["-C", "./tests/valid_configs/newer_processes.toml"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_newer_network() {
|
||||
run_and_kill(&["-C", "./tests/valid_configs/newer_network.toml"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_network_alias() {
|
||||
run_and_kill(&["-C", "./tests/valid_configs/network_alias.toml"]);
|
||||
}
|
||||
|
||||
/// This uses deprecated network settings - once they are removed, this test file should be moved to invalid configs.
|
||||
#[test]
|
||||
fn test_deprecated_network() {
|
||||
run_and_kill(&["-C", "./tests/valid_configs/deprecated/network.toml"]);
|
||||
}
|
||||
|
||||
/// This uses deprecated process settings - once they are removed, this test file should be moved to invalid configs.
|
||||
#[test]
|
||||
fn test_deprecated_processes() {
|
||||
run_and_kill(&["-C", "./tests/valid_configs/deprecated/processes.toml"]);
|
||||
}
|
||||
|
||||
/// This uses deprecated CPU settings - once they are removed, this test file should be moved to invalid configs.
|
||||
#[test]
|
||||
fn test_network_alias() {
|
||||
run_and_kill(&["-C", "./tests/valid_configs/network_alias.toml"]);
|
||||
fn test_deprecated_cpu() {
|
||||
run_and_kill(&["-C", "./tests/valid_configs/deprecated/cpu.toml"]);
|
||||
}
|
||||
|
||||
/// This uses deprecated memory settings - once they are removed, this test file should be moved to invalid configs.
|
||||
#[test]
|
||||
fn test_deprecated_memory() {
|
||||
run_and_kill(&["-C", "./tests/valid_configs/deprecated/memory.toml"]);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
# This uses deprecated CPU settings - once they are removed, this test file should be moved to invalid configs.
|
||||
|
||||
[flags]
|
||||
hide_avg_cpu = true
|
||||
cpu_left_legend = true
|
||||
average_cpu_row = true
|
||||
@@ -1,9 +0,0 @@
|
||||
# This uses deprecated network and memory settings - once they are removed, this test file should be moved to invalid configs.
|
||||
|
||||
[flags]
|
||||
network_use_bytes = true
|
||||
network_use_log = true
|
||||
network_use_binary_prefix = true
|
||||
network_legend = "left"
|
||||
|
||||
memory_legend = "left"
|
||||
@@ -0,0 +1,6 @@
|
||||
# This uses deprecated memory settings - once they are removed, this test file should be moved to invalid configs.
|
||||
|
||||
[flags]
|
||||
enable_cache_memory = true
|
||||
free_arc = true
|
||||
memory_legend = "left"
|
||||
@@ -0,0 +1,7 @@
|
||||
# This uses deprecated network settings - once they are removed, this test file should be moved to invalid configs.
|
||||
|
||||
[flags]
|
||||
network_use_bytes = true
|
||||
network_use_log = true
|
||||
network_use_binary_prefix = true
|
||||
network_legend = "left"
|
||||
@@ -0,0 +1,6 @@
|
||||
# This uses the newer CPU config location.
|
||||
|
||||
[cpu]
|
||||
hide_avg_cpu = true
|
||||
left_legend = true
|
||||
basic_average_cpu_row = true
|
||||
@@ -0,0 +1,6 @@
|
||||
# This uses the newer memory config location.
|
||||
|
||||
[memory_graph]
|
||||
cache_memory = true
|
||||
free_arc = true
|
||||
legend_position = "left"
|
||||
@@ -5,6 +5,3 @@ use_log = true
|
||||
use_bytes = true
|
||||
use_binary_prefix = true
|
||||
legend_position = "left"
|
||||
|
||||
[memory_graph]
|
||||
legend_position = "left"
|
||||
Reference in New Issue
Block a user