TLDR
How do I get a view of the status of all services on a target ?
something like :
# obviously, 'systemctl status' does not have this output :
$ systemctl --user status service.target
service.target: inactive (dead)
├── backend.service: active
├── db.service: active
├── frontend.service: active
└── scheduler.service: inactive (dead)
Context
We have several systemd units, which are parts of a more global service, so we have written a service.target
with all these units as dependencies.
For a more complete context :
- the units and target are actually user units and target units
the
service.target
file consists only of a description :#cat .config/systemd/user/service.target [Unit] Description = Service global target
service.target
's dependencies are listed in the filesystem :$ tree .config/systemd/user ├── backend.service ├── db.service ├── frontend.service ├── scheduler.service ├── service.target └── service.target.requires ├── backend.service -> ../backend.service ├── db.service -> ../db.service ├── frontend.service -> ../frontend.service └── scheduler.service -> ../scheduler.service
With this setup, systemctl --user start service.target
and systemctm --user stop service.target
works like we expect.
What I would like
I would like to have a command or a script, which would tell me wether the dependencies of the target are all up, only partially up, or all down.
From what I tried :
systemctl --user status service.target
will correctly tell me (and exit with0
) if all services are up, but will not help me to distinguish between "some are up, some are down" and "all are down" (in both case : exit code is3
, status message saysinactive (dead)
)systemctl --user list-dependencies service.target
does not give an output stable enough to parsesystemctl --user status
will give me a detailed overview of all processes started by systemd user services, but I d'ont know how to narrow this list down to "only the services under service.target"
Question
What is the most stable way to get the status of all the services on which a systemd target depends ?
Should we modify our setup ?