Skip to main content

Module host

Module host 

Source
Expand description

What the watch needs from the running machine, as pure functions where it can be (tested), reading /etc, /sys and /proc only in read_*.

Functions§

boottime_secs
CLOCK_BOOTTIME whole seconds: the integer part of /proc/uptime.
expand_tools
The network tools now: plain names as they are, a template (name@) as each running instance (name@inst) among running.
network_tools
The export’s top-level networkTools (/etc/planarian/export.json): unit names, a template ending in @. None: missing or unparsable, which the caller treats as fail closed (the watch is not attached).
read_cgroups
cgroup id (the cgroup directory’s inode) → unit, for every service cgroup under root (/sys/fs/cgroup), and the running services’ names.
read_ifnames
Interface index → name, from /sys/class/net.
read_virtual_ifaces
The virtual links standing: those whose /sys/class/net/<name> resolves under /sys/devices/virtual/ (tun, tap, wireguard, dummy, veth, bridges, lo). A physical NIC’s resolves under its bus device.
unit_of_cgroup
The unit a cgroup path belongs to: the first <name>.service under system.slice, past any slices (a template’s instances sit in its own slice; a service’s sub-cgroups are its own). None for user sessions, the root, slices: changes from there are unattributed.