使用systemd

您所在的位置:网站首页 怎么看进程启动时间 使用systemd

使用systemd

2024-06-01 04:53| 来源: 网络整理| 查看: 265

systemd-analyze是一个分析启动性能的工具,用于分析启动时服务时间消耗。默认显示启动是内核和用户空间的消耗时间:使用systemd-analyze plot > boot.svg生成一张启动详细信息矢量图,然后用图像浏览器或者网页浏览器打开查看 。

[root@localhost~]#systemd-analyze Startupfinishedin818ms(kernel)+6.240s(initrd)+32.979s(userspace)=40.038s  和使用systemd-analyzetime命令的效果一样。

(1)查看详细的每个服务消耗的启动时间通过systemd-analyzeblame命令查看详细的每个服务消耗的启动时间:

[root@localhost~]#systemd-analyzeblame 30.852siscsi.service 16.994skdump.service 10.871sboot.mount ... 103mssystemd-sysctl.service 101msdatapool.mount 

(2)查看严重消耗时间的服务树状表systemd-analyzecritical-chain命令打印严重消耗时间的服务树状表,按照启动消耗的时间进行排序,时间消耗越多,越排到前面。@之后是服务激活或者启动的时间,+号之后是服务启动消耗的时间。个人理解@是从系统引导到服务启动起来的时间,是一个相对时间消耗,+是服务启动消耗的时间,是一个绝对时间消耗。

[root@localhost~]#systemd-analyzecritical-chain Thetimeaftertheunitisactiveorstartedisprintedafterthe"@"character. Thetimetheunittakestostartisprintedafterthe"+"character. [email protected] └─[email protected]+16.994s └─[email protected] └─[email protected]+54ms └─[email protected]+535ms └─[email protected] └─[email protected] └─[email protected] └─[email protected] └─[email protected]+2ms └─[email protected]+67ms

(3)打印分析图及其他命令systemd-analyzeplot打印一个svg格式的服务消耗时间表,通过浏览器可以以图形的方式展示,非常直观:

[root@localhost~]#systemd-analyze plot>plot.svg   systemd-analyzedot用分隔符产生当前服务 systemd-analyzedump以友好方式显示当前服务状态 6systemd文件类型及存放位置 systemd配置文件被称为unit单元,根据类型不同,以不同的扩展名结尾。 .service系统服务; .target一组系统服务; .automount自动挂载点; .device能被内核识别的设备; .mount挂载点; .path文件系统的文件或者目录; .scope外部创建的进程; .slice一组分层次管理的系统进程; .snapshot系统服务状态管理; .socket进程间通讯套接字; .swap定义swap文件或者设备; .timer定义定时器。

最后再总结一下:

# 查看启动耗时$ systemd-analyze

# 查看每个服务的启动耗时$ systemd-analyze blame

# 显示瀑布状的启动过程流$ systemd-analyze critical-chain

# 显示指定服务的启动流$ systemd-analyze critical-chain atd.service

查看所有的服务systemctl list-units --type=service



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3