systemd-analyze – Find System Boot-up Performance Statistics in Linux

[‘

n

Are you using systemd system and service manager, and your Linux system taking longer time to boot or you simple want to view the reports of your system boot-up performance? If yes, you have landed on the right place.

n

In this article, we will show you how to analyze a Linux system boot-up performance statistics using systemd-analyze, one of numerous utilities under systemd for system management.

n

Read Also: How to Control Systemd Services on Remote Linux Server

n

To get an overview of the system boot-up time, we can run systemd-analyze command without any arguments as follows. It will list information about how much time each service took to start, which includes time taken by kernel, initrd and userspace while booting.

n

# systemd-analyzernrnStartup finished in 884ms (kernel) + 3.861s (initrd) + 48.356s (userspace) = 53.102srn

n

If you want to view a list of all running units, sorted by the time they took to initialize (highest time on top), the blame sub-command is used for this purpose. After running the command that follows, use [Enter] to view more services in the list and q to quit.

n

# systemd-analyze blame rn

n

Find Out Time Each Unit Took to Start

n

         16.159s mariadb.servicern         12.178s libvirtd.servicern         10.298s tuned.servicern          9.836s postfix.servicern          8.704s lsws.servicern          7.352s lscpd.servicern          4.988s [emailxa0protected]rn          4.779s NetworkManager-wait-online.servicern          4.577s lvm2-monitor.servicern          4.439s ModemManager.servicern          4.413s polkit.servicern          4.280s dev-sda1.devicern          4.225s systemd-udev-settle.servicern          3.957s firewalld.servicern          3.227s rhel-dmesg.servicern          3.221s abrt-ccpp.servicern          3.142s rsyslog.servicern          3.053s avahi-daemon.servicern          3.042s pure-ftpd.servicern          2.249s gssproxy.servicern          2.212s NetworkManager.servicern          1.889s proc-fs-nfsd.mountrn          1.780s systemd-tmpfiles-setup-dev.servicern          1.451s sshd.servicern          1.267s rhel-readonly.servicern          1.035s sysstat.servicern          1.001s rpc-statd-notify.servicern           910ms systemd-logind.servicern           739ms kdump.servicern           738ms network.servicern...rn

n

As you can see from the above output that each unit is sorted based on the time taken, you can simply find out which service is taking longer time while booting and analyze the issue.

n

Next, we can also view a tree of the time-critical chain for the default target or a list of specified units with the critical-chain sub-command as shown.

n

# systemd-analyze critical-chain  rn

n

Print time-critical Chain for Default Target

n

The time after the unit is active or started is printed after the "@" character.rnThe time the unit takes to start is printed after the "+" character.rnrnmulti-user.target @48.342srn└─mariadb.service @31.560s +16.159srn  └─network.target @31.558srn    └─network.service @30.819s +738msrn      └─NetworkManager-wait-online.service @26.035s +4.779srn        └─NetworkManager.service @23.821s +2.212srn          └─network-pre.target @23.821srn            └─firewalld.service @19.863s +3.957srn              └─polkit.service @15.381s +4.413srn                └─basic.target @12.271srn                  └─sockets.target @12.271srn                    └─virtlockd.socket @12.270srn                      └─sysinit.target @12.251srn                        └─systemd-update-utmp.service @12.196s +54msrn                          └─auditd.service @11.705s +486msrn                            └─systemd-tmpfiles-setup.service @11.609s +93msrn                              └─rhel-import-state.service @11.397s +211msrn                                └─local-fs.target @11.363srn                                  └─run-user-0.mount @46.910srn                                    └─local-fs-pre.target @10.575srn                                      └─lvm2-monitor.service @5.996s +4.577srn                                        └─lvm2-lvmetad.service @7.376srn                                          └─lvm2-lvmetad.socket @5.987srn                                            └─-.slicern

n

# systemd-analyze critical-chain ntp.service networking.servicern

n

Finally, let’s look at one more important sub-command that allows for producing graphical (svg format) detailing of system services that have been started, and at what time, highlighting their initialization time, as follows.

n

Make sure graphical display mode or x-windows is enabled in order to view the plot.

n

# systemd-analyze plot > boot_analysis.svgrn# xviewer boot_analysis.svg  rn

n

Linux Boot Analysis
Linux Boot Analysis

n

All the above commands will print the boot-up performance statistics for the local machine. To view information from a remote host over ssh, use the -H flag and specify the [emailxa0protected] directive, as shown.

n

# systemd-analyze time -H [emailxa0protected]rn# systemd-analyze blame -H [emailxa0protected]rn# systemd-analyze critical-chain -H [emailxa0protected]rn

n

systemd-analyze can also be used to find other state and tracing information from the system and systemd (service manager) and more. For more information, see its man page.

n

# man systemd-analyze rn

n

Read Also: How to Change Runlevels (targets) in SystemD

n

That’s it for now! If you have any questions or thought to share, use the feedback form below to reach us.

n

‘]