我使用了 Ubuntu 16.04。我发现一些服务将通过systemctl status <name>.service以下方式显示 CPU 和内存使用情况:
$ systemctl status nginx
? nginx.service - LSB: Stop/start nginx
Loaded: loaded (/etc/init.d/nginx; bad; vendor preset: enabled)
Active: active (running) since ? 2017-04-07 09:21:25 CST; 4h 59min ago
Docs: man:systemd-sysv-generator(8)
Process: 2677 ExecStart=/etc/init.d/nginx start (code=exited, status=0/SUCCESS)
Tasks: 2
Memory: 2.5M
CPU: 12ms
CGroup: /system.slice/nginx.service
??2695 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.con
??2697 nginx: worker process
Run Code Online (Sandbox Code Playgroud)
但是在另一台主机上,我发现systemctl status不会显示 CPU 和内存使用情况:
$ systemctl status nginx
? nginx.service - LSB: Stop/start nginx
Loaded: loaded (/etc/init.d/nginx; bad; vendor preset: enabled)
Active: active (running) since ? 2017-04-06 20:57:15 CST; 17h ago
Docs: man:systemd-sysv-generator(8)
CGroup: /system.slice/nginx.service
??29668 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.con
??29669 nginx: worker process
??29670 nginx: worker process
??29671 nginx: worker process
??29672 nginx: worker process
Run Code Online (Sandbox Code Playgroud)
为什么?两者nginx都是从 nginx 官方 repo 安装的apt install -y nginx。即使在同一台主机上,某些服务也不会显示 CPU 和内存使用情况。
以及如何在 systemctl status 中显示 CPU 和内存使用情况?
geo*_*xsh 10
我不知道为什么有些主机可以但有些不能,如果您想要一致的行为,您应该通过设置为单个单元或默认为所有单元启用内存帐户:
DefaultMemoryAccounting=yes
Run Code Online (Sandbox Code Playgroud)
在/etc/systemd/system.conf然后做:
systemctl daemon-reexec
Run Code Online (Sandbox Code Playgroud)
从 systemd 开发人员那里查看此列表线程,以及systemd-system.conf[5]。
| 归档时间: |
|
| 查看次数: |
8402 次 |
| 最近记录: |