运维开发网

Linux下查询内存使用情况的常用命令

运维开发网 https://www.qedev.com 2020-06-13 15:10 出处:网络
1、cat /proc/meminfo $ cat /proc/meminfo MemTotal:16430636 kB MemFree:14376492 kB MemAvailable:15298732 kB

1、cat /proc/meminfo

$ cat /proc/meminfo
MemTotal:       16430636 kB
MemFree:        14376492 kB
MemAvailable:   15298732 kB
Buffers:          161976 kB
Cached:          1022440 kB
SwapCached:            0 kB
Active:          1369780 kB
Inactive:         438696 kB
Active(anon):     624376 kB
Inactive(anon):    49444 kB
Active(file):     745404 kB
Inactive(file):   389252 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Dirty:                60 kB
Writeback:             0 kB
AnonPages:        624068 kB
Mapped:            88140 kB
Shmem:             49752 kB
Slab:             108076 kB
SReclaimable:      82864 kB
SUnreclaim:        25212 kB
KernelStack:        4464 kB
PageTables:        10480 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     8215316 kB
Committed_AS:    1811204 kB
VmallocTotal:   34359738367 kB
VmallocUsed:       34780 kB
VmallocChunk:   34359695100 kB
HardwareCorrupted:     0 kB
AnonHugePages:    182272 kB
CmaTotal:              0 kB
CmaFree:               0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:      169832 kB
DirectMap2M:     8218624 kB
DirectMap1G:    10485760 kB

2、free命令

$ free -h
              total        used        free      shared  buff/cache   available
Mem:            15G        740M         13G         48M        1.2G         14G
Swap:            0B          0B          0B

3、top命令

top - 17:46:52 up 24 days,  7:55,  1 user,  load average: 0.00, 0.01, 0.05
Tasks: 150 total,   1 running, 149 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.0 us,  0.0 sy,  0.0 ni, 99.9 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem : 16430636 total, 14375400 free,   761676 used,  1293560 buff/cache
KiB Swap:        0 total,        0 free,        0 used. 15298748 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                                        
 1278 root      39  19 1009380  12864   4296 S   0.3  0.1 110:22.18 bcm-si                                                                                         
 6891 bls       20   0 2892024 159516  18192 S   0.3  1.0  55:29.09 java                                                                                           
    1 root      20   0  191392   4292   2576 S   0.0  0.0   0:41.43 systemd                                                                                        
    2 root      20   0       0      0      0 S   0.0  0.0   0:00.12 kthreadd                                                                                       
    3 root      20   0       0      0      0 S   0.0  0.0   0:01.45 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.60 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   4:42.73 rcu_sched                                                                                      
   10 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 lru-add-drain                                                                                  
   11 root      rt   0       0      0      0 S   0.0  0.0   0:11.94 watchdog/0                                                                                     
   12 root      rt   0       0      0      0 S   0.0  0.0   0:10.31 watchdog/1                                                                                     
   13 root      rt   0       0      0      0 S   0.0  0.0   0:00.27 migration/1                                                                                    
   14 root      20   0       0      0      0 S   0.0  0.0   0:03.51 ksoftirqd/1                                                                                    
   16 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/1:0H                                                                                   
   17 root      rt   0       0      0      0 S   0.0  0.0   0:08.49 watchdog/2                                                                                     
   18 root      rt   0       0      0      0 S   0.0  0.0   0:00.29 migration/2                                                                                    
   19 root      20   0       0      0      0 S   0.0  0.0   0:01.62 ksoftirqd/2                                                                                    
   21 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/2:0H                                                                                   
   22 root      rt   0       0      0      0 S   0.0  0.0   0:09.91 watchdog/3                                                                                     
   23 root      rt   0       0      0      0 S   0.0  0.0   0:00.53 migration/3                                                                                    
   24 root      20   0       0      0      0 S   0.0  0.0   0:02.67 ksoftirqd/3                                                                                    
   26 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/3:0H                                                                                   
   27 root      rt   0       0      0      0 S   0.0  0.0   0:11.63 watchdog/4                                                                                     
   28 root      rt   0       0      0      0 S   0.0  0.0   0:00.31 migration/4                                                                                    
   29 root      20   0       0      0      0 S   0.0  0.0   0:01.81 ksoftirqd/4                                                                                    
   31 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/4:0H                                                                                   
   32 root      rt   0       0      0      0 S   0.0  0.0   0:09.95 watchdog/5                                                                                     
   33 root      rt   0       0      0      0 S   0.0  0.0   0:00.51 migration/5    

 

 

4、vmstat命令

$ vmstat
procs -----------memory------------- ---swap-- -----io---- -system-- ------cpu-----
 r  b   swpd   free   buff    cache   si   so    bi    bo   in   cs us sy id wa st
 1  0      0 14376368 161976 1130836   0    0     0     3    2    2  0  0 100 0  0
$ vmstat -s
     16430636 K total memory
       762152 K used memory
      1371068 K active memory
       438692 K inactive memory
     14375160 K free memory
       161976 K buffer memory
      1131348 K swap cache
            0 K total swap
            0 K used swap
            0 K free swap
       589175 non-nice user cpu ticks
      1981533 nice user cpu ticks
       444738 system cpu ticks
   1676693728 idle cpu ticks
       147296 IO-wait cpu ticks
            0 IRQ cpu ticks
         7999 softirq cpu ticks
       330028 stolen cpu ticks
       594719 pages paged in
     42000160 pages paged out
            0 pages swapped in
            0 pages swapped out
    421548879 interrupts
    599573120 CPU context switches
   1561081893 boot time
       120054 forks

 

5、ps命令

ps aux --sort -rss

$ ps aux --sort -rss
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root      1231  0.9  2.2 1368496 375824 ?      SNl  Jun21 346:39 ./bcm-agent
bls       6891  0.1  0.9 2892024 159516 ?      Sl   Jun21  55:29 /opt/bls/lib/jre/bin/java -Duser.language=en_us -Xmx500m -XX:+UseParallelGC -XX:+UseParallelOldGC -
root       389  0.0  0.2  96376 46212 ?        Ss   Jun21   0:14 /usr/lib/systemd/systemd-journald
root      1245  0.0  0.2 1200080 40200 ?       Sl   Jun21  19:48 /opt/hosteye/bin/hosteye --is_child_mode=true --is_console_mode=false --start_mode=0
root      1199  0.0  0.1 288132 28188 ?        Ssl  Jun21   2:06 /usr/sbin/rsyslogd -n
root       898  0.0  0.1 573840 17152 ?        Ssl  Jun21   5:08 /usr/bin/python -Es /usr/sbin/tuned -l -P

待完善。。。

 

 

参考:

https://www.cnblogs.com/zhuiluoyu/p/6154898.html

https://www.cnblogs.com/xd502djj/archive/2011/03/01/1968041.html

https://www.cnblogs.com/jiffies/articles/2106456.html

0

精彩评论

暂无评论...
验证码 换一张
取 消