Does the netdata systemd plugin montor systemd units started by users other than root? I have a unit that’s run from non-root user and running the systemd plugin in debug mode i get this
...
[ INFO ] discovery[file manager] discovery.go:73 instance is started
[ INFO ] discovery[file reader] read.go:41 instance is started
[ INFO ] discovery[file reader] read.go:42 instance is stopped
[ DEBUG ] build[manager] build.go:164 received config group ('/etc/netdata/go.d/systemdunits.conf'): 1 jobs (added: 1, removed: 0)
[ DEBUG ] build[manager] build.go:313 building systemdunits[user-unit.service] job, config: map[__provider__:file reader __source__:/etc/netdata/go.d/systemdunits.conf autodetection_retry:0 include:[user-unit.service.service] module:systemdunits name:user-unit.service priority:70000 update_every:10]
[ DEBUG ] systemdunits[user-unit.service] systemdunits.go:74 unit names patterns: [user-unit.service.service]
[ DEBUG ] systemdunits[user-unit.service] systemdunits.go:75 timeout: 2s
[ DEBUG ] systemdunits[user-unit.service] collect.go:129 calling function 'GetManagerProperty'
[ DEBUG ] systemdunits[user-unit.service] collect.go:135 systemd version: "247.3-7+deb11u4"
[ DEBUG ] systemdunits[user-unit.service] collect.go:175 calling function 'ListUnitsByPatterns'
[ DEBUG ] systemdunits[user-unit.service] collect.go:188 got total/loaded 0/0 units
[ ERROR ] systemdunits[user-unit.service] job.go:205 check failed
[ DEBUG ] run[manager] run.go:43 tick 0
....
The unit definitely exists, however the netdata systemd collector seems to have issues with user units. I know that you need to do some trickery when using systemd unit files per user, like setting user DBUS , enabling lingering if you want to service that the unit controls to keep running after the user session exits etc.
I know this might not have to do anything with with netdata, I’m mentioning this just to point there are complications to consider when using systemd user services.
I’m assuming since the netdata runs as its own user it cannot access other users systemd files?
~# systemctl --all list-units user*
UNIT LOAD ACTIVE SUB DESCRIPTION
0 loaded units listed.
To show all installed unit files use 'systemctl list-unit-files'.
This was run from root as well as from netdata user.
Using
include:
- '*.service'
does not show the user unit. Other ones do show up in graph.
Ah, I see - I guess we need to connect to the user session bus, what we do now is we always connect to the system bus. I am not sure this will be possible without root privileges. Perhaps adding netdata user to some group will do, need to check.