How to get information about your Linux services with systemd.

The systemd init system may be used to get information about your running services. Here I am getting information about the openvpn service.

[email protected]:~$ systemctl -a status openvpn.service
● openvpn.service - LSB: Openvpn VPN service
   Loaded: loaded (/etc/init.d/openvpn)
   Active: active (running) since Mon 2015-04-13 14:57:18 AEST; 5h 2min ago
     Docs: man:systemd-sysv-generator(8)
   CGroup: /system.slice/openvpn.service
           └─1719 /usr/sbin/openvpn --writepid /run/openvpn/udp1194.pid --daemon ovpn-udp1194 --cd /etc/openvpn --config /etc/openvpn/udp1194.conf --script...
 
Apr 13 14:57:18 eyjafjallajkull ovpn-udp1194[1719]: GID set to nogroup
Apr 13 14:57:18 eyjafjallajkull ovpn-udp1194[1719]: UID set to nobody
Apr 13 14:57:18 eyjafjallajkull ovpn-udp1194[1719]: Listening for incoming TCP connection on [undef]
Apr 13 14:57:18 eyjafjallajkull ovpn-udp1194[1719]: TCPv4_SERVER link local (bound): [undef]
Apr 13 14:57:18 eyjafjallajkull ovpn-udp1194[1719]: TCPv4_SERVER link remote: [undef]
Apr 13 14:57:18 eyjafjallajkull ovpn-udp1194[1719]: MULTI: multi_init called, r=256 v=256
Apr 13 14:57:18 eyjafjallajkull ovpn-udp1194[1719]: IFCONFIG POOL: base=10.8.0.4 size=62, ipv6=0
Apr 13 14:57:18 eyjafjallajkull ovpn-udp1194[1719]: MULTI: TCP INIT maxclients=1024 maxevents=1028
Apr 13 14:57:18 eyjafjallajkull ovpn-udp1194[1719]: Initialization Sequence Completed
Apr 13 14:57:18 eyjafjallajkull systemd[1]: Started LSB: Openvpn VPN service.

This command will list information about all running services.

[email protected]:~$ systemctl -a status
● eyjafjallajkull
    State: degraded
     Jobs: 0 queued
   Failed: 5 units
    Since: Tue 2015-04-14 00:56:49 AEST; 4h 53min left
   CGroup: /
           ├─1 /sbin/init splash
           ├─system.slice
           │ ├─avahi-daemon.service
           │ │ ├─750 avahi-daemon: running [eyjafjallajkull.local
           │ │ └─841 avahi-daemon: chroot helpe
           │ ├─NetworkManager-dispatcher.service
           │ ├─dbus.service
           │ │ └─793 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation
           │ ├─openvpn.service
           │ │ └─1719 /usr/sbin/openvpn --writepid /run/openvpn/udp1194.pid --daemon ovpn-udp1194 --cd /etc/openvpn --config /etc/openvpn/udp1194.conf --scrip
           │ ├─ModemManager.service
           │ │ └─763 /usr/sbin/ModemManager
           │ ├─cron.service
           │ │ └─758 /usr/sbin/cron -f
           │ ├─hddtemp.service
           │ ├─systemd-vconsole-setup.service
           │ ├─rc-local.service
           │ ├─atieventsd.service
           │ ├─dev-sdb2.swap
           │ ├─home.mount
           │ ├─apport.service
           │ ├─systemd-modules-load.service
           │ ├─dev-sdb5.swap
           │ ├─pulseaudio.service
           │ ├─ifup-wait-all-auto.service
           │ ├─click-system-hooks.service
           │ ├─welcome2l.service
           │ ├─libvirt-bin.service
           │ │ └─1903 /usr/sbin/libvirtd -d
           │ ├─systemd-fsck-root.service
           │ ├─winbind.service
           │ │ ├─2161 /usr/sbin/winbindd
           │ │ ├─2178 /usr/sbin/winbindd
           │ │ ├─2204 /usr/sbin/winbindd
           │ │ └─2205 /usr/sbin/winbindd
           │ ├─-.mount
           │ ├─networking.service
           │ ├─ufw.service
           │ ├─accounts-daemon.service
           │ │ └─743 /usr/lib/accountsservice/accounts-daemon
           │ ├─lm-sensors.service
           │ ├─dev-disk-by\x2duuid-fbdbee14\x2daf95\x2d4dbb\x2d94ae\x2d0e29d3a61b3e.swap
           │ ├─colord.service
           │ │ └─2752 /usr/lib/colord/colord
           │ ├─resolvconf.service
           │ ├─atd.service
           │ │ └─775 /usr/sbin/atd -f
           │ ├─systemd-user-sessions.service
           │ ├─systemd-journald.service
           │ │ └─263 /lib/systemd/systemd-journald
           │ ├─run-user-1000.mount
           │ ├─sys-fs-fuse-connections.mount

Here is another way to see if a service is running.

[email protected]:~$ systemctl is-active openvpn
active

Show a verbose listing of systemd information with this command.

[email protected]:~$ systemctl show
Version=219
Features=+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT -GNUTLS +ACL +XZ -LZ4 -SECCOMP +BLKID -ELFUTILS +KMOD -IDN
Architecture=x86-64
Tainted=local-hwclock
FirmwareTimestampMonotonic=0
LoaderTimestampMonotonic=0
KernelTimestamp=Tue 2015-04-14 00:56:44 AEST
KernelTimestampMonotonic=0
InitRDTimestampMonotonic=0
UserspaceTimestamp=Tue 2015-04-14 00:56:49 AEST
UserspaceTimestampMonotonic=5132302
FinishTimestamp=Mon 2015-04-13 14:58:35 AEST
FinishTimestampMonotonic=111345338
SecurityStartTimestamp=Tue 2015-04-14 00:56:49 AEST
SecurityStartTimestampMonotonic=5147649
SecurityFinishTimestamp=Tue 2015-04-14 00:56:49 AEST
SecurityFinishTimestampMonotonic=5158717
GeneratorsStartTimestamp=Mon 2015-04-13 14:56:50 AEST
GeneratorsStartTimestampMonotonic=5729697
GeneratorsFinishTimestamp=Mon 2015-04-13 14:56:52 AEST
GeneratorsFinishTimestampMonotonic=8130316
UnitsLoadStartTimestamp=Mon 2015-04-13 14:56:52 AEST
UnitsLoadStartTimestampMonotonic=8148385
UnitsLoadFinishTimestamp=Mon 2015-04-13 14:56:53 AEST
UnitsLoadFinishTimestampMonotonic=8988941
LogLevel=info
LogTarget=journal-or-kmsg
NNames=428
NFailedUnits=5
NJobs=0
NInstalledJobs=1543
NFailedJobs=72
Progress=1
Environment=LANG=en_AU.UTF-8 LANGUAGE=en_AU:en PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ConfirmSpawn=no
ShowStatus=no
UnitPath=/etc/systemd/system /run/systemd/system /run/systemd/generator /usr/local/lib/systemd/system /lib/systemd/system /usr/lib/systemd/system /run/systemd
DefaultStandardOutput=journal
DefaultStandardError=journal
RuntimeWatchdogUSec=0
ShutdownWatchdogUSec=10min
SystemState=degraded

The systemd-analyze command will print out the time taken for the system to boot.

[email protected]:~$ systemd-analyze
Startup finished in 5.132s (kernel) + 1min 46.213s (userspace) = 1min 51.345s

To print a bootchart styled svg plot of the boot process of your Linux system, use this command. Then open the svg file in a viewer like Firefox to see the actual boot process. This is a built-in alternative to the bootchart utility for Linux. Another great systemd feature.

[email protected]:~$ systemd-analyze plot > plot.svg

If you want to know if the system is running in a virtual machine, use the systemd-detect-virt command. Information about the virtual machine, (if any) will be printed to the terminal.

No comments have been made. Use this form to start the conversation :)

Leave a Reply