查看服务的CPU利用率
2023-06-13 09:17:46 时间
01.获取服务的当前CPU份额(比如httpd)
# systemctl show -p CPUShares httpd.service CPUShares=1024
注意:每个服务的默认值都为CPUShare = 1024.您可以增加/减少进程的CPU份额。
02.将服务的CPU份额(httpd.service)限制为2000 CPUShares /
# systemctl set-property httpd.service CPUShares=2000 # systemctl show -p CPUShares httpd.service CPUShares=2000
注意:为服务设置CPUShare时,会创建一个名为service的目录(httpd.service.d),其中包含一个包含CPUShare Limit信息的文件90-CPUShares.conf。 您可以将文件视为:
# vi /etc/systemd/system/httpd.service.d/90-CPUShares.conf [Service] CPUShares=2000
03.检查服务的所有配置详细信息
# systemctl show httpd Id=httpd.service Names=httpd.service Requires=basic.target Wants=system.slice WantedBy=multi-user.target Conflicts=shutdown.target Before=shutdown.target multi-user.target After=network.target remote-fs.target nss-lookup.target systemd-journald.socket basic.target system.slice Description=The Apache HTTP Server LoadState=loaded ActiveState=active SubState=running FragmentPath=/usr/lib/systemd/system/httpd.service ....
04.分析服务的关键链(httpd)
# systemd-analyze critical-chain httpd.service The time after the unit is active or started is printed after the "@" character. The time the unit takes to start is printed after the "+" character. httpd.service +142ms └─network.target @11.168s └─network.service @9.456s +1.712s └─NetworkManager.service @8.858s +596ms └─firewalld.service @4.931s +3.926s └─basic.target @4.916s └─sockets.target @4.916s └─dbus.socket @4.916s └─sysinit.target @4.905s └─systemd-update-utmp.service @4.864s +39ms └─auditd.service @4.563s +301ms └─systemd-tmpfiles-setup.service @4.485s +69ms └─rhel-import-state.service @4.342s +142ms └─local-fs.target @4.324s └─boot.mount @4.286s +31ms └─systemd-fsck@dev-disk-by/x2duuid-79f594ad/x2da332/x2d4730/x2dbb5f/x2d85d196080964.service @4.092s +149ms └─dev-disk-by/x2duuid-79f594ad/x2da332/x2d4730/x2dbb5f/x2d85d196080964.device @4.092s
29.获取服务的依赖项列表(httpd)
# systemctl list-dependencies httpd.service httpd.service ├─system.slice └─basic.target ├─firewalld.service ├─microcode.service ├─rhel-autorelabel-mark.service ├─rhel-autorelabel.service ├─rhel-configure.service ├─rhel-dmesg.service ├─rhel-loadmodules.service ├─paths.target ├─slices.target │ ├─-.slice │ └─system.slice ├─sockets.target │ ├─dbus.socket ....
05.按层次列出控制组
# systemd-cgls ├─1 /usr/lib/systemd/systemd --switched-root --system --deserialize 23 ├─user.slice │ └─user-0.slice │ └─session-1.scope │ ├─2498 sshd: root@pts/0 │ ├─2500 -bash │ ├─4521 systemd-cgls │ └─4522 systemd-cgls └─system.slice ├─httpd.service │ ├─4440 /usr/sbin/httpd -DFOREGROUND │ ├─4442 /usr/sbin/httpd -DFOREGROUND │ ├─4443 /usr/sbin/httpd -DFOREGROUND │ ├─4444 /usr/sbin/httpd -DFOREGROUND │ ├─4445 /usr/sbin/httpd -DFOREGROUND │ └─4446 /usr/sbin/httpd -DFOREGROUND ├─polkit.service │ └─721 /usr/lib/polkit-1/polkitd --no-debug ....
06.根据CPU,内存,输入和输出列出控制组
# systemd-cgtop Path Tasks %CPU Memory Input/s Output/s / 83 1.0 437.8M - - /system.slice - 0.1 - - - /system.slice/mariadb.service 2 0.1 - - - /system.slice/tuned.service 1 0.0 - - - /system.slice/httpd.service 6 0.0 - - - /system.slice/NetworkManager.service 1 - - - - /system.slice/atop.service 1 - - - - /system.slice/atopacct.service 1 - - - - /system.slice/auditd.service 1 - - - - /system.slice/crond.service 1 - - - - /system.slice/dbus.service 1 - - - - /system.slice/firewalld.service 1 - - - - /system.slice/lvm2-lvmetad.service 1 - - - - /system.slice/polkit.service 1 - - - - /system.slice/postfix.service 3 - - - - /system.slice/rsyslog.service 1 - - - - /system.slice/system-getty.slice/getty@tty1.service 1 - - - - /system.slice/systemd-journald.service 1 - - - - /system.slice/systemd-logind.service 1 - - - - /system.slice/systemd-udevd.service 1 - - - - /system.slice/webmin.service 1 - - - - /user.slice/user-0.slice/session-1.scope 3 - - - -
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/59184.html
apacheMD相关文章
- 量深入探索——查看Linux系统的CPU数量(linux查看cpu数)
- Linux命令行查看系统CPU性能(linux查看系统cpu)
- Linux查看CPU核数的简单方法(linux查看cpu核数)
- 使用率Linux下掌握CPU使用率的命令技巧(linux命令查看cpu)
- 利用率linux CPU利用率最高化的突破口(linux占cpu)
- 占用Linux下查看进程CPU占用情况(linux查看进程cpu)
- 信息Linux系统深入探索:查看CPU信息(linux系统查看cpu)
- 型号Linux系统查看CPU型号的方法(linux如何看cpu)
- Linux在物理CPU上的表现(linux物理cpu)
- 教你如何在Linux上查看CPU信息(linux看cpu)
- Linux查看CPU详解:如何掌握CPU信息?(linux查cpu)
- MySQL如何查看CPU使用情况(mysql查看cpu)
- “提升Linux系统性能:调整CPU频率”(cpu频率linux)
- 如何在Linux系统中查看CPU信息?(linux查cpu信息)
- 如何在Linux系统中查询CPU型号(linux查询cpu型号)
- 如何查看Linux系统的CPU使用情况(怎么查linux的cpu)
- 利用Oracle管理系统查询CPU性能(oracle查询cpu)
- 深入查看Linux系统中CPU占用率(linux查看占用cpu)
- Linux下检查CPU温度的小窍门(linux查看cpu温度)
- 使用率Linux下查看CPU使用率的方法(linux如何查看cpu)
- CPU连接MySQL的正确姿势(cpu如何连接mysql)
- 使用Oracle CPU,提高运算效率吧(oracle cpu用户)