Add independent per-machine monitoring

Show separate resource histories for each machine in All Systems, configure the primary tray icon independently with optional per-machine icons, and display network IN/OUT as distinct traces. Migrate legacy monitor and tray selections while preserving saved preferences.
This commit is contained in:
2026-11-26 07:13:02 -06:00
parent 7628161f07
commit 5b2251c8f2
24 changed files with 1092 additions and 249 deletions

View File

@@ -50,11 +50,12 @@ sample() {
dev=${dev//[[:space:]]/}
path=/sys/class/net/$dev
[[ -d $path ]] || continue
speed= state= physical=0
speed= state= index= physical=0
[[ ! -e $path/device ]] || physical=1
[[ ! -r $path/operstate ]] || read -r state < "$path/operstate"
[[ ! -r $path/ifindex ]] || read -r index < "$path/ifindex"
{ [[ ! -r $path/speed ]] || read -r speed < "$path/speed"; } 2>/dev/null
printf 'net\t%s\t%s\t%s\t%s\t%s\n' "$dev" "$physical" "$state" "$speed" "$rest"
printf 'net\t%s\t%s\t%s\t%s\t%s\t%s\n' "$dev" "$physical" "$state" "$speed" "$rest" "$index"
done < /proc/net/dev
for path in /sys/class/drm/card[0-9]*; do
[[ ${path##*/} =~ ^card[0-9]+$ && -r $path/device/vendor ]] || continue

View File

@@ -261,6 +261,6 @@ def interface_info():
count = w.ULONG.from_address(table.value).value
rows = (_InterfaceRow * count).from_address(table.value + ct.alignment(_InterfaceRow))
return {row.alias: (bool(row.flags & 1) and row.type in (6, 71),
row.transmit, row.receive) for row in rows}
row.transmit, row.receive, bytes(row.guid)) for row in rows}
finally:
free(table)

View File

@@ -328,10 +328,10 @@ class LinuxParser:
selected("disk", key, key, disk_metrics(read, write, reads, writes,
min(100, active / 10) if active is not None else None),
not self.target.disks or key in self.target.disks)
for key, physical, state, speed, row in (row for row in sections["net"] if len(row) == 5):
for key, physical, state, speed, row, *identity in (row for row in sections["net"] if len(row) in (5, 6)):
v = integers(row, 16)
if v:
receive, transmit = counters("net:" + key, (v[0], v[8]))
receive, transmit = counters(("net", key, state, *identity), (v[0], v[8]))
link = num(speed)
up = state == "up" if state in ("up", "down", "lowerlayerdown", "dormant") else None
link = link if link and link > 0 and up else None

View File

@@ -170,26 +170,34 @@ class Network(Counters):
def __init__(self, settings):
super().__init__(settings)
self.selected = settings.interfaces
self.identities = {}
def sample(self):
stamp, now = time(), monotonic()
rows = psutil.net_io_counters(pernic=True, nowrap=False) or {}
stats = psutil.net_if_stats()
native = interface_info()
selected = self.selected or [key for key in rows if native.get(key, (False, 0, 0))[0]]
absent = (False, 0, 0, None)
selected = self.selected or [key for key in rows if native.get(key, absent)[0]]
identities = {key: (native.get(key, absent)[3], stats[key].isup if key in stats else None)
for key in rows}
def convert(key, row, previous, elapsed):
if self.identities.get(key) != identities[key]:
previous = None
values = deltas(row, previous, ("bytes_recv", "bytes_sent"), elapsed, self.interval)
stat = stats.get(key)
up = stat.isup if stat else None
_, tx_link, rx_link = native.get(key, (False, 0, 0))
_, tx_link, rx_link, _ = native.get(key, absent)
if tx_link in (0, 2**64 - 1):
tx_link = (stat.speed * 1e6) if stat and stat.speed > 0 else 0
if rx_link in (0, 2**64 - 1):
rx_link = (stat.speed * 1e6) if stat and stat.speed > 0 else 0
return net_metrics(*values, up, rx_link / 1e6 if up else None, tx_link / 1e6 if up else None)
return self.measure(stamp, now, rows, selected, convert)
sample = self.measure(stamp, now, rows, selected, convert)
self.identities = identities
return sample
def os_name():