1.查看详细的内存占比
cat /proc/PID/status
eg:寻找hostapd的进程的pid,对当前的pid的进程所占用的内存进行详细查看。
root@ROUTER:~# ps | grep hostapd 6715 root 1740 S hostapd -B /etc/hostapd.conf.wlan0 29684 root 1328 S grep hostapd root@ROUTER:~# cat /proc/6715/status Name: hostapd State: S (sleeping) Tgid: 6715 Ngid: 0 Pid: 6715 PPid: 1 TracerPid: 0 Uid: 0 0 0 0 Gid: 0 0 0 0 FDSize: 32 Groups: 0 VmPeak: 1740 kB VmSize: 1740 kB VmLck: 0 kB VmPin: 0 kB VmHWM: 120 kB VmRSS: 120 kB VmData: 80 kB VmStk: 136 kB VmExe: 720 kB VmLib: 672 kB VmPTE: 8 kB VmPMD: 0 kB VmSwap: 0 kB Threads: 1 SigQ: 0/949 SigPnd: 0000000000000000 ShdPnd: 0000000000000000 SigBlk: 0000000000000000 SigIgn: 0000000200001004 SigCgt: 0000000000004203 CapInh: 0000000000000000 CapPrm: 0000003fffffffff CapEff: 0000003fffffffff CapBnd: 0000003fffffffff CapAmb: 0000000000000000 Cpus_allowed: 1 Cpus_allowed_list: 0 voluntary_ctxt_switches: 2598 nonvoluntary_ctxt_switches: 2634
2.
ps -aux命令可以直接查询出 内存比 和 CPU占比,为了验证这个命令查询出来的内存占比和CPU占比是不是准确,我们先从Ubuntu系统上验证一下当前占比是不是准确
ps -aux | grep zookeeper
ps -aux | grep 2181