CPU负载查看工具
- uptime
[root@localhost ~]# uptime 15:24:28 up 5:18, 2 users, load average: 0.00, 0.01, 0.05
显示内容说明:
15:24:28 #系统当前时间 up 5:18 #主机已运行时间(时间越长,说明越稳定) 2 user #用户连接数(总连接数) load average: 0.00, 0.01, 0.05 # 系统平均负载,统计最近1,5,15分钟的系统平均负载
注:
如果每个CPU内核的当前活动进程数小于3,则系统的性能良好。如果每个CPU内核的当前进程数大于5,则性能有严重问题。
- 查找CPU使用最多的进程
- top #按大写P 排序(top本身耗资源,高负载时不建议使用)
[root@localhost ~]# top top - 15:35:16 up 5:28, 2 users, load average: 0.00, 0.01, 0.05 Tasks: 357 total, 2 running, 355 sleeping, 0 stopped, 0 zombie %Cpu(s): 0.3 us, 0.7 sy, 0.0 ni, 99.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st KiB Mem : 1003160 total, 123316 free, 145532 used, 734312 buff/cache KiB Swap: 1048572 total, 1048520 free, 52 used. 635784 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 37994 root 20 0 130156 2028 1268 R 0.7 0.2 0:00.67 top 1 root 20 0 56632 4180 2424 S 0.0 0.4 0:03.68 systemd 2 root 20 0 0 0 0 S 0.0 0.0 0:00.35 kthreadd 3 root 20 0 0 0 0 S 0.0 0.0 0:03.34 ksoftirqd/0 5 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:0H 7 root rt 0 0 0 0 S 0.0 0.0 0:00.00 migration/0 8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcu_bh 9 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/0 10 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/1
- ps # –sort 排序 ,-pcpu 显示绝对路径
[root@localhost ~]# ps -aux --sort -pcpu |head USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 38059 2.6 0.5 403664 5416 ? Sl 15:41 0:00 /usr/libexec/packagekitd root 762 0.1 0.4 268816 4260 ? Ssl 10:06 0:27 /usr/bin/vmtoolsd root 1 0.0 0.4 56632 4180 ? Ss 10:06 0:03 /usr/lib/systemd/systemd --switched-root --system --deserialize 24 root 2 0.0 0.0 0 0 ? S 10:06 0:00 [kthreadd] root 3 0.0 0.0 0 0 ? S 10:06 0:03 [ksoftirqd/0] root 5 0.0 0.0 0 0 ? S< 10:06 0:00 [kworker/0:0H] root 7 0.0 0.0 0 0 ? S 10:06 0:00 [migration/0] root 8 0.0 0.0 0 0 ? S 10:06 0:00 [rcu_bh] root 9 0.0 0.0 0 0 ? S 10:06 0:00 [rcuob/0]
- 查看CPU信息
[root@localhost ~]# cat /proc/cpuinfo processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 42 model name : Intel(R) Core(TM) i5-2520M CPU @ 2.50GHz stepping : 7 microcode : 0x29 cpu MHz : 2491.969 cache size : 3072 KB physical id : 0 siblings : 1 core id : 0 cpu cores : 1 apicid : 0 initial apicid : 0 fpu : yes fpu_exception : yes cpuid level : 13 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf pni pclmulqdq ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx hypervisor lahf_lm ida arat epb pln pts dtherm tsc_adjust bogomips : 4983.93 clflush size : 64 cache_alignment : 64 address sizes : 42 bits physical, 48 bits virtual power management:
- 查看CPU个数
[root@localhost ~]# cat /proc/cpuinfo |grep processor |wc -l 4
- 查看CPU核心数
[root@localhost ~]# cat /proc/cpuinfo |grep "core id" |wc -l 8
- mpstat #查看CPU运行情况
1、安装
[root@localhost ~]# yum -y install sysstat
2、使用
语法:mpstat [t] [n] #t为更新时间,n为次数
[root@localhost ~]# mpstat -P ALL 10 3 Linux 3.10.0-229.el7.x86_64 (localhost.localdomain) 2018年07月17日 _x86_64_ (1 CPU) 16时23分28秒 CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle 16时23分38秒 all 0.00 0.00 0.10 0.00 0.00 0.00 0.00 0.00 0.00 99.90 16时23分38秒 0 0.00 0.00 0.10 0.00 0.00 0.00 0.00 0.00 0.00 99.90 16时23分38秒 CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle 16时23分48秒 all 0.10 0.00 0.00 0.00 0.00 0.10 0.00 0.00 0.00 99.80 16时23分48秒 0 0.10 0.00 0.00 0.00 0.00 0.10 0.00 0.00 0.00 99.80 16时23分48秒 CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle 16时23分58秒 all 0.10 0.00 0.30 0.00 0.00 0.00 0.00 0.00 0.00 99.60 16时23分58秒 0 0.10 0.00 0.30 0.00 0.00 0.00 0.00 0.00 0.00 99.60 平均时间: CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle 平均时间: all 0.07 0.00 0.13 0.00 0.00 0.03 0.00 0.00 0.00 99.77 平均时间: 0 0.07 0.00 0.13 0.00 0.00 0.03 0.00 0.00 0.00 99.77
显示参数说明:
%user :CPU使用占比,不包含nice值为负进程 (usr/total)*100 %nice:低优先级进程使用CPU占比,nice值为负进程的CPU时间(%) (nice/total)*100 %sys :系统使用CPU占比,内核时间(%) (system/total)*100 %iowait :CPU等待IO占比,硬盘IO等待时间(%) (iowait/total)*100 %irq :CPU处理硬中断占比,硬中断时间(%) (irq/total)*100 %soft :CPU处理软中断占比,软中断时间(%) (softirq/total)*100 %idle: CPU空闲占比,闲置时间(%) (idle/total)*100
温馨提示:如无特殊说明,本站文章均为作者原创,转载请注明出处!