找出占用cpu内存过高的进程
准备
//分析占用CPU最高的应用
[root@dy1 ~]# ps -eo user,pid,pcpu,pmem,args --sort=-pcpu |head -n 10
USER PID %CPU %MEM COMMAND
root 7365 1.0 0.0 ps -eo user,pid,pcpu,pmem,args --sort=-pcpu
root 46 0.2 0.0 [kworker/0:2]
root 1 0.1 0.1 /usr/lib/systemd/systemd --switched-root --system --deserialize 22
root 3175 0.1 0.1 /usr/lib/systemd/systemd-udevd
root 6581 0.1 0.3 /usr/bin/vmtoolsd
root 2 0.0 0.0 [kthreadd]
root 3 0.0 0.0 [ksoftirqd/0]
root 5 0.0 0.0 [kworker/0:0H]
root 6 0.0 0.0 [kworker/u256:0]
//分析占用内存最高的应用
[root@dy1 ~]# ps -eo user,pid,pcpu,pmem,args --sort=-pmem |head -n 10
USER PID %CPU %MEM COMMAND
root 6925 0.0 0.8 /usr/bin/python2 -Es /usr/sbin/tuned -l -P
polkitd 6578 0.0 0.6 /usr/lib/polkit-1/polkitd --no-debug
root 6580 0.0 0.6 /usr/sbin/NetworkManager --no-daemon
root 6927 0.0 0.5 /usr/sbin/rsyslogd -n
root 6581 0.1 0.3 /usr/bin/vmtoolsd
root 6311 0.0 0.3 /usr/bin/VGAuthService -s
root 7206 0.0 0.2 sshd: root@pts/0
root 6696 0.0 0.2 /sbin/dhclient -d -q -sf /usr/libexec/nm-dhcp-helper -pf /var/run/dhclient-eth0.pid -lf /var/lib/NetworkManager/dhclient-5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03-eth0.lease -cf /var/lib/NetworkManager/dhclient-eth0.conf eth0
root 6697 0.0 0.2 /sbin/dhclient -d -q -sf /usr/libexec/nm-dhcp-helper -pf /var/run/dhclient-eth1.pid -lf /var/lib/NetworkManager/dhclient-0121e71e-c281-3df3-a790-c05e7f76cda1-eth1.lease -cf /var/lib/NetworkManager/dhclient-eth1.conf eth1
整合
#!/bin/bash
echo "-------------------CUP占用前10排序--------------------------------"
ps -eo user,pid,pcpu,pmem,args --sort=-pcpu |head -n 10
echo "-------------------内存占用前10排序--------------------------------"
ps -eo user,pid,pcpu,pmem,args --sort=-pmem |head -n 10
————————————————