可以通过 uptime、w、top 等指令获取道系统平均负载(load average)信息。

比如使用 uptime 获取到的信息:

16:11:21 up 419 days, 22:46,  2 users,  load average: 0.25, 0.26, 0.26

man uptime 查看指令手册,里面有对于返回内容的具体描述,包含了 load average 的定义:

       uptime  gives  a one line display of the following information.  The current time, how long the system has been running, how many users are currently logged on, and the system load averages for the
       past 1, 5, and 15 minutes.

       This is the same information contained in the header line displayed by w(1).

       System load averages is the average number of processes that are either in a runnable or uninterruptable state.  A process in a runnable state is either using the CPU or waiting to use the CPU.   A
       process in uninterruptable state is waiting for some I/O access, eg waiting for disk.  The averages are taken over the three time intervals.  Load averages are not normalized for the number of CPUs
       in a system, so a load average of 1 means a single CPU system is loaded all the time while on a 4 CPU system it means it was idle 75% of the time.

uptime 将以下信息一行展示。当前时间,系统已经运行的时长,当前已登录的用户数量,还有过去 1 分钟、5 分钟、15 分钟内的系统平均负载。

这与 w 指令头行展示的信息一样。

系统平均负载是处于可运行或不可中断状态进程的平均数。一个处于可运行状态的进程要么是在使用 CPU,要么是在登录使用 CPU。而一个处于不可中断状态的进程是在等待某些 I/O 访问,比如等待磁盘。平均数就取自这三个时间间隔。负载平均数未针对在一个系统中CPU数量进行标准化,因此平均负载为1意味着单个CPU系统一直处于加载状态,而在一个 4 CPU系统中,这意味着它75% 的时间处于空闲状态。

最后翻译的 CPU 个数应该对应的是 CPU 的总核数。所以转化为百分之应该是

系统平均负载率 = 系统单位时间的平均负载 / CPU 总核数

查看 CPU 核心数:grep -c 'model name' /proc/cpuinfogrep 'model name' /proc/cpuinfo |wc -l

它可以用来衡量一个系统的负载状态,是否顺畅或者阻塞。当然这个数值与宝塔面板的负载不一致,猜测后者应该有自己的计算公式。