How to monitor for systemctl --user services using Checkmk

**CMK version: 2.1.0p26
**OS version: RHEL 8.8

**Error message: No error, service is not discovered if using --all parameter for example

Does anyone have any additional information on how to monitor systemctl --user services?

Thanks

I never worked with systemd --user services when it comes to monitoring. Do you check them on the CLI just like normal system services?

Thank you @robin.gierse and apologies for the late follow-up. What we’re trying to achieve is to have checkmk monitor systemd services that are running in user context, not system context. On RHEL8 and RHEL9 we’re using this approach to manage systemd units as a non-privileged user. See e.g. systemd/User - ArchWiki

To monitor a systemd --user unit as root, we need to export XDG_RUNTIME_DIR for the user (let’s call it myuser), then run the check like this:
export XDG_RUNTIME_DIR=/run/user/$(id -u myuser); sudo -E -u myuser systemctl --user status my-user-service.service

Is this achievable via checkmk using the existing systemd monitoring ability?

This is definitely not supported with the current systemd monitoring and I have a hunch, that is not relevant enough to become a mainstream feature. But you can of course create an idea, and see if it gets traction.

But now, that you already have a command, why not make it a local check?
With a little added logic you should be able to get decent monitoring out of it.

Thanks Robin, we’re currently using local checks as well as process monitoring, so we kind of have that covered. I’ve also submitted https://ideas.checkmk.com/suggestions/544224/ability-to-monitor-systemd-units-running-in-user-context (awaiting for moderation) hoping that it’ll get some traction.
Thanks again.

1 Like