Userland: Add network adapter link status to SystemMonitor and applet

Add a column named 'Link status' to the Network tab in SystemMonitor
showing the speed and duplex if the link is up.
Add the link speed behind the existing text in the applet or show
'down' if the link is down.
This commit is contained in:
Thomas Wagenveld 2021-07-28 14:23:39 +02:00 committed by Gunnar Beutner
commit 3a40287776
Notes: sideshowbarker 2024-07-18 07:33:17 +09:00
2 changed files with 15 additions and 1 deletions

View file

@ -48,6 +48,14 @@ NetworkStatisticsWidget::NetworkStatisticsWidget()
net_adapters_fields.empend("name", "Name", Gfx::TextAlignment::CenterLeft);
net_adapters_fields.empend("class_name", "Class", Gfx::TextAlignment::CenterLeft);
net_adapters_fields.empend("mac_address", "MAC", Gfx::TextAlignment::CenterLeft);
net_adapters_fields.empend("Link status", Gfx::TextAlignment::CenterLeft,
[this](JsonObject const& object) -> String {
if (!object.get("link_up").as_bool())
return "Down";
return String::formatted("{} Mb/s {}-duplex", object.get("link_speed").to_i32(),
object.get("link_full_duplex").as_bool() ? "full" : "half");
});
net_adapters_fields.empend("ipv4_address", "IPv4", Gfx::TextAlignment::CenterLeft);
net_adapters_fields.empend("packets_in", "Pkt In", Gfx::TextAlignment::CenterRight);
net_adapters_fields.empend("packets_out", "Pkt Out", Gfx::TextAlignment::CenterRight);