358.1. ksystemstats-kdos-1.0.0
KDOS sensors for System Monitor: boxes, energy by application, the A/B slots; the KDOS Meters face and page
| Version | 1.0.0, release 2 |
| Source tree | src/desktop/ksystemstats-kdos/ |
| Phase | 50_desktop (Desktop), 52 of 92 in build order |
| Licence | MIT |
| Homepage | https://github.com/kunaldawn/kdos |
| Build time | 0.1 SBU |
| Installed size | 278.7 KiB in 12 files |
| Recipe | src/desktop/ksystemstats-kdos/kpkgbuild |
About
ksystemstats-kdos shows KDOS’s own figures (boxes, energy use by application, the system slots) in System Monitor and in the panel’s meters. It is three things System Monitor reads:
- a ksystemstats sensor plugin,
/usr/lib/qt6/plugins/ksystemstats/ksystemstats_plugin_kdos.so; - a sensor face, KDOS Meters (
org.kdos.metersunder/usr/share/ksysguard/sensorfaces); - two System Monitor pages: the KDOS page,
/usr/share/plasma-systemmonitor/kdos.page, and the Overview page System Monitor opens on,kdos-overview.page.
The plugin publishes one container, kdos:
| Sensors | What they read |
|---|---|
kdos/box/<box>/{name,icon,cpu,memory,memoryLimit,ioRead,ioWrite,processes,energy} |
Each running box’s cgroup scope, app-kdos-<box>-<n>.scope, in a login’s delegated subtree or under user@<uid>.service/app.slice, or, for a box with none, its processes: the session’s uid’s, in a mount namespace other than the plugin’s, with KDOS_BOX=<box> in their environment; the name and icon of the launcher whose X-KDOS-Box names the box |
kdos/box/all/{boxes,cpu,memory,ioRead,ioWrite,processes} |
The same, summed over every box |
kdos/energy/<app>[@<box>]/{name,app,box,impact,cpuTime,gpu} and kdos/energy/all/… |
kdos-energyd’s report-json on /run/kdos-energyd.sock |
kdos/slot/{status,running,runningVersion,runningState,other,otherVersion,otherState,next,trial,attempts} |
/run/kdos/bootstate.json, the copy of kdos-bootctl status --json every user may read; with none, the live medium (/ an overlay in /proc/mounts) or one root, said as which, and /etc/os-release’s VERSION_ID as the running version |
kdos/look/phosphor |
kwinrc [Plugins] kdos_crtEnabled, 1 while Phosphor mode is on |
kdos/look/phosphorState |
The same as “On” or “Off”, for the KDOS page’s System card |
KDOS Meters draws one row per sensor: its name, a sparkline in the accent and its figure in the monospace face, over a faint scanline ground while kdos/look/phosphor reads 1. A text sensor has no sparkline, and its text wraps after the name.
In a horizontal panel a meter’s sensors stand side by side, a download or read figure marked ↓ and an upload or write figure ↑. The sparklines get only the room the panel’s other applets leave, down to none, before any figure narrows. A meter whose stepOutBelow setting is above 0, as the KDOS desk sets its network meter’s, shrinks to one pixel and draws nothing while its panel is narrower than that many grid units of logical width, so the task manager keeps its launchers’ size. The width is read again whenever the panel is resized, and so is the setting, from the applet’s configuration. The face’s property map follows that configuration only when the applet reloads it, so a value written after the face loaded takes effect at the next change of panel width. Opened from a panel, the face is a popup chart whose sparklines share the popup’s height.
Its sensorPattern setting makes it follow every sensor whose id matches a regular expression, as sensors come and go, which is how the KDOS page gives each box and each application a row of its own.
The pages. The KDOS page has four parts: Overview (this machine, all boxes, the system), Boxes (CPU, memory and disk per box), Energy (impact per application and the ledger) and Slots (the running slot and the other one). kdos-overview.page is upstream’s Overview with only the sensors every machine has: the disk and network totals, and a KDOS Meters face following gpu/gpu<n>/usage for the graphics cards. The stock page’s per-disk, per-interface and GPU sensors would put a “missing some sensors” banner over it on the live medium and in a virtual machine.
Why it is in KDOS
The comment above it in script/phases/50_desktop/packages.txt:
System Monitor's KDOS sensors: boxes, energy by application, the A/B slots.
Sources
None: the port builds from its own directory, /kdos/src/desktop/ksystemstats-kdos.
Dependencies
Depends on: cmake, ninja, extra-cmake-modules, qt6-qtbase, qt6-qtdeclarative, kconfig, kcoreaddons, ki18n, kpackage, kirigami, kitemmodels, kquickcharts, libksysguard, ksystemstats, plasma-systemmonitor.
Required by (2): kde-plasma, kdos-plasma-look.
Installation
From the repository root, inside the build container, this is the line kdosbuild runs for the port:
script/chroot/exec.sh bash -c 'source script/phases/50_desktop/phase.env && kpkg install ksystemstats-kdos'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /kdos/src/desktop/ksystemstats-kdos.
1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.
2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.
SRC_ROOT=/var/cache/kpkg/work/ksystemstats-kdos
SRC=$SRC_ROOT/ksystemstats-kdos-1.0.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.
3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
cmake -S "$PORT_SRC" -B build -G Ninja \
-D CMAKE_INSTALL_PREFIX=/usr \
-D KDE_INSTALL_LIBDIR=lib \
-D CMAKE_BUILD_TYPE=Release \
-D KDE_INSTALL_USE_QT_SYS_PATHS=ON \
-D BUILD_TESTING=OFF \
-Wno-dev
cmake --build build
DESTDIR=$PKG cmake --install build
The switches, and why each is set:
-S "$PORT_SRC"— The sources are the port’s own directory: a port of KDOS’s own has no tarball, and the build tree is made in the empty$SRC.-D KDE_INSTALL_USE_QT_SYS_PATHS=ON— Install the plugin into Qt’s own plugin directory,/usr/lib/qt6/plugins, where ksystemstats looks forksystemstats/.-D BUILD_TESTING=OFF— Build no tests into the package. The QtTest suite intests/is run bymake plasmatestin the development container, not by the image build.-D CMAKE_INSTALL_PREFIX=/usr,-D KDE_INSTALL_LIBDIR=lib,-D CMAKE_BUILD_TYPE=Release— The tree’s prefix and library directory, which ECM would otherwise put underlib64, and an optimised build.
The common switches of each build system are explained in the Flag glossary.
4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/ksystemstats-kdos, prunes what the image does not ship, lints the tree and rolls it reproducibly:
tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
--mtime=@$SOURCE_DATE_EPOCH \
--use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
-cf ksystemstats-kdos-1.0.0-2.tar.xz -C "$PKG" .
5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/ksystemstats-kdos, and runs the triggers its paths call for.
Other files in the port directory, read by build.sh: CMakeLists.txt, face/, page/, src/, tests/.
Contents
Installed directories: /usr/share/ksysguard/sensorfaces/org.kdos.meters.
Notes
The plugin is built against libksysguard’s SensorPlugin, which has no stable API, so it must be rebuilt, and its tests rerun, whenever Plasma moves to a new minor release.
ksystemstats splits a sensor path at its first and last /, so the object of kdos/box/www/cpu is box/www and the sensor tree shows KDOS ▸ Boxes ▸ Box www. A tree node takes its title only from an object at its exact path, so the plugin adds two objects with no sensors, box and energy, which title the kdos/box and kdos/energy nodes; without them the sensor picker names those groups by their raw paths. A box name or an application name never carries a / into a path: a scope whose unescaped name holds one, or a KDOS_BOX value that does, is not taken for a box, and an energy row’s id keeps only letters, digits, ., _, - and @.
A box’s figures are its scope’s own cpu.stat, memory.current, memory.max, io.stat and pids.current. cgroup v2 counts every descendant in them, so podman’s libpod-<id> and conmon children are inside the totals without the plugin walking them. Only scopes the session’s own uid owns are read: another user’s boxes are theirs.
In practice no box gets a scope on KDOS: elogind leaves /sys/fs/cgroup/<session>/cgroup.procs owned by root, cgroup2 refuses the move into delegated, and every box runs in the login’s session cgroup with its limits unenforced, which kdos-box profile says. Such a box is found by its processes instead (kdosBoxesByProcess). kdos-appbox sets KDOS_BOX in every box’s container and podman passes it to every exec; the mount namespace test keeps out a host program that inherited the variable from a kdos-box enter shell. Its figures are its processes’ sums: utime, stime, cutime and cstime from /proc/<pid>/stat, so a child reaped inside the box keeps its time in the sum; Pss from smaps_rollup, which does not count a page shared between two of its processes twice, or the resident set from statm where that file cannot be read; read_bytes and write_bytes from /proc/<pid>/io; and a memoryLimit of 0. A box with a scope is never counted twice: its name is passed to the process walk to skip. See known gaps.
ksystemstats starts when its first client asks for sensors, and an application’s energy sensors exist only once a report has named them, so the first report is read before the daemon answers anyone, waiting at most a second. After that kdos-energyd is asked every ten seconds while an energy sensor is watched and every minute while none is, so a page opened later still finds the applications. The ledger is root’s and wheel’s alone; for anyone else the status sensor says so and no application sensors exist.
A pattern in a face’s sensor list is resolved once, when the face loads, so a box started later would never be shown by a stock face. KDOS Meters matches its sensorPattern against the live sensor tree instead, which is why the KDOS page’s per-box and per-application faces are KDOS Meters with an empty sensor list.