Thanks Petter for this feedback, I would agree with your suggestion.
Something like this ? diff --git a/collect.d/system b/collect.d/system index 9dc6fb9..5175aac 100644 --- a/collect.d/system +++ b/collect.d/system @@ -58,7 +58,9 @@ cat /proc/mounts > procmounts # Document current runlevel, useful to differenciate LTSP # thin clients from diskless workstations. -runlevel > runlevel +if command -v runlevel >/dev/null 2>&1; then + runlevel > runlevel +fi # Throw away error message from laptop-detect using dmidecode in Xen # domUs. See #438693 for more info. On Tue, Feb 10, 2026 at 12:38 PM Petter Reinholdtsen <[email protected]> wrote: > [Hector Cao] > > -runlevel > runlevel > > +if command -v systemctl >/dev/null 2>&1 && [ -d /run/systemd/system ]; > then > > + systemctl list-units --type=target --state=active > runlevel > > +elif command -v runlevel >/dev/null 2>&1; then > > + runlevel > runlevel > > +fi > > I believe this is the wrong approach. The systemctl command is not > presenting the current runlevel, it is presenting something else, and it > belong in a diffferent file name. > > If the runlevel command do not exist, the runlevel file should not be > created. Changing the content of well known files place too much > guesswork on the client code parsing the collected information. > > -- > Happy hacking > Petter Reinholdtsen > > > -- Hector CAO Software Engineer – Server Team / Virtualization [email protected] https://launc <https://launchpad.net/~hectorcao>hpad.net/~hectorcao <https://launchpad.net/~hectorcao> <https://launchpad.net/~hectorcao>

