synchronization
Some checks failed
continuous-integration/drone Build is failing

This commit is contained in:
2025-08-25 15:57:40 +08:00
commit cee91802b3
106 changed files with 9124 additions and 0 deletions

44
Docs/检测CPU负载.md Normal file
View File

@@ -0,0 +1,44 @@
> 本文作者:丁辉
# 检测CPU负载
## 介绍
CPU利用率可以用以下公式计算
CPU利用率(%) = 1 - (闲置时间 / 总时间) x 100
**解释**
- **闲置时间**在指定的时间段内CPU处于闲置状态的时间总和。
- **总时间**这个时间段的总时长通常包括CPU的工作时间和闲置时间。
## 脚本检测
- 使用 Sysstat 工具检测 CPU 负载
1. 安装 Sysstat
- Centos
```bash
yum -y install sysstat
```
- Ubuntu
```bash
apt-get -y install sysstat
```
2. 执行脚本
```bash
curl -sfL https://gitee.com/offends/Linux/raw/main/File/Shell/check-cpu-sysstat.sh | bash
```
- 根据 `/proc/stat` 数据计算 CPU 负载
```bash
curl -sfL https://gitee.com/offends/Linux/raw/main/File/Shell/check-cpu.sh | bash
```