我想问题是,我可以通过读取一次 /proc/stat 以某种方式计算 CPU 利用率百分比吗?
# head -1 /proc/stat
cpu 67891300 39035 6949171 2849641614 118251644 365498 2341854 0
Run Code Online (Sandbox Code Playgroud)
我正在考虑总结除 IOWait 之外的列(我在某处阅读它被计算在空闲状态),这会给我 100% 并且每个单独的列都可以通过 (column/100_percent)*100 转换为百分比。
这是一种可行的方法还是我完全偏离了轨道?
这不是我人生中第一次必须说服小公司使用 DNS 服务而不是 /etc/hosts 文件和 IP 地址。第一次看起来可能很傻/有趣,但想象一下,有许多管理员很懒惰或根本不在乎,他们拒绝实施此服务。我们可以收集用例和这样做的原因吗?
您对这种情况有什么经验吗?请分享!
这是一个非常奇怪的问题,但在新系统(Fedora、Ubuntu)上 ctrl+c 对某些工具无效:
如果我执行运行近一分钟的 yum list 我不能中断运行 ctrl+c
$time yum list >/dev/null
^C^C^C^C^C^C^C^C^C
Run Code Online (Sandbox Code Playgroud)
命令执行不会停止。
然而,中断查找是可能的。
$ time find / >/dev/null 2>&1
^C
real 0m0.741s
user 0m0.033s
sys 0m0.124s
Run Code Online (Sandbox Code Playgroud)
我很好奇是什么原因造成的。
我必须进行以下设置:
$ stty -a
speed 38400 baud; rows 36; columns 158; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase …Run Code Online (Sandbox Code Playgroud) 我不确定为什么会发生这种情况,但这些是完全错误的结果:
Children see throughput for 15 re-readers = 12793134.62 KB/sec
Parent sees throughput for 15 re-readers = 12753940.84 KB/sec
Min throughput per process = 515695.50 KB/sec
Max throughput per process = 1088000.75 KB/sec
Avg throughput per process = 852875.64 KB/sec
Min xfer = 249856.00 KB
Children see throughput for 15 random readers = 12667347.75 KB/sec
Parent sees throughput for 15 random readers = 12613558.90 KB/sec
Min throughput per process = 685239.00 KB/sec
Max throughput per process = 1318021.25 KB/sec
Avg …Run Code Online (Sandbox Code Playgroud)