Skip to content

Commit

Permalink
metrics: Link to network interface
Browse files Browse the repository at this point in the history
Fixes #18998
  • Loading branch information
leomoty authored and mvollmer committed Sep 19, 2023
1 parent d784f0e commit 98a2e09
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/metrics/metrics.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ class CurrentMetrics extends React.Component {
const num_cpu_str = cockpit.format(cockpit.ngettext("$0 CPU", "$0 CPUs", numCpu), numCpu);

const netIO = this.netInterfacesNames.map((iface, i) => [
iface,
<Button variant="link" isInline onClick={() => cockpit.jump(`/network#/${iface}`) } key={iface}>{iface}</Button>,
this.state.netInterfacesRx[i] >= 1 ? cockpit.format_bytes_per_sec(this.state.netInterfacesRx[i]) : "0",
this.state.netInterfacesTx[i] >= 1 ? cockpit.format_bytes_per_sec(this.state.netInterfacesTx[i]) : "0",
]);
Expand Down Expand Up @@ -805,7 +805,8 @@ class CurrentMetrics extends React.Component {
);
}

const rowPropsIface = row => ({ 'data-interface': row[0] });
// first element is the jump button, key is interface name
const rowPropsIface = row => ({ 'data-interface': row[0].key });
const rowPropsDiskIO = row => ({ 'cgroup-name': row[0] });
const topServicesCPUColumns = [_("Service"), "%"];
const topServicesMemoryColumns = [_("Service"), _("Used")];
Expand Down
21 changes: 21 additions & 0 deletions test/verify/check-metrics
Original file line number Diff line number Diff line change
Expand Up @@ -1243,6 +1243,10 @@ BEGIN {{
b.wait_in_text("[aria-label='Network usage'] [data-interface='cockpittest1']", "cockpittest1")
b.wait_in_text("[aria-label='Network usage'] [data-interface='lo']", "lo")

# can jump to network interface details
b.wait_visible("[aria-label='Network usage'] [data-interface='cockpittest1'] button")
b.wait_visible("[aria-label='Network usage'] [data-interface='lo'] button")

def rateMatches(label, regexp):
text = b.text(f"[aria-label='Network usage'] [data-interface='lo'] td[data-label='{label}']")
return re.match(regexp, text) is not None
Expand All @@ -1261,6 +1265,23 @@ BEGIN {{
b.wait_text("[aria-label='Network usage'] [data-interface='cockpittest1'] td[data-label='In']", "0")
b.wait_text("[aria-label='Network usage'] [data-interface='cockpittest1'] td[data-label='Out']", "0")

b.click("[aria-label='Network usage'] [data-interface='lo'] button")
b.enter_page("/network")
b.wait_visible("#network-interface-name:contains('lo')")
if m.image in ["ubuntu-2204", "centos-8-stream"] or "rhel-8" in m.image:
b.wait_not_present(".pf-v5-c-switch")
b.wait_in_text("#network-interface-settings", "This device cannot be managed here.")
else:
# loopback can currently be managed, toggle on/off is present
b.wait_visible(".pf-v5-c-switch")

b.go("/metrics")
b.enter_page("/metrics")
b.click("[aria-label='Network usage'] [data-interface='cockpittest1'] button")
b.enter_page("/network")
b.wait_visible("#network-interface-name:contains('cockpittest1')")
b.wait_in_text("#network-interface-settings", "This device cannot be managed here.")


@testlib.skipImage("TODO: Arch Linux packagekit support", "arch")
@testlib.skipDistroPackage()
Expand Down

0 comments on commit 98a2e09

Please sign in to comment.