1. 查看消耗CPU资源最多的前10个进程
[root@localhost ~]# ps auxw | head -1;ps auxw |sort -rn -k3 |head -11
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1456 4.7 1.4 1128168 28884 ? S<l Mar30 269:35 /usr/local/vpnserver/vpnserver execsvc
root 10763 1.0 0.0 110240 1176 pts/1 R+ 17:00 0:00 ps auxw
zabbix 10522 0.0 0.1 81476 2344 ? S Apr02 0:05 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]
zabbix 10521 0.0 0.0 81336 1532 ? S Apr02 0:19 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
zabbix 10519 0.0 0.0 81336 1420 ? S Apr02 0:00 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 969 0.0 0.0 0 0 ? S Mar30 0:00 [kauditd]
root 9491 0.0 0.0 108316 1904 pts/0 Ss+ Mar31 0:00 -bash
root 9486 0.0 0.2 100060 4060 ? Ss Mar31 0:00 sshd: root@pts/0
root 916 0.0 0.0 0 0 ? S Mar30 0:00 [ext4-dio-unwrit]
root 915 0.0 0.0 0 0 ? S Mar30 0:00 [jbd2/sda2-8]
[root@localhost ~]#
2. 查看消耗内存资源最多的前10个进程
[root@localhost ~]# ps auxw | head -1;ps auxw |sort -rn -k4 |head -11
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1456 4.7 1.4 1128168 28884 ? S<l Mar30 269:49 /usr/local/vpnserver/vpnserver execsvc
root 9486 0.0 0.2 100060 4060 ? Ss Mar31 0:00 sshd: root@pts/0
root 10449 0.0 0.2 100056 4036 ? Ss Apr02 0:00 sshd: root@pts/1
zabbix 10522 0.0 0.1 81476 2344 ? S Apr02 0:05 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]
root 9082 0.0 0.1 12016 2276 ? S< Mar30 0:00 /sbin/udevd -d
root 9068 0.0 0.1 12140 2404 ? S< Mar30 0:00 /sbin/udevd -d
root 1426 0.0 0.1 81012 3464 ? Ss Mar30 0:01 /usr/libexec/postfix/master
postfix 1431 0.0 0.1 81260 3484 ? S Mar30 0:00 qmgr -l -t fifo -u
postfix 10748 0.0 0.1 81092 3440 ? S 15:47 0:00 pickup -l -t fifo -u
zabbix 10521 0.0 0.0 81336 1532 ? S Apr02 0:19 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
zabbix 10519 0.0 0.0 81336 1420 ? S Apr02 0:00 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
[root@localhost ~]#
3. 如下指令也是同样效果(按照cpu,内存等)
ps auxw --sort=rss
ps auxw --sort=%cpu
ps auxw --sort=%mem
4. 几个参数的含义
-
%MEM 进程的内存占用率
-
MAJFL is the major page fault count,
-
VSZ 进程所使用的虚存的大小
-
RSS 进程使用的驻留集大小或者是实际内存的大小(RSS is the "resident 5. set size" meaning physical memory used)
-
TTY 与进程关联的终端(tty)