获取平均负载
————————————————————————————————————————————————————————————————————————————
笔者一般使用两条命令获取平均负载:
uptime1
2[root@con02 ~]# uptime
15:37:00 up 814 days, 22:02, 4 users, load average: 0.87, 0.83, 0.82
top1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55top - 15:37:37 up 814 days, 22:02, 4 users, load average: 1.01, 0.87, 0.84
Tasks: 644 total, 2 running, 642 sleeping, 0 stopped, 0 zombie
%Cpu(s): 4.2 us, 0.9 sy, 0.0 ni, 94.8 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 65858136 total, 8405052 free, 37853144 used, 19599940 buff/cache
KiB Swap: 0 total, 0 free, 0 used. 23213220 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
31919 nova 20 0 6284804 108152 16248 R 35.3 0.2 52:59.05 nova-compute
32023 nova 20 0 499104 95988 3664 S 23.5 0.1 9:26.80 nova-conductor
32005 nova 20 0 499616 96448 3660 S 17.6 0.1 9:23.34 nova-conductor
32014 nova 20 0 499288 96220 3664 S 17.6 0.1 9:19.99 nova-conductor
32025 nova 20 0 499008 95772 3664 S 17.6 0.1 9:24.99 nova-conductor
21167 root 20 0 147744 2452 1388 R 11.8 0.0 0:00.02 top
32028 nova 20 0 499692 96616 3660 S 11.8 0.1 10:28.59 nova-conductor
72 root 20 0 0 0 0 S 5.9 0.0 90:48.89 ksoftirqd/3
7329 root 20 0 41992 23172 21824 S 5.9 0.0 30:39.54 sap1007
7893 qemu 20 0 10.171g 5.320g 12468 S 5.9 8.5 92:06.55 qemu-kvm
10461 qemu 20 0 6319884 224920 12192 S 5.9 0.3 80:59.01 qemu-kvm
13771 glance 20 0 714392 66352 5760 S 5.9 0.1 557:17.33 glance-api
31637 mysql 20 0 15.114g 3.001g 138444 S 5.9 4.8 2315:34 mysqld
32002 nova 20 0 498576 95528 3664 S 5.9 0.1 10:26.97 nova-conductor
32004 nova 20 0 499644 96488 3664 S 5.9 0.1 10:43.25 nova-conductor
32007 nova 20 0 499436 96344 3660 S 5.9 0.1 10:26.56 nova-conductor
32021 nova 20 0 498600 95548 3660 S 5.9 0.1 9:46.67 nova-conductor
1 root 20 0 338680 4888 1940 S 0.0 0.0 80:02.58 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:42.26 kthreadd
3 root 20 0 0 0 0 S 0.0 0.0 132:42.57 ksoftirqd/0
5 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:0H
8 root rt 0 0 0 0 S 0.0 0.0 10:13.38 migration/0
9 root 20 0 0 0 0 S 0.0 0.0 0:00.01 rcu_bh
10 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/0
11 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/1
12 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/2
13 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/3
14 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/4
15 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/5
16 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/6
17 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/7
18 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/8
19 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/9
20 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/10
21 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/11
22 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/12
23 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/13
24 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/14
25 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/15
26 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/16
27 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/17
28 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/18
29 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/19
30 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/20
31 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/21
32 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/22
33 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/23
34 root 20 0 0 0 0 S 0.0 0.0 5143:32 rcu_sched
负载就是上面的load average: 0.87, 0.83, 0.82,分别表示过去一分钟,五分钟,十五分钟的负载
负载代表什么
——————————————————————————————————————————————————————————————————————————————
上面的负载值代表的其实是系统中的活跃进程数,包括正在运行和不可中断运行(比如一些内核态的写磁盘调度)
如何判断负载是高还是低
——————————————————————————————————————————————————————————————————————————————
1.首先需要查看系统中有多少cpu
1
2[root@con02 ~]# grep "model name" /proc/cpuinfo | wc -l
242.比较负载值和cpu数目
如果负载值大于cpu数目,name系统就处于超负载状态
查看分析负载工具
—————————————————————————————————————————————————————————————————————————————
1.mpstat
查看多个cpu的性能使用情况2.pidstat
查看进程的性能
压测工具
—————————————————————————————————————————————————————————————————————————————
- 1.stress
这个stress可以压测cpu,内存和磁盘io