Scrounger / ioBroker.linux-control

Controlling Linux devices and information about your system
https://forum.iobroker.net/topic/35870/test-adapter-linux-control-v0-x-x
MIT License
10 stars 5 forks source link

Problem with getting service names #46

Open copystring opened 1 year ago

copystring commented 1 year ago

Describe the bug
You're using systemctl list-units --type service --all --no-legend | awk '{out=""; for(i=5;i<=NF;i++){out=out" "$i}; print $1","$2","$3","$4","out}' to list all services. On my system some services have an asterisk before the actual service name.

See this truncated list: systemctl list-units --type service --all --no-legend | awk '{out=""; for(i=5;i<=NF;i++){out=out" "$i}; print $1","$2","$3","$4","out}' apparmor.service,loaded,active,exited, Load AppArmor profiles apt-daily-upgrade.service,loaded,inactive,dead, Daily apt upgrade and clean activities apt-daily.service,loaded,inactive,dead, Daily apt download activities *,auditd.service,not-found,inactive, dead auditd.service *,connman.service,not-found,inactive, dead connman.service

Resulting in errors like this: State "linux-control.1.storj.services.*.running" has no existing object, this might lead to an error in future versions

These services either need to be ignored or start to get the service name after the asterisk otherwise the services list is never fully completed. See this:

image

Versions:

copystring commented 1 year ago

Or maybe it is useful to use list-unit-files --state=enabled instead of list-units --type service --all? The services which are disabled have the asterisk in front.

Scrounger commented 1 year ago

which distibution is that?

copystring commented 1 year ago

debian 11 running in a proxmox lxc with nested enabled. With nested it shows the services of the host in addition to it's own services.

copystring commented 1 year ago

Please accept this PR to fix the issue. https://github.com/Scrounger/ioBroker.linux-control/pull/57