[systemd-devel] systemd diagnostics

Gustavo Sverzut Barbieri barbieri at profusion.mobi
Fri Nov 25 15:35:53 PST 2011


On Tue, Nov 22, 2011 at 1:49 PM, Edward Z. Yang <ezyang at mit.edu> wrote:
> Hello Gustavo,
>
> Of course!
>
> Excerpts from Gustavo Sverzut Barbieri's message of Tue Nov 22 04:49:00 -0500 2011:
>> > 1. Newline separated property information.  When I run
>> > 'systemctl show -p "Wants" basic.target' I get a space-separated list of
>> > targets.  This is pretty annoying, it would be great for it to be newline
>> > separated.  Maybe another command for this use-case of inspecting
>> > dependencies.  (It's also pretty confusing to tell whether or not I want
>> > Before or Wants.)
>
> Primarily useful when developing and debugging systemd unit files. It's
> not always obvious what the correct set of dependencies are and a good
> way to figure things out is to see how the system is currently structured.

Hum, fair enough. Maybe we could add such tool in systemctl itself?


>> > 2. Dependency chasing for "Wants".  If I enable some systemd service,
>> > I would like to know all of the extra services it spins up.  systemd
>> --test --system
>> > doesn't really do what I would like here.  I actually want something more
>> like
>> > iterated 'show -p "Wants".
>
> Ditto. Also, useful when a dep is not getting run and you're not really sure why.

Fair as well. But do you know that with systemd lots of dependencies
are figured out and doesn't/shouldn't be made explicit? For instance,
whenever you use socket or dbus activation, you will automatically
start the other service without ever saying that in your unit... then
no way to know this by such means.


>> > 3. Listing enabled services.  We should not have to write horrible
>> > scripts like this:
>> >
>> >    for SERVICE in `systemctl -t service --full --all list-units | awk '{
>> >    print $1 }'`; do
>> >        echo -n "$SERVICE:  "
>> >        if systemctl is-enabled $SERVICE; then
>> >            echo ENABLED
>> >        else
>> >            echo disabled
>> >        fi
>> >    done 2>/dev/null
>
> We maintain around ten servers, and sometimes things get out of sync, so
> part of our auditing procedure is to ensure all the same services are
> enabled on all of the machines.

Ugh! I'd consider writing a python-dbus script to do this instead of
such mess. See example below :-)

#!/usr/bin/python

import dbus, sys

b = dbus.SystemBus()
o = b.get_object("org.freedesktop.systemd1", "/org/freedesktop/systemd1")
mgr = dbus.Interface(o, "org.freedesktop.systemd1.Manager")

def check_service(serv):
    try:
        state = mgr.GetUnitFileState(serv)
    except dbus.exceptions.DBusException:
        state = "does-not-exist"
    if state == "static" or state.startswith("enabled-"):
        state = "enabled"
    print "%s: %s" % (serv, state)

services = sys.argv[1:]
if services:
    for serv in services:
        check_service(serv)
else:
    for unit in mgr.ListUnits():
        serv = unit[0]
        if not serv.endswith(".service"):
            continue
        check_service(serv)




>> > 4. Fedora 15 shutdown does not give any messages to the console (my
>> coworkers
>> > tell me this is a funny Plymouth interaction.)  Did this get fixed later
>> on,
>> > or do we need to do something else?
>
> This is just a little annoying, since console is the most convenient
> way of interacting with a rebooting VM, and we have historically had cases
> where kernel modules would BUG during the reboot process (or
> other bad thigns) and it would be nice know about it.

here I have the final logs before shutdown, but nothing for services
stopping. What do you mean?

-- 
Gustavo Sverzut Barbieri
http://profusion.mobi embedded systems
--------------------------------------
MSN: barbieri at gmail.com
Skype: gsbarbieri
Mobile: +55 (19) 9225-2202


More information about the systemd-devel mailing list