cpu百分比linux,Linux CPU百分比不等于100%(Linux CPU percentages don't add up to 100%)

Linux CPU百分比不等于100%(Linux CPU percentages don't add up to 100%)

每当我尝试从top或mpstat等命令中添加CPU利用率百分比,特别是collectd服务时,我无法达到100%的CPU利用率。

例如,Amazon EC2上的测试服务器的top结果:

Cpu(s): 13.6%us, 31.6%sy, 0.0%ni, 53.2%id, 0.0%wa, 0.0%hi, 0.0%si, 1.7%st

无论我如何将百分比加起来,我从来都不会获得100%的CPU,当然也没有任何合理的方式。 大多数情况下似乎是四舍五入的错误; 100.1%或99.9%,但有时我最终超过110%。 这通常发生在steal相对较高的情况下,例如,收集的一个情况报告〜21.44%偷窃和~88%闲置,只有那两个已经超过100%。 我理解ni (不错)也计入us (用户),所以我不应该添加它,但是仍然无法解决。

有人知道如何添加这些高达100%或如何解释收集有时报告的例外情况?

Whenever I try to add up the CPU utilization percentages from commands like top or mpstat and in particular the collectd service, I can't get to the exact 100% CPU utilization.

For example top results from a test server on Amazon EC2:

Cpu(s): 13.6%us, 31.6%sy, 0.0%ni, 53.2%id, 0.0%wa, 0.0%hi, 0.0%si, 1.7%st

No matter how I add up the percentages, I never quite get 100% CPU, certainly not in any logical way. Mostly it seems like rounding errors; 100.1% or 99.9%, but sometimes I end up with over 110%. This usually happens when steal is relatively high, e.g. one situation from collectd reported ~21.44% steal and ~88% idle, just those two are well over 100% already. I understand the ni (nice) is also counted in us (user), so I shouldn't add it, but that still doesn't work out.

Does anybody know how to add these up to 100% or how to interpret the exceptional cases that collectd sometimes reports?

原文:https://stackoverflow.com/questions/11977391

更新时间:2020-06-19 20:06

最满意答案

collectd (以及top , htop , vmstat或任何其他此类实用程序)报告一个间隔的平均值,并且内核的性质(这些实用程序从中查询其统计信息)通常不使用浮点数学并且不一定试图穷举一切,不能100%准确。 有时它会加起来不到100%,有时甚至更多。 它不是用于审计,只是用于花费时间的一般指示。

collectd (and top, htop, vmstat or any other such utility) reports an average over an interval, and by nature of the kernel (from which these utilities query their statistics) not generally using floating point math and not necessarily trying to exhaustively account for everything, can't be 100% accurate. Sometimes it'll all add up to something less than 100%, sometimes more. It's not intended to be used for an audit, just a general indication of where time is being spent.

2012-08-15

相关问答

因为这里的答案似乎没有正确的解决,这里是使用下划线的半混淆版本: function foo(l, target) {

var off = target - _.reduce(l, function(acc, x) { return acc + Math.round(x) }, 0);

return _.chain(l).

sortBy(function(x) { return Math.round(x) - x }).

map(fun

...

如果没有使用-t或-i选项 ,我可以通过在前台启动容器来重现非阻塞行为。 在那种特殊情况下, Console.ReadLine()不会阻止。 如果使用-i或-t ,则Console.ReadLine阻塞。 此外,如果我在后台运行容器(使用-d选项 ),则Console.ReadLine()被阻止。 如果在前台运行容器,请确保使用-t或-i 。 I can reproduce the non-blocking behaviour by starting a container in the fore

...

感谢大家帮忙。 最终我们升级了(只有一半的java服务器)到JDK 1.6,问题就消失了。 只是不要使用1.5.0.10 :) 我们设法通过访问空指针来重现这些问题(提升SYS而不是US,并杀死整个linux。) 再次感谢大家。 Thanks to everybody for helping out. Eventually we upgraded (only half of the java servers,) to JDK 1.6 and the problem disappeared. Jus

...

你的JavaScript有几个问题。 以下是我可以看到的两个主要问题: 您正在使用parseInt解析一个浮点数(0.14),因为它正在失去精度并且变为0。 像isNumeric和maxLengthCheck这样的方法没有定义。 事实上,你甚至不需要它们。 这是工作代码: $(document).ready(function (){

$('.thepercentage').keyup(function(e){

thenum = $('.thenumber').val()

...

这个怎么样? def adjustAppend( v, n ):

weight= -n/sum(v)

return [ i+i*weight for i in v ] + [n]

给定一个数字列表v ,附加一个新的数字n 。 对现有数字加权以保持总和相同。 sum(v) == sum( v + [n] )

v , i中的每个元素都必须通过i , r ( i )的某个函数来减少 sum(r(i)) == -n

要么 sum( map( r, v ) ) == -n

因此,加

...

嗯,是的,这是正常的。 在任何Javascript运行的确切时刻,CPU都是100%占用。 这是正常的和预期的。 在任何给定时刻,CPU要么100%运行,要么根本不运行。 中间没有。 当你看到50%时,这只是一段时间内的移动平均线,包括半个时间的100%和一半时间的0%。 因此,操作性问题是CPU处于100%的时间。 如果是几毫秒,那没什么。 如果是几分钟,这可能是一个问题。 大多数监控工具会随着时间的推移向您显示更多的移动平均值,因此您不会看到瞬时突发达到100%,但如果您的监控工具向您显示10

...

例如,通过下一个主题: unit Unit2;

interface

uses

Classes;

type

TLoadThread = class(TThread)

public

class var Stop: Boolean;

protected

procedure Execute; override;

public

constructor Create;

end;

implementation

constructor TLoadThrea

...

最好的选择是使用flock()锁定你的文件进行写入 - http://ar2.php.net/flock-使用循环来实现Windows的兼容性,因为flock没有阻塞选项(对你的CentOS无效) ,但无害)。 $max_tries = 5; // don't loop forever

$tbcheck = "refresh.txt";

$tbsend = fopen($tbcheck, 'w');

for ($try=0; $try

if (fl

...

collectd (以及top , htop , vmstat或任何其他此类实用程序)报告一个间隔的平均值,并且内核的性质(这些实用程序从中查询其统计信息)通常不使用浮点数学并且不一定试图穷举一切,不能100%准确。 有时它会加起来不到100%,有时甚至更多。 它不是用于审计,只是用于花费时间的一般指示。 collectd (and top, htop, vmstat or any other such utility) reports an average over an interval, a

...

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值