Skip to content

Commit 6aba358

Browse files
lnyngfacebook-github-bot
authored andcommitted
Show process processor
Summary: We already record the processor the process last run on. Show it in the process view CPU tab. Differential Revision: D78903557 fbshipit-source-id: fc5240e84e375d6548473f1c591540e660a792aa
1 parent b431362 commit 6aba358

5 files changed

Lines changed: 19 additions & 17 deletions

File tree

below/dump/src/test.rs

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ fn test_dump_sys_content() {
8080
rc.render_title(false)
8181
))
8282
.to_owned(),
83-
"Model value and json value do not match for field: {}",
84-
field_id,
83+
"Model value and json value do not match for field: {field_id}",
8584
);
8685
}
8786
}
@@ -248,8 +247,7 @@ fn test_dump_process_content() {
248247
rc.render_title(false)
249248
))
250249
.to_owned(),
251-
"Model value and json value do not match for field: {}",
252-
field_id,
250+
"Model value and json value do not match for field: {field_id}",
253251
);
254252
}
255253
}
@@ -282,6 +280,7 @@ fn test_dump_proc_titles() {
282280
"User CPU",
283281
"Sys CPU",
284282
"Threads",
283+
"Processor",
285284
"Minflt",
286285
"Majflt",
287286
"RSS",
@@ -373,7 +372,7 @@ fn test_dump_proc_select() {
373372
let pid = item["Pid"].as_str().unwrap();
374373
let cur_id = pid.parse::<i32>().unwrap();
375374
if prev_id > 0 {
376-
assert!(prev_id < cur_id, "prev_id: {}, cur_id: {}", prev_id, cur_id);
375+
assert!(prev_id < cur_id, "prev_id: {prev_id}, cur_id: {cur_id}");
377376
}
378377
prev_id = cur_id;
379378
}
@@ -399,7 +398,7 @@ fn test_dump_proc_select() {
399398
let pid = item["Pid"].as_str().unwrap();
400399
let cur_id = pid.parse::<i32>().unwrap();
401400
if prev_id > 0 {
402-
assert!(prev_id > cur_id, "prev_id: {}, cur_id: {}", prev_id, cur_id);
401+
assert!(prev_id > cur_id, "prev_id: {prev_id}, cur_id: {cur_id}");
403402
}
404403
prev_id = cur_id;
405404
}
@@ -420,8 +419,7 @@ fn traverse_cgroup_tree(model: &model::CgroupModel, jval: &Value) {
420419
rc.render_title(false)
421420
))
422421
.to_owned(),
423-
"Model value and json value do not match for field: {}",
424-
field_id,
422+
"Model value and json value do not match for field: {field_id}",
425423
);
426424
}
427425
}
@@ -619,8 +617,7 @@ fn test_dump_iface_content() {
619617
rc.render_title(false)
620618
))
621619
.to_owned(),
622-
"Model value and json value do not match for field: {}",
623-
field_id,
620+
"Model value and json value do not match for field: {field_id}",
624621
);
625622
}
626623
}
@@ -729,8 +726,7 @@ fn test_dump_network_content() {
729726
rc.render_title(false),
730727
))
731728
.to_owned(),
732-
"Model value and json value do not match for field: {}",
733-
field_id,
729+
"Model value and json value do not match for field: {field_id}",
734730
);
735731
}
736732
}
@@ -850,8 +846,7 @@ fn test_dump_transport_content() {
850846
rc.render_title(false),
851847
))
852848
.to_owned(),
853-
"Model value and json value do not match for field: {}",
854-
field_id,
849+
"Model value and json value do not match for field: {field_id}",
855850
);
856851
}
857852
}
@@ -1121,8 +1116,7 @@ fn test_dump_disk_content() {
11211116
rc.render_title(false),
11221117
))
11231118
.to_owned(),
1124-
"Model value and json value do not match for field: {}",
1125-
field_id,
1119+
"Model value and json value do not match for field: {field_id}",
11261120
);
11271121
}
11281122
}

below/model/src/common_field_ids.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
///
2424
/// This list also servers as documentation for available field ids that could
2525
/// be used in other below crates. A test ensures that this list is up-to-date.
26-
pub const COMMON_MODEL_FIELD_IDS: [&str; 480] = [
26+
pub const COMMON_MODEL_FIELD_IDS: [&str; 481] = [
2727
"system.hostname",
2828
"system.kernel_version",
2929
"system.os_release",
@@ -357,6 +357,7 @@ pub const COMMON_MODEL_FIELD_IDS: [&str; 480] = [
357357
"process.processes.<key>.cpu.user_pct",
358358
"process.processes.<key>.cpu.system_pct",
359359
"process.processes.<key>.cpu.num_threads",
360+
"process.processes.<key>.cpu.processor",
360361
"process.processes.<key>.cmdline",
361362
"process.processes.<key>.exe_path",
362363
"network.interfaces.<key>.interface",

below/model/src/process.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ pub struct ProcessCpuModel {
172172
pub user_pct: Option<f64>,
173173
pub system_pct: Option<f64>,
174174
pub num_threads: Option<u64>,
175+
pub processor: Option<i32>,
175176
}
176177

177178
impl ProcessCpuModel {
@@ -184,6 +185,7 @@ impl ProcessCpuModel {
184185
user_pct,
185186
system_pct,
186187
num_threads: end.num_threads,
188+
processor: end.processor,
187189
}
188190
}
189191

@@ -194,6 +196,7 @@ impl ProcessCpuModel {
194196
user_pct: fold_optionals!(left.user_pct, right.user_pct),
195197
system_pct: fold_optionals!(left.system_pct, right.system_pct),
196198
num_threads: fold_optionals!(left.num_threads, right.num_threads),
199+
processor: Some(-1),
197200
}
198201
}
199202
}

below/render/src/default_configs.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,7 @@ impl HasRenderConfigForDump for model::SingleProcessModel {
10051005
UserPct => Some(gauge.unit("percent")),
10061006
SystemPct => Some(gauge.unit("percent")),
10071007
NumThreads => Some(counter),
1008+
Processor => Some(counter),
10081009
},
10091010
// OpenMetrics does not support strings
10101011
Cmdline => None,
@@ -1056,6 +1057,7 @@ impl HasRenderConfig for model::ProcessCpuModel {
10561057
UserPct => rc.title("CPU User").format(Precision(2)).suffix("%"),
10571058
SystemPct => rc.title("CPU System").format(Precision(2)).suffix("%"),
10581059
NumThreads => rc.title("Threads"),
1060+
Processor => rc.title("Processor"),
10591061
}
10601062
}
10611063
}

below/view/src/process_tabs.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ impl ProcessTab {
137137

138138
pub mod default_tabs {
139139
use model::ProcessCpuModelFieldId::NumThreads;
140+
use model::ProcessCpuModelFieldId::Processor;
140141
use model::ProcessCpuModelFieldId::SystemPct;
141142
use model::ProcessCpuModelFieldId::UsagePct;
142143
use model::ProcessCpuModelFieldId::UserPct;
@@ -201,6 +202,7 @@ pub mod default_tabs {
201202
ViewItem::from_default(Cpu(SystemPct)),
202203
ViewItem::from_default(Cpu(NumThreads)),
203204
ViewItem::from_default(Cpu(UsagePct)),
205+
ViewItem::from_default(Cpu(Processor)),
204206
])
205207
});
206208

0 commit comments

Comments
 (0)