Skip to content

Commit db7bab8

Browse files
Split 'show memory_breakdown' into two commands
one for reporting absolute values (in bytes), another for reporting relative values (in percent).
1 parent 7fe4871 commit db7bab8

File tree

8 files changed

+436
-88
lines changed

8 files changed

+436
-88
lines changed

CHANGELOG.md

Lines changed: 77 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,85 @@
11
# rabbitmqadmin-ng Change Log
22

3-
## v0.19.0 (in development)
3+
## v0.19.0 (Jan 5, 2025)
44

5-
No (documented) changes yet
5+
### Enhancements
6+
7+
* Two new commands for reasoning about target [node's memory footprint](https://www.rabbitmq.com/docs/memory-use):
8+
9+
```shell
10+
# displays a breakdown in bytes
11+
rabbitmqadmin show memory_breakdown_in_bytes --node 'rabbit@hostname'
12+
```
13+
14+
```shell
15+
# displays a breakdown in percent
16+
rabbitmqadmin show memory_breakdown_in_percent --node 'rabbit@sunnyside'
17+
```
18+
19+
Example output of `show memory_breakdown_in_percent`:
20+
21+
```
22+
┌────────────────────────────────────────┬────────────┐
23+
│ key │ percentage │
24+
├────────────────────────────────────────┼────────────┤
25+
│ total │ 100% │
26+
├────────────────────────────────────────┼────────────┤
27+
│ Binary heap │ 45.10% │
28+
├────────────────────────────────────────┼────────────┤
29+
│ Allocated but unused │ 23.45% │
30+
├────────────────────────────────────────┼────────────┤
31+
│ Quorum queue ETS tables │ 23.05% │
32+
├────────────────────────────────────────┼────────────┤
33+
│ Other processes │ 5.32% │
34+
├────────────────────────────────────────┼────────────┤
35+
│ Other (used by the runtime) │ 4.98% │
36+
├────────────────────────────────────────┼────────────┤
37+
│ Code │ 4.54% │
38+
├────────────────────────────────────────┼────────────┤
39+
│ Client connections: others processes │ 3.64% │
40+
├────────────────────────────────────────┼────────────┤
41+
│ Management stats database │ 3.48% │
42+
├────────────────────────────────────────┼────────────┤
43+
│ Client connections: reader processes │ 3.22% │
44+
├────────────────────────────────────────┼────────────┤
45+
│ Plugins and their data │ 3.12% │
46+
├────────────────────────────────────────┼────────────┤
47+
│ Other (ETS tables) │ 1.55% │
48+
├────────────────────────────────────────┼────────────┤
49+
│ Metrics data │ 0.66% │
50+
├────────────────────────────────────────┼────────────┤
51+
│ AMQP 0-9-1 channels │ 0.40% │
52+
├────────────────────────────────────────┼────────────┤
53+
│ Message store indices │ 0.27% │
54+
├────────────────────────────────────────┼────────────┤
55+
│ Atom table │ 0.24% │
56+
├────────────────────────────────────────┼────────────┤
57+
│ Client connections: writer processes │ 0.19% │
58+
├────────────────────────────────────────┼────────────┤
59+
│ Quorum queue replica processes │ 0.10% │
60+
├────────────────────────────────────────┼────────────┤
61+
│ Stream replica processes │ 0.07% │
62+
├────────────────────────────────────────┼────────────┤
63+
│ Mnesia │ 0.02% │
64+
├────────────────────────────────────────┼────────────┤
65+
│ Metadata store │ 0.02% │
66+
├────────────────────────────────────────┼────────────┤
67+
│ Stream coordinator processes │ 0.02% │
68+
├────────────────────────────────────────┼────────────┤
69+
│ Classic queue processes │ 0.00% │
70+
├────────────────────────────────────────┼────────────┤
71+
│ Metadata store ETS tables │ 0.00% │
72+
├────────────────────────────────────────┼────────────┤
73+
│ Stream replica reader processes │ 0.00% │
74+
├────────────────────────────────────────┼────────────┤
75+
│ Reserved by the kernel but unallocated │ 0.00% │
76+
└────────────────────────────────────────┴────────────┘
77+
78+
```
79+
680

781

8-
## v0.18.0 (Jan 1, 2024)
82+
## v0.18.0 (Jan 1, 2025)
983

1084
### Enhancements
1185

Cargo.lock

Lines changed: 22 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ reqwest = { version = "0.12.12", features = [
1717
"__rustls",
1818
"rustls-tls-native-roots"
1919
]}
20-
rabbitmq_http_client = { git = "https://github.com/michaelklishin/rabbitmq-http-api-rs.git", features = [
20+
rabbitmq_http_client = { version = "0.15.0", features = [
2121
"core",
2222
"blocking",
2323
"tabled"

src/cli.rs

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -754,14 +754,14 @@ fn declare_subcommands() -> [Command; 11] {
754754
]
755755
}
756756

757-
fn show_subcommands() -> [Command; 4] {
757+
fn show_subcommands() -> [Command; 5] {
758758
let overview_cmd = Command::new("overview")
759759
.about("displays a essential information about target node and its cluster");
760760
let churn_cmd = Command::new("churn").about("displays object churn metrics");
761761
let endpoint_cmd = Command::new("endpoint")
762762
.about("for troubleshooting: displays the computed HTTP API endpoint URI");
763-
let memory_breakdown_cmd = Command::new("memory_breakdown")
764-
.about("use it to understand what consumes memory on the target node")
763+
let memory_breakdown_in_bytes_cmd = Command::new("memory_breakdown_in_bytes")
764+
.about("provides a memory footprint breakdown (in bytes) for the target node")
765765
.arg(
766766
Arg::new("node")
767767
.long("node")
@@ -773,7 +773,26 @@ fn show_subcommands() -> [Command; 4] {
773773
MEMORY_FOOTPRINT_GUIDE_URL
774774
));
775775

776-
[overview_cmd, churn_cmd, endpoint_cmd, memory_breakdown_cmd]
776+
let memory_breakdown_in_percent_cmd = Command::new("memory_breakdown_in_percent")
777+
.about("provides a memory footprint breakdown (in percent) for the target node")
778+
.arg(
779+
Arg::new("node")
780+
.long("node")
781+
.help("target node, must be a cluster member")
782+
.required(true),
783+
)
784+
.after_long_help(color_print::cformat!(
785+
"<bold>Doc guide:</bold>: {}",
786+
MEMORY_FOOTPRINT_GUIDE_URL
787+
));
788+
789+
[
790+
overview_cmd,
791+
churn_cmd,
792+
endpoint_cmd,
793+
memory_breakdown_in_bytes_cmd,
794+
memory_breakdown_in_percent_cmd,
795+
]
777796
}
778797

779798
fn delete_subcommands() -> [Command; 11] {

src/main.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,13 @@ fn dispatch_subcommand(
253253
println!("Using endpoint: {}", endpoint);
254254
res_handler.no_output_on_success(Ok(()))
255255
}
256-
("show", "memory_breakdown") => {
256+
("show", "memory_breakdown_in_bytes") => {
257257
let result = commands::show_memory_breakdown(client, command_args);
258-
res_handler.memory_breakdown_result(result)
258+
res_handler.memory_breakdown_in_bytes_result(result)
259+
}
260+
("show", "memory_breakdown_in_percent") => {
261+
let result = commands::show_memory_breakdown(client, command_args);
262+
res_handler.memory_breakdown_in_percent_result(result)
259263
}
260264

261265
("list", "nodes") => {

src/output.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,29 @@ impl ResultHandler {
130130
}
131131
}
132132

133-
pub fn memory_breakdown_result(&mut self, result: ClientResult<NodeMemoryBreakdown>) {
133+
pub fn memory_breakdown_in_bytes_result(&mut self, result: ClientResult<NodeMemoryBreakdown>) {
134134
match result {
135135
Ok(output) => {
136136
self.exit_code = Some(ExitCode::Ok);
137137

138-
let mut table = tables::memory_breakdown(output);
138+
let mut table = tables::memory_breakdown_in_bytes(output);
139+
self.table_styler.apply(&mut table);
140+
141+
println!("{}", table);
142+
}
143+
Err(error) => self.report_command_run_error(&error),
144+
}
145+
}
146+
147+
pub fn memory_breakdown_in_percent_result(
148+
&mut self,
149+
result: ClientResult<NodeMemoryBreakdown>,
150+
) {
151+
match result {
152+
Ok(output) => {
153+
self.exit_code = Some(ExitCode::Ok);
154+
155+
let mut table = tables::memory_breakdown_in_percent(output);
139156
self.table_styler.apply(&mut table);
140157

141158
println!("{}", table);

0 commit comments

Comments
 (0)