Linux进程管理——查看内存的工具
Linux进程管理——查看内存的工具
一查看内存的工具vmstat
vmstat命令:虚拟内存信息
vmstat [options] [delay [count]]
vmstat 2 5
- [root@centos72 ~]# 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 610224 2076 279392 0 0 32 9 316 55 8 19 73 1 0
- [root@centos72 ~]# rpm -q vmstat
- package vmstat is not installed
- [root@centos72 ~]# type vmstat
- vmstat is hashed (/usr/bin/vmstat)
- [root@centos72 ~]# free
- total used free shared buff/cache available
- Mem: 997980 106532 609936 7832 281512 705116
- Swap: 2097148 0
详细选项:
procs:
r:可运行(正运行或等待运行)进程的个数,和核心数有关
b:处于不可中断睡眠态的进程个数(被阻塞的队列的长度)
memory:
swpd: 交换内存的使用总量
free:空闲物理内存总量
buffer:用于buffer的内存总量
cache:用于cache的内存总量
注意buffer和cache的区别
swap:
si:从磁盘交换进内存的数据速率(kb/s)
so:从内存交换至磁盘的数据速率(kb/s)
查看帮助文档
- Swap
- si: Amount of memory swapped in from disk (/s).
- so: Amount of memory swapped to disk (/s).
io:
bi:从块设备读入数据到系统的速率(kb/s),也就是出磁盘进内存
bo: 保存数据至块设备的速率,也就是进磁盘出内存
- IO
- bi: Blocks received from a block device (blocks/s).
- bo: Blocks sent to a block device (blocks/s).
设置1秒执行一次
- [root@centos72 ~]# vmstat 1
- 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 758312 2076 134872 0 0 56 5 68 82 0 0 98 2 0
- 0 0 0 758288 2076 134872 0 0 0 0 55 41 0 0 100 0 0
- 0 0 0 758288 2076 134872 0 0 0 0 52 46 0 0 100 0 0
- 0 0 0 758288 2076 134872 0 0 0 0 52 45 0 0 100 0 0
- 0 0 0 758288 2076 134872 0 0 0 0 56 48 0 0 100 0 0
- 0 0 0 758288 2076 134872 0 0 0 0 45 33 0 0 100 0 0
- 0 0 0 758288 2076 134872 0 0 0 0 50 42 0 0 100 0
top命令也有一样的选项
- top - 00:50:39 up 49 min, 2 users, load average: 0.00, 0.01, 0.05
- Tasks: 104 total, 1 running, 103 sleeping, 0 stopped, 0 zombie
- %Cpu(s): 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
- KiB Mem : 997980 total, 757148 free, 103336 used, 137496 buff/cache
- KiB Swap: 2097148 total, 2097148 free, 0 used. 733212 avail Mem
- PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
- 1 root 20 0 193316 6412 4080 S 0.0 0.6 0:01.47 systemd
- 2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd
- 3 root 20 0 0 0 0 S 0.0 0.0 0:00.02 ksoftirqd/0
- 5 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:0H
- 6 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kworker/u256:0
- 7 root rt 0 0 0 0 S 0.0 0.0 0:00.04 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.33 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:00.01 watchdog/0
- 12 root rt 0 0 0 0 S 0.0 0.0 0:00.01 watchdog/1
- 13 root rt 0 0 0 0 S 0.0 0.0 0:00.00 migration/1
- 14 root 20 0 0 0 0 S 0.0 0.0 0:00.01 ksoftirqd/1
- 16 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/1:0H
- 18 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kdevtmpfs
system:
in: interrupts 中断速率,包括时钟
cs: context switch 进程切换速率,切换高不好
这和学习一样,要集中精力才会效率高
cpu:
us:Time spent running non-kernel code
sy: Time spent running kernel code
id: Time spent idle. Linux 2.5.41前,包括IO-wait time.
wa: Time spent waiting for IO. 2.5.41前,包括in idle.
st: Time stolen from a virtual machine. 2.6.11前, unknown.
开启一个进程,可以看到刚开始是出内存的多
因为内存空间满了就要里面的内容导到交换分区里面
- [root@centos72 ~]# vmstat 1
- procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
- r b swpd free buff cache si so bi bo in cs us sy id wa st
- 3 0 0 138112 2076 135496 0 0 15 1 40 38 0 0 99 0 0
- 0 7 135944 48976 0 67688 128 227088 9540 227089 5203 777 0 10 14 76 0
- 0 8 280072 48764 0 59576 224 63932 6664 63948 1314 244 0 3 0 97 0
- 0 7 317960 48800 0 63960 8 26792 256 26792 646 241 0 1 0 99 0
- 0 8 355080 64672 0 65012 276 37012 1348 37012 1428 218 0 3 7 91 0
- 0 8 402696 64132 0 65596 96 47628 260 47628 210 60 0 2 0 99 0
- 0 10 429832 49148 0 65448 120 27140 304 27140 248 101 0 1 0 99 0
- 0 10 489224 48824 0 58192 128 91312 8772 91312 2527 384 0 5 0 95 0
- 1 9 567296 72648 0 61268 96 46084 220 46084 355 164 0 1 0 99 0
- 4 9 582152 48704 0 60316 280 14696 676 14696 12712 295 0 33 0 67 0
- 4 9 590344 48880 0 61336 32 8456 1096 8456 102 50 0 9 0 91 0
- 8 9 618240 50096 0 60216 52 28704 316 28704 902 134 0 11 0 89 0
- 14 10 651520 48860 0 61432 32 32524 32 32524 1077 193 0 14 0 86 0
- 2 12 686080 48812 0 61740 32 34676 144 34676 702 140 0 9 62 29 0
- 9 8 702720 49164 0 60936 176 16480 436 16480 4339 89 0 20 0 80 0
- 10 6 747776 48884 0 61076 256 45080 592 45080 4401 104 0 62 0 38 0
- 9 7 764048 49992 0 60044 204 16836 584 16836 3782 69 0 25 0 75 0
- 12 7 838912 56412 0 61520 128 74664 296 74664 385 91 0 14 0 86 0
- 2 10 866560 52044 0 63116 288 27408 1476 27408 4312 334 0 16 0 84
让bi值变大,那么就要从磁盘读取数据,也就是出磁盘进内存
比如从第1块硬盘读数据到垃圾箱里面
- [root@centos72 ~]# df -h
- Filesystem Size Used Avail Use% Mounted on
- /dev/sda2 50G 1.3G 49G 3% /
- devtmpfs 477M 0 477M 0% /dev
- tmpfs 488M 0 488M 0% /dev/shm
- tmpfs 488M 7.6M 480M 2% /run
- tmpfs 488M 0 488M 0% /sys/fs/cgroup
- /dev/sda3 20G 33M 20G 1% /app
- /dev/sda1 1014M 124M 891M 13% /boot
- tmpfs 98M 0 98M 0% /run/user/0
- [root@centos72 ~]# dd if=/dev/sda of=/dev/null
- [root@centos72 ~]# vmstat 1
- 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 49864 815124 0 108072 0 13 3 14 25 21 0 0 100 0 0
- 0 0 49864 815124 0 108132 0 0 0 0 64 48 0 0 100 0 0
- 0 0 49864 815124 0 108132 0 0 0 0 55 43 0 0 100 0 0
- 0 0 49864 815124 0 108132 0 0 0 0 54 46 0 0 100 0 0
- 1 0 49864 770112 44880 108124 0 0 44880 0 485 178 0 10 66 24 0
- 0 1 49864 688412 126800 108104 0 0 81920 0 878 255 1 23 50 27 0
- 1 0 49864 528276 286544 108496 0 0 159744 0 1229 63 1 43 50 7 0
- 1 0 49864 376412 438096 108768 0 0 151552 0 1295 55 1 46 51 2 0
- 1 0 49864 236780 577360 109164 0 0 139264 0 1226 65 1 37 49 13 0
- 1 0 49864 72624 741200 109524 0 0 163840 0 1438 83 1 45 50 6 0
- 0 1 49864 72048 774588 76588 0 0 282640 395 1588 206 6 37 48 9 0
- 1 0 49864 62660 783960 76780 0 0 69632 0 424 129 2 7 50 41 0
- 0 1 49864 77532 768896 76824 0 0 57344 0 381 237 1 5 50 44 0
- 0 1 49864 73128 773868 76776 0 0 53248 0 362 195 2 5 50 44 0
- 0 1 49864 68116 778744 76876 0 0 53248 0 373 182 1 6 50 43 0
- 0 1 49864 81316 765416 76972 0 0 28672 0 225 128 1 3 50 47 0
- 0 1 49864 77328 770300 76932 0 0 53248 0 334 164 1 6 50 43 0
- 0 1 49864 80312 767308 77004 0 0 69632 2 549 377 2 7 51 41 0
- 0 1 49864 65336 782208 77044 0 0 32768 0 205 79 1 3 50 46 0
- procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
- r b swpd free buff cache si so bi bo in cs us sy id wa st
- 2 0 49864 61616 789040 75848 0 0 139264 0 731 144 3 14 50 34 0
- 1 0 49864 73440 778604 76144 0 0 368640 0 1803 192 9 36 48 7 0
- 1 0 49864 68620 781404 76724 0 0 355840 0 1620 127 9 33 48 9 0
- 1 0 49864 64616 787500 76324 0 0 356864 0 1643 130 9 34 48 9 0
- 1 0 49864 66344 785224 76788 0 0 282636 8 1469 110 10 35 50 5 0
- 2 0 49864 77792 773020 77444 0 0 315392 0 1497 87 10 34 49 7 0
- 1 0 49864 80512 769484 78296 0 0 311380 0 1573 133 9 37 51 3 0
- 1 0 49864 66492 780540 78940 0 0 359424 0 1628 99 10 34 48 7 0
- 1 0 49864 67068 784196 76760 0 0 353280 0 1608 126 9 34 49 9 0
- 1 0 49864 81676 768808 77612 0 0 360456 20 1633 112 9 36 48 8 0
- 0 1 49864 64044 785580 78316 0 0 344064 0 1554 112 8 33 49 10 0
- 0 1 49864 69752 779612 78728 0 0 393216 0 1885 197 10 40 48 4 0
- 1 0 49864 62060 787120 78864 0 0 397312 0 1909 212 10 37 48 5 0
- 1 0 49864 64728 784528 78816 0 0 360448 0 1837 210 9 36 48 7 0
- 1 0 49864 66900 782292 78908 0 0 372736 0 1839 215 9 37 48 7 0
- 1 0 49864 69976 779204 79032 0 0 323584 0 1541 175 8 30 49 13 0
- 1 0 49864 71012 778260 78928 0 0 376832 0 1838 239 9 36 48 7 0
- 1 0 49864 68520 780676 78680 0 0 425984 0 2076 245 10 41 48 1 0
- 1 0 49864 75060 774076 78792 0 0 331776 0 1723 225 10 34 48 9
增加bo值
- [root@centos72 ~]# dd if=/dev/sda of=/f1
- [root@centos72 ~]# vmstat 1
- 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 49864 73816 771396 83032 0 13 668 14 29 21 0 0 100 0 0
- 0 0 49864 73692 771396 83008 0 0 0 0 65 51 0 0 100 0 0
- 1 0 49864 80052 745316 102564 0 0 24436 0 311 134 0 7 80 13 0
- 2 1 49864 74568 690624 162564 0 0 65536 76112 674 298 2 18 46 35 0
- 7 1 49864 71944 680280 175740 0 0 8192 0 284 49 3 18 59 21 0
- 8 0 49864 76776 611136 238508 0 0 59904 2048 706 143 2 24 52 21 0
- 4 0 49864 64664 594468 267612 0 0 28672 30723 367 95 6 70 24 0 0
- 3 1 49864 74676 576804 276384 0 0 9728 72016 168 44 0 9 63 28 0
- 3 1 49864 76316 566944 284776 0 0 8192 0 136 37 3 18 26 54 0
- 11 1 49864 76316 566944 284776 0 0 0 0 90 13 0 100 0 0 0
- 5 0 49864 75400 497952 354624 0 0 65536 10752 908 197 3 29 45 23 0
- 7 1 49864 64288 487396 376180 0 0 32768 98996 269 119 5 75 20 0 0
- 5 1 49864 77980 452188 398160 0 0 12288 0 443 65 2 16 60 23 0
- 1 0 49864 62728 388992 476024 0 0 77824 28672 1011 159 4 52 39 4 0
- 3 1 49864 72916 372744 482036 0 0 8192 0 78 34 6 19 56 19 0
- 5 0 49864 64288 362128 498940 0 0 13824 16896 251 59 5 59 18 18 0
- 6 0 49864 78640 332404 516352 0 0 18944 74536 221 49 2 21 42 35 0
-s: 显示内存的统计数据
- [root@centos72 ~]# vmstat -s
- 997980 K total memory
- 69504 K used memory
- 387508 K active memory
- 403720 K inactive memory
- 81120 K free memory
- 180292 K buffer memory
- 667064 K swap cache
- 2097148 K total swap
- 49864 K used swap
- 2047284 K free swap
- 3626 non-nice user cpu ticks
- 2 nice user cpu ticks
- 15279 system cpu ticks
- 7273227 idle cpu ticks
- 17014 IO-wait cpu ticks
- 0 IRQ cpu ticks
- 496 softirq cpu ticks
- 0 stolen cpu ticks
- 50988602 pages paged in
- 3212894 pages paged out
- 5460 pages swapped in
- 243937 pages swapped out
- 2116104 interrupts
- 1576029 CPU context switches
- 1558281696 boot time
- 1757 forks
定义显示次数
- [root@centos72 ~]# vmstat 1 3
- procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
- r b swpd free buff cache si so bi bo in cs us sy id wa st
- 2 0 48584 64156 403812 459696 0 13 1653 59 35 23 0 0 99 0 0
- 2 0 48584 64308 404496 458928 0 0 376832 0 2437 243 10 37 48 6 0
- 0 1 48584 63416 406468 457848 0 0 401408 0 2549 260 8 41 47 4 0
- [root@centos72 ~]# vmstat 1 6
- procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
- r b swpd free buff cache si so bi bo in cs us sy id wa st
- 1 1 48584 69340 398596 459876 0 13 1682 59 35 23 0 0 99 0 0
- 0 1 48584 69576 398320 459772 0 0 61440 0 579 257 2 6 50 42 0
- 1 0 48584 64820 403060 459828 0 0 45056 0 427 166 1 5 50 45 0
- 0 1 48584 61972 406012 459792 0 0 77824 0 649 244 2 8 50 40 0
- 0 1 48584 63092 404844 459748 0 0 73728 0 618 278 2 7 50 41 0
- 0 1 48584 73948 394792 458848 0 0 69632 0 588 236 1 7 50 42
二iostat:统计CPU和设备IO信息
- [root@centos72 ~]# yum repolist
- Loaded plugins: fastestmirror
- Loading mirror speeds from cached hostfile
- base | 3.6 kB 00:00:00
- repo id repo name status
- base base 3,971
- repolist: 3,971
- [root@centos72 ~]# yum whatprovides iostat
- Loaded plugins: fastestmirror
- Loading mirror speeds from cached hostfile
- sysstat-10.1.5-13.el7.x86_64 : Collection of performance monitoring tools for Linux
- Repo : base
- Matched from:
- Filename : /usr/bin/iostat
- [root@centos72 ~]# yum install sysstat -y
- Loaded plugins: fastestmirror
- Loading mirror speeds from cached hostfile
- Resolving Dependencies
- --> Running transaction check
- ---> Package sysstat.x86_64 0:10.1.5-13.el7 will be installed
- --> Processing Dependency: libsensors.so.4()(64bit) for package: sysstat-10.1.5-13.el7.x86_64
- --> Running transaction check
- ---> Package lm_sensors-libs.x86_64 0:3.4.0-4.20160601gitf9185e5.el7 will be installed
- --> Finished Dependency Resolution
- Dependencies Resolved
- ========================================================================================================
- Package Arch Version Repository Size
- ========================================================================================================
- Installing:
- sysstat x86_64 10.1.5-13.el7 base 310 k
- Installing for dependencies:
- lm_sensors-libs x86_64 3.4.0-4.20160601gitf9185e5.el7 base 41 k
- Transaction Summary
- ========================================================================================================
- Install 1 Package (+1 Dependent package)
- Total download size: 352 k
- Installed size: 1.2 M
- Downloading packages:
- --------------------------------------------------------------------------------------------------------
- Total 705 kB/s | 352 kB 00:00:00
- Running transaction check
- Running transaction test
- Transaction test succeeded
- Running transaction
- Installing : lm_sensors-libs-3.4.0-4.20160601gitf9185e5.el7.x86_64 1/2
- Installing : sysstat-10.1.5-13.el7.x86_64 2/2
- Verifying : sysstat-10.1.5-13.el7.x86_64 1/2
- Verifying : lm_sensors-libs-3.4.0-4.20160601gitf9185e5.el7.x86_64 2/2
- Installed:
- sysstat.x86_64 0:10.1.5-13.el7
- Dependency Installed:
- lm_sensors-libs.x86_64 0:3.4.0-4.20160601gitf9185e5.el7
- Complete!
下面都是完整的单词,之前是简写
avg-cpu: %user %nice %system %iowait %steal %idle
tps 每秒钟处理的事务
kB_read/s 每秒钟从磁盘读取的字节数?
kB_wrtn/s 每秒钟从磁盘写入的字节数?
kB_read
kB_wrtn
- [root@centos72 ~]# iostat
- Linux 3.10.0-862.el7.x86_64 (centos72.huawei.com) 05/20/2019 _x86_64_ (2 CPU)
- avg-cpu: %user %nice %system %iowait %steal %idle
- 0.05 0.00 0.22 0.25 0.00 99.49
- Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
- scd0 0.01 0.08 0.00 2978 0
- sda 3.11 1378.58 86.82 51100818
- [root@centos65 ~]# iostat
- Linux 2.6.32-642.el6.x86_64 (centos65.jd.com) 05/20/2019 _x86_64_ (2 CPU)
- avg-cpu: %user %nice %system %iowait %steal %idle
- 0.00 0.00 0.04 0.08 0.00 99.87
- Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn
- sda 0.29 6.47 1.34 238874 49352
- scd0 0.00 0.01 0.00 528
从磁盘里读数据,并且设置时间间隔显示一次
- [root@centos72 ~]# dd if=/dev/sda of=/dev/null
- [root@centos72 ~]# iostat 1
- Linux 3.10.0-862.el7.x86_64 (centos72.huawei.com) 05/20/2019 _x86_64_ (2 CPU)
- avg-cpu: %user %nice %system %iowait %steal %idle
- 0.05 0.00 0.23 0.26 0.00 99.46
- Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
- scd0 0.01 0.08 0.00 2978 0
- sda 3.25 1412.10 117.79 53159598 4434194
- avg-cpu: %user %nice %system %iowait %steal %idle
- 5.56 0.00 22.22 24.24 0.00 47.98
- Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
- scd0 0.00 0.00 0.00 0 0
- sda 470.00 240136.00 0.00 240136 0
- avg-cpu: %user %nice %system %iowait %steal %idle
- 1.01 0.00 4.55 44.44 0.00 50.00
- Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
- scd0 0.00 0.00 0.00 0 0
- sda 93.00 47616.00 0.00 47616 0
- avg-cpu: %user %nice %system %iowait %steal %idle
- 1.03 0.00 4.62 43.59 0.00 50.77
- Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
- scd0 0.00 0.00 0.00 0 0
- sda 128.00 65536.00 0.00 65536 0
- avg-cpu: %user %nice %system %iowait %steal %idle
- 1.53 0.00 5.10 43.37 0.00 50.00
- Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
- scd0 0.00 0.00 0.00 0 0
- sda 124.00 63488.00 0.00 63488 0
- avg-cpu: %user %nice %system %iowait %steal %idle
- 1.00 0.00 4.00 45.00 0.00 50.00
- Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
- scd0 0.00 0.00 0.00 0 0
- sda 87.00 44544.00 0.00 44544 0
- avg-cpu: %user %nice %system %iowait %steal %idle
- 1.02 0.00 4.57 44.16 0.00 50.25
- Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
- scd0 0.00 0.00 0.00 0 0
- sda 98.00 50176.00 0.00 50176 0
- avg-cpu: %user %nice %system %iowait %steal %idle
- 1.03 0.00 6.15 42.56 0.00 50.26
- Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
- scd0 0.00 0.00 0.00 0 0
- sda 132.00 67584.00 0.00 67584
此命令的作用就是可以查看磁盘访问的压力大小
定义显示次数
- [root@centos72 ~]# iostat 1 4
- Linux 3.10.0-862.el7.x86_64 (centos72.huawei.com) 05/20/2019 _x86_64_ (2 CPU)
- avg-cpu: %user %nice %system %iowait %steal %idle
- 0.08 0.00 0.35 0.38 0.00 99.19
- Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
- scd0 0.01 0.08 0.00 2978 0
- sda 5.76 2694.01 117.16 101963082 4434320
- avg-cpu: %user %nice %system %iowait %steal %idle
- 10.05 0.00 40.70 3.52 0.00 45.73
- Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
- scd0 0.00 0.00 0.00 0 0
- sda 835.00 426092.00 0.00 426092 0
- avg-cpu: %user %nice %system %iowait %steal %idle
- 8.50 0.00 35.00 8.50 0.00 48.00
- Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
- scd0 0.00 0.00 0.00 0 0
- sda 697.03 356879.21 0.00 360448 0
- avg-cpu: %user %nice %system %iowait %steal %idle
- 9.60 0.00 35.86 7.07 0.00 47.47
- Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
- scd0 0.00 0.00 0.00 0 0
- sda 736.00 376832.00 0.00 376832
三pmap命令
pmap命令:进程对应的内存映射,也就是进程使用的内存空间
pmap [options] pid [...]
-x: 显示详细格式的信息
- [root@centos72 ~]# dd if=/dev/sda of=/dev/null
调用了很多库,也是要占空间的
很多模块都可能使用到相同的库,相当于公共设施
- [root@centos72 ~]# pstree -p
- systemd(1)─┬─NetworkManager(557)─┬─{NetworkManager}(594)
- │ └─{NetworkManager}(596)
- ├─VGAuthService(546)
- ├─agetty(573)
- ├─auditd(517)───{auditd}(518)
- ├─crond(567)
- ├─dbus-daemon(550)───{dbus-daemon}(556)
- ├─irqbalance(549)
- ├─master(873)─┬─pickup(1594)
- │ └─qmgr(875)
- ├─polkitd(540)─┬─{polkitd}(576)
- │ ├─{polkitd}(577)
- │ ├─{polkitd}(582)
- │ ├─{polkitd}(586)
- │ └─{polkitd}(587)
- ├─rsyslogd(791)─┬─{rsyslogd}(793)
- │ └─{rsyslogd}(794)
- ├─sshd(788)─┬─sshd(1076)───bash(1081)───dd(1729)
- │ └─sshd(1599)───bash(1603)───pstree(1743)
- ├─systemd-journal(356)
- ├─systemd-logind(543)
- ├─systemd-udevd(390)
- ├─tuned(789)─┬─{tuned}(1030)
- │ ├─{tuned}(1031)
- │ ├─{tuned}(1032)
- │ └─{tuned}(1046)
- └─vmtoolsd(547)───{vmtoolsd}(579)
- [root@centos72 ~]# pmap 1729
- 1729: dd if=/dev/sda of=/dev/null
- 0000000000400000 68K r-x-- dd
- 0000000000610000 4K r---- dd
- 0000000000611000 4K rw--- dd
- 0000000000de9000 132K rw--- [ anon ]
- 00007fd21a123000 103588K r---- locale-archive
- 00007fd22064c000 1804K r-x-- libc-2.17.so
- 00007fd22080f000 2044K ----- libc-2.17.so
- 00007fd220a0e000 16K r---- libc-2.17.so
- 00007fd220a12000 8K rw--- libc-2.17.so
- 00007fd220a14000 20K rw--- [ anon ]
- 00007fd220a19000 136K r-x-- ld-2.17.so
- 00007fd220c31000 12K rw--- [ anon ]
- 00007fd220c39000 4K rw--- [ anon ]
- 00007fd220c3a000 4K r---- ld-2.17.so
- 00007fd220c3b000 4K rw--- ld-2.17.so
- 00007fd220c3c000 4K rw--- [ anon ]
- 00007ffeeedc9000 132K rw--- [ stack ]
- 00007ffeeedf7000 8K r-x-- [ anon ]
- ffffffffff600000 4K r-x-- [ anon ]
- total 107996K
另外一种实现:
cat /proc/PID/maps
实际上是看此文件的内容,但是这样看易读性差
做开发可能会涉及到内存泄漏问题
内存泄漏就是进程占用了内存之后一直不释放内存,占满了还会继续占用,直到所有的内存占满导致系统奔溃
所以运维和开发不分家,平时遇到了什么问题要和开发沟通
- [root@centos72 ~]# ls /proc/1729/maps -l
- -r--r--r--. 1 root root 0 May 20 10:35 /proc/1729/maps
- [root@centos72 ~]# cat /proc/1729/maps
- 00400000-00411000 r-xp 00000000 08:02 21443 /usr/bin/dd
- 00610000-00611000 r--p 00010000 08:02 21443 /usr/bin/dd
- 00611000-00612000 rw-p 00011000 08:02 21443 /usr/bin/dd
- 00de9000-00e0a000 rw-p 00000000 00:00 0 [heap]
- 7fd21a123000-7fd22064c000 r--p 00000000 08:02 228723 /usr/lib/locale/locale-archive
- 7fd22064c000-7fd22080f000 r-xp 00000000 08:02 33600202 /usr/lib64/libc-2.17.so
- 7fd22080f000-7fd220a0e000 ---p 001c3000 08:02 33600202 /usr/lib64/libc-2.17.so
- 7fd220a0e000-7fd220a12000 r--p 001c2000 08:02 33600202 /usr/lib64/libc-2.17.so
- 7fd220a12000-7fd220a14000 rw-p 001c6000 08:02 33600202 /usr/lib64/libc-2.17.so
- 7fd220a14000-7fd220a19000 rw-p 00000000 00:00 0
- 7fd220a19000-7fd220a3b000 r-xp 00000000 08:02 33600195 /usr/lib64/ld-2.17.so
- 7fd220c31000-7fd220c34000 rw-p 00000000 00:00 0
- 7fd220c39000-7fd220c3a000 rw-p 00000000 00:00 0
- 7fd220c3a000-7fd220c3b000 r--p 00021000 08:02 33600195 /usr/lib64/ld-2.17.so
- 7fd220c3b000-7fd220c3c000 rw-p 00022000 08:02 33600195 /usr/lib64/ld-2.17.so
- 7fd220c3c000-7fd220c3d000 rw-p 00000000 00:00 0
- 7ffeeedc9000-7ffeeedea000 rw-p 00000000 00:00 0 [stack]
- 7ffeeedf7000-7ffeeedf9000 r-xp 00000000 00:00 0 [vdso]
- ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
文件描述符表示进程打开了文件数量
如果数量不断增加说明有问题,因为内存空间是有限的,进程占用的资源是有限的
如果出现此问题那么就要找开发
- [root@centos72 ~]# ls /proc/1800/fd
- 0 1 2
- [root@centos72 ~]#
- [root@centos72 ~]# ls /proc/1800/fd
- 0 1 2
- [root@centos72 ~]# ls /proc/1800/fd
- 0 1 2
- [root@centos72 ~]# ls /proc/1800/fd
- 0 1 2
- [root@centos72 ~]# ls /proc/1800/fd
- 0 1 2
- [root@centos72 ~]# ls /proc/1800/fd
- 0 1 2
- [root@centos72 ~]# ls /proc/1800/fd -al
- total 0
- dr-x------. 2 root root 0 May 20 10:46 .
- dr-xr-xr-x. 9 root root 0 May 20 10:45 ..
- lr-x------. 1 root root 64 May 20 10:46 0 -> /dev/sda
- l-wx------. 1 root root 64 May 20 10:46 1 -> /dev/null
- lrwx------. 1 root root 64 May 20 10:46 2 -> /dev/pts/
在另外一个终端打开vim进程
- [root@centos72 ~]# vim f1
如果是vim进程就会打开交换文件
如果正常退出此文件就没有了,异常退出就会有此文件要手动删除
- [root@centos72 ~]# pstree -p
- systemd(1)─┬─NetworkManager(557)─┬─{NetworkManager}(594)
- │ └─{NetworkManager}(596)
- ├─VGAuthService(546)
- ├─agetty(573)
- ├─auditd(517)───{auditd}(518)
- ├─crond(567)
- ├─dbus-daemon(550)───{dbus-daemon}(556)
- ├─irqbalance(549)
- ├─master(873)─┬─pickup(1594)
- │ └─qmgr(875)
- ├─polkitd(540)─┬─{polkitd}(576)
- │ ├─{polkitd}(577)
- │ ├─{polkitd}(582)
- │ ├─{polkitd}(586)
- │ └─{polkitd}(587)
- ├─rsyslogd(791)─┬─{rsyslogd}(793)
- │ └─{rsyslogd}(794)
- ├─sshd(788)─┬─sshd(1076)───bash(1081)───vim(1840)
- │ └─sshd(1599)───bash(1603)───pstree(1841)
- ├─systemd-journal(356)
- ├─systemd-logind(543)
- ├─systemd-udevd(390)
- ├─tuned(789)─┬─{tuned}(1030)
- │ ├─{tuned}(1031)
- │ ├─{tuned}(1032)
- │ └─{tuned}(1046)
- └─vmtoolsd(547)───{vmtoolsd}(579)
- [root@centos72 ~]# ls /proc/1840/fd
- 0 1 2 4
- [root@centos72 ~]# ls /proc/1840/fd -al
- total 0
- dr-x------. 2 root root 0 May 20 10:53 .
- dr-xr-xr-x. 9 root root 0 May 20 10:53 ..
- lrwx------. 1 root root 64 May 20 10:53 0 -> /dev/pts/1
- lrwx------. 1 root root 64 May 20 10:53 1 -> /dev/pts/1
- lrwx------. 1 root root 64 May 20 10:53 2 -> /dev/pts/1
- lrwx------. 1 root root 64 May 20 10:53 4 -> /root/.f1.swp
Linux进程管理——查看内存的工具的更多相关文章
- linux 进程管理和内存分配
1.进程相关概念 进程:正在运行中的程序 内核功用:进程管理.文件系统.网络功能.内存管理.驱动程序.安全功能等 Process:运行中的程序的一个副本,是被载入内存的一个指令集合 进程 ID(Pro ...
- Linux进程管理四大工具ps \dstat\ top\ htop
Linux进程管理之“四大名捕” 一.四大名捕 四大名捕,最初出现于温瑞安创作的武侠小说,是朝廷中正义力量诸葛小花的四大徒弟,四人各怀绝技,分别是轻功暗器高手“无情”.内功卓越的高手“铁手”.腿功惊人 ...
- Linux进程管理工具vmstat,iostat,pmap
一查看内存的工具——vmstat (一)vmstat的介绍 vmstat vmstat是Virtual Memory Statistics(虚拟内存统计)的缩写 利用vmstat命令可以对操作系统的报 ...
- Linux进程管理工具Supervisor的安装配置
目录 Linux进程管理工具Supervisor的安装配置 简介 安装Python包管理工具 安装Supervisor 配置 配置文件参数说明 配置进程管理 启动supervisor 控制进程 交互终 ...
- Linux进程管理工具
Linux进程管理工具 Htop yum install htop 参考帮助: http://blog.csdn.net/skh2015java/article/details/53173896 Li ...
- Linux 进程管理 笔记
https://www.ibm.com/developerworks/cn/linux/l-linux-process-management/index.htmlLinux 进程管理剖析 进程可以是短 ...
- linux进程管理(二)
接上[linux进程管理(一)] 终止进程的工具 kill .killall.pkill 终止一个进程或终止一个正在运行的程序,一般是通过 kill .killall.pkill.xkill 等进行. ...
- Linux进程管理之ps的使用
主题Linux进程管理之ps工具的使用 一ps工具的介绍 ps: process state 进程状态ps - report a snapshot of the current processesL ...
- 12个Linux进程管理命令介绍(转)
12个Linux进程管理命令介绍 [日期:2015-06-02] 来源:Linux中国 作者:Linux [字体:大 中 小] 执行中的程序在称作进程.当程序以可执行文件存放在存储中,并且运行的 ...
随机推荐
- 音悦台 api分析
用户订阅MV更新 http://uapi.yinyuetai.com/i/flw/subscribe-video-list?page=1&pageSize=200&uid=XXXXXX ...
- java 将MySql数据库中的数据(某一列)取出放入数组中 转
转:http://blog.csdn.net/ewili/article/details/8605638 假设mysql中test数据库中有个表式score,有数据,我只取第一列的数据出来: publ ...
- 牛客网暑期ACM多校训练营(第五场) F - take —— 期望+树状数组+逆元
看到一篇好的博客特意转出来观摩大佬:转:https://blog.csdn.net/greybtfly/article/details/81413526 题目大意:给n个箱子排成一排,从头到尾按顺序依 ...
- PHP常用工具函数之手机号相关
1.手机号正确与否判定 //测试手机号 $phone = '17777777777'; $pattern = '/^1[356789]\d{9}$/'; $is = preg_match($patte ...
- day32—CSS多列布局学习
转行学开发,代码100天——2018-04-17 关于多列布局,前期已经梳理过,今天的培训课程学习中再次提及,趁此也做个总结和检验. 多列布局的介绍参考: day08—css布局解决方案之多列布局 ...
- day11—前端学习之我不想看书
转行学开发,代码100天——2018-03-27 今天是前端学习,博客记录见证的第11天,按理说还要继续写一写代码相关的内容. 但由于今天的代码实践都是一些基础知识,还是想谈一谈关于编程方面看书的事情 ...
- python实现堆栈与队列的方法
python实现堆栈与队列的方法 本文实例讲述了python实现堆栈与队列的方法.分享给大家供大家参考.具体分析如下: 1.python实现堆栈,可先将Stack类写入文件stack.py,在其它程序 ...
- error LNK2019: unresolved external symbol __vsnwprintf
老DX SDK,新VS2019问题,编译老项目GG,依赖库加入 legacy_stdio_definitions.lib 解决
- linux下shell显示git当前分支
function git-branch-name { git symbolic-ref HEAD 2>/dev/null | cut -d"/" -f 3 } functio ...
- Pandas案例--人口密度分析
需求: 导入文件,查看原始数据 将人口数据和各州简称数据进行合并 将合并的数据中重复的abbreviation列进行删除 查看存在缺失数据的列 找到有哪些state/region使得state的值为N ...