ow can /proc/loadavg be used ?

本文详细解释了Linux内核如何计算系统负载平均值,包括等待输入的进程是否准备好运行,以及如何评估CPU使用率和I/O操作的影响。通过分析不同时间段的负载平均值,可以判断系统的健康状况和资源分配效率。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

参见:http://unix.derkeiler.com/Newsgroups/comp.unix.shell/2006-11/msg00577.html

Re: How can /proc/loadavg be used ?



Bo Yang <struggle@xxxxxxxxxxxxxxxxxx> writes:

In linux proc filesystem , there is a file
loadavg , it contain three fields seperately
describe the last 1 , 5 , 15 minutes load average .



also avalable in the uptime(1) command for older systems.
The top(1) program shows this as well.

And my question is , how the kernel calculate
these three number ,



The load average is the number of jobs that are ready to run at that time.
Let me give some more detail.

If a process is sleeping because it's waiting for input, it's not
ready to run. So a process waiting for a disk or network input is NOT
ready to run. A process that was using 100% CPU and 0% disk is always
ready to run.

Rarely are jobs 100% CPU or 100% I/O. It's always a mixture.

Three important points

The load average is the number of processes that could run if the
scheduler let them run. A dual core CPU could handle 2 processes using
100% CPU. If that is all that is running, it's fine.

The second is - how quickly do these jobs complete?
If another process starts, and completes quickly - fine.

The third is - how do these numbers look at 1 minute, 5 minutes and 15
minutes, and how do they change.


load average: 10.00, 5.03, 1.00

- this is trouble. The load average is increasing.

load average: 1.00, 5.03, 10.00

- The opposite. The load average was 10.0 fifteen minutes ago,
and the CPU is recovering.


load average: 4.00, 4.03, 4.00

- a steady load

and how big the number is
for a normal running server ?



There is no simple answer. If the computer is able to complete the
jobs in sufficient time, then it is fine. Sufficient is something you
have to define. We can't do that.
Examples:

Web server
Mail server
Financial Database
Simulation server

All of these systems have different requirements for completion of a
job. A load average of 10 may be fine for one, and a disaster for
another.

You can look at other tools as well.
I like top(1) as it shows a lot of information, including percent idle.


p.s. Your English is better than my Chinese.

### 回答1: nered by uid 这个错误提示意味着你在使用sudo命令时,没有root权限。sudo命令需要root权限才能执行,因此你需要以root用户身份登录或者使用su命令切换到root用户,然后再执行sudo命令。如果你不知道如何以root用户身份登录或者使用su命令,请参考相关的Linux教程。 ### 回答2: 这是一个 Linux 系统中常见的错误提示。它表示当前用户在尝试使用 sudo 命令以管理员权限执行命令时,因为缺少必要的权限,无法正常执行命令。 通常情况下,这个问题会出现在以下几种情况中: 1. 当前用户没有使用 sudo 命令的权限; 2. /usr/bin/sudo 的文件权限或所有者被修改了; 3. sudo 配置文件出现了错误; 4. 系统环境中出现了异常。 解决这个问题的方法有很多种,但以下是其中一种可能的步骤: 1. 确认当前用户是否具有使用 sudo 命令的权限。可以使用命令 "groups <username>" 来查看当前用户所属的用户组。如果当前用户不在 sudo 用户组中,则无法使用 sudo 命令。 2. 确认 /usr/bin/sudo 文件的权限和所有者。可以使用命令 "ls -l /usr/bin/sudo" 来查看文件的详细属性,确保文件权限为 4755,所有者为 root。 3. 确认 sudo 配置文件是否正确配置。通常情况下,sudo 的配置文件为 /etc/sudoers。可以使用命令 "sudo visudo" 来编辑该文件。确保文件中没有语法错误并且当前用户被正确配置。 4. 如果以上步骤都没有解决问题,那么可能是系统环境出现了异常。可以尝试重启系统,如果问题依旧存在,则需要进一步排查系统环境中是否存在其他问题。 需要注意的是,在尝试解决这个问题时,应该遵循安全措施并且谨慎操作,避免对系统造成不必要的风险。 ### 回答3: 对于这个问题,“sudo: /usr/bin/sudo must be own”通常是由于特定的权限或者所有权问题导致的。sudo命令是一个允许普通用户以超级用户权限运行单个命令或者整个shell的工具。 sudo命令需要像setuid用户一样工作,即它必须具有与root用户相同的权限。但是,如果sudo二进制文件的所有权或权限被错误地更改,则无法使用sudo命令。 通常,此错误可能是由于以下原因之一导致的: 1.未正确安装sudo二进制文件 2. 权限问题,如sudo二进制文件的所有者/组,以及文件的读写执行权限。 为解决此问题,可以执行以下操作之一: 1.通过从Linux软件包存储库用apt-get或yum或其他操作系统管理器重新安装sudo软件包. 安装方法如下: Ubuntu/Debian: sudo apt-get update sudo apt-get install sudo CentOS: sudo yum update sudo yum install sudo 2. 确认sodu二进制文件的所有权和权限正确,并赋予相应的权限。确保sudo二进制文件所有者是root,文件权限设置为4755 sudo chown root:root /usr/bin/sudo sudo chmod 4755 /usr/bin/sudo 如果以上两种方法均不能解决问题,那么可能是其他权限或安全性问题所引起。 在这种情况下,最好与系统管理员或Linux技术支持团队联系以进行更进一步的排错。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值