├── images ├── homescreen.jpg ├── file_systems.jpg ├── top_processes.jpg ├── cpu_utilization.jpg ├── mem_utilization.jpg ├── nfs_statistics.jpg ├── virtual_memory.jpg ├── disk_utilization.jpg ├── kernel-statistics.jpg ├── nvidia_gpu_status.jpg ├── top_processes_base.jpg ├── network_utilization.jpg └── cpu_utilization_long_term.jpg ├── README.md ├── posts ├── nfs-statistics.md ├── top-processes.md ├── the-end.md ├── network-utilization.md ├── nvidia-gpu-status.md ├── cpu-information.md ├── file-systems.md ├── kernel-statistics.md ├── disk-utilization.md ├── cpu-utilization.md └── memory-utilization.md ├── SUMMARY.md └── LICENSE /images/homescreen.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanXiao/read-nmon-code-to-learn-analyzing-linux-performance/HEAD/images/homescreen.jpg -------------------------------------------------------------------------------- /images/file_systems.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanXiao/read-nmon-code-to-learn-analyzing-linux-performance/HEAD/images/file_systems.jpg -------------------------------------------------------------------------------- /images/top_processes.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanXiao/read-nmon-code-to-learn-analyzing-linux-performance/HEAD/images/top_processes.jpg -------------------------------------------------------------------------------- /images/cpu_utilization.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanXiao/read-nmon-code-to-learn-analyzing-linux-performance/HEAD/images/cpu_utilization.jpg -------------------------------------------------------------------------------- /images/mem_utilization.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanXiao/read-nmon-code-to-learn-analyzing-linux-performance/HEAD/images/mem_utilization.jpg -------------------------------------------------------------------------------- /images/nfs_statistics.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanXiao/read-nmon-code-to-learn-analyzing-linux-performance/HEAD/images/nfs_statistics.jpg -------------------------------------------------------------------------------- /images/virtual_memory.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanXiao/read-nmon-code-to-learn-analyzing-linux-performance/HEAD/images/virtual_memory.jpg -------------------------------------------------------------------------------- /images/disk_utilization.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanXiao/read-nmon-code-to-learn-analyzing-linux-performance/HEAD/images/disk_utilization.jpg -------------------------------------------------------------------------------- /images/kernel-statistics.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanXiao/read-nmon-code-to-learn-analyzing-linux-performance/HEAD/images/kernel-statistics.jpg -------------------------------------------------------------------------------- /images/nvidia_gpu_status.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanXiao/read-nmon-code-to-learn-analyzing-linux-performance/HEAD/images/nvidia_gpu_status.jpg -------------------------------------------------------------------------------- /images/top_processes_base.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanXiao/read-nmon-code-to-learn-analyzing-linux-performance/HEAD/images/top_processes_base.jpg -------------------------------------------------------------------------------- /images/network_utilization.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanXiao/read-nmon-code-to-learn-analyzing-linux-performance/HEAD/images/network_utilization.jpg -------------------------------------------------------------------------------- /images/cpu_utilization_long_term.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NanXiao/read-nmon-code-to-learn-analyzing-linux-performance/HEAD/images/cpu_utilization_long_term.jpg -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Read Nmon Code To Learn Analyzing Linux Performance 2 | [Nmon](http://nmon.sourceforge.net/pmwiki.php) is a poweful but simple tool (just one single source file with about ~`9000` lines of code) to monitor `Linux` performance, so it is a good tutorial to learn how to analyze `Linux` performance. 3 | -------------------------------------------------------------------------------- /posts/nfs-statistics.md: -------------------------------------------------------------------------------- 1 | # NFS statistics 2 | 3 | `nmon` can also be used to monitor `NFS` statistics: read `/proc/net/rpc/nfsd` to get server related statistics while `/proc/net/rpc/nfs` for client (press '`N`'): 4 | 5 | ![image](https://raw.githubusercontent.com/NanXiao/read-nmon-code-to-learn-analyzing-linux-performance/master/images/nfs_statistics.jpg) 6 | 7 | BTW, since my server doesn't enable `NFS` feature, you can't see any valuable content from the picture. 8 | -------------------------------------------------------------------------------- /SUMMARY.md: -------------------------------------------------------------------------------- 1 | * [CPU information](posts/cpu-information.md) 2 | * [CPU utilization](posts/cpu-utilization.md) 3 | * [Memory utilization](posts/memory-utilization.md) 4 | * [Disk utilization](posts/disk-utilization.md) 5 | * [Network utilization](posts/network-utilization.md) 6 | * [Kernel statistics](posts/kernel-statistics.md) 7 | * [Top processes](posts/top-processes.md) 8 | * [File systems](posts/file-systems.md) 9 | * [NFS statistics](posts/nfs-statistics.md) 10 | * [NVIDIA GPU status](posts/nvidia-gpu-status.md) 11 | * [The end](posts/the-end.md) -------------------------------------------------------------------------------- /posts/top-processes.md: -------------------------------------------------------------------------------- 1 | # Top processes 2 | 3 | Inputting '`t`' can get top processes information: 4 | 5 | ![image](https://raw.githubusercontent.com/NanXiao/read-nmon-code-to-learn-analyzing-linux-performance/master/images/top_processes.jpg) 6 | 7 | By default, the processes are sorted and displayed in CPU utilization. The `%CPU` and `min/max Faults` fields are read and calculated from `/proc/[pid]/stat`, and `Size`, `Res` ... are got `/proc/[pid]/statm`. 8 | 9 | There are other modes for top processes. E.g., pressing `1` can switch to "`Base`" mode: 10 | 11 | ![image](https://raw.githubusercontent.com/NanXiao/read-nmon-code-to-learn-analyzing-linux-performance/master/images/top_processes_base.jpg) 12 | 13 | For detailed information of every process, please refer [/proc/[pid]/stat](http://man7.org/linux/man-pages/man5/proc.5.html). -------------------------------------------------------------------------------- /posts/the-end.md: -------------------------------------------------------------------------------- 1 | # The end 2 | 3 | It is time to wrap up this journey now. After going through the code, I summarize the steps of implementing a home-brew performance monitor tool: 4 | 5 | a) Get the performance raw data: `/proc` is a treasure for the whole system while `/proc/[pid]` for a specified process. If you want to observer proprietary devices (e.g., `NVIDIA` GPU), please refer vendor APIs; 6 | 7 | b) Understand and parse data; 8 | 9 | c) Display them. You can choose primitive `ncurses` or more fancy modern `GUI` libraries. 10 | 11 | If you are learning a new programming language, reinventing a monitor wheel may be a good exercise, isn't it? 12 | 13 | P.S., if this small project gives you little help, please consider give it a star in [github](https://github.com/NanXiao/read-nmon-code-to-learn-analyzing-linux-performance). :-) -------------------------------------------------------------------------------- /posts/network-utilization.md: -------------------------------------------------------------------------------- 1 | # Network utilization 2 | 3 | Inputting '`n`' can get network utilization: 4 | 5 | ![image](https://raw.githubusercontent.com/NanXiao/read-nmon-code-to-learn-analyzing-linux-performance/master/images/network_utilization.jpg) 6 | 7 | The statistics are read from `/proc/net/dev` file (processed by `proc_net` function): 8 | 9 | $ cat /proc/net/dev 10 | Inter-| Receive | Transmit 11 | face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed 12 | eno2: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 13 | lo: 61231535 54975 0 0 0 0 0 0 61231535 54975 0 0 0 0 0 0 14 | eno1: 6123992486 37999646 0 92998 0 0 0 769601 54887394843 48055902 0 0 0 0 0 0 15 | 16 | It is not difficult to comprehend meanings of every field (You can refer this [discussion](https://stackoverflow.com/questions/3521678/what-are-meanings-of-fields-in-proc-net-dev)). -------------------------------------------------------------------------------- /posts/nvidia-gpu-status.md: -------------------------------------------------------------------------------- 1 | # NVIDIA GPU status 2 | 3 | `nmon` can also be used to monitor `NVIDIA` GPU status. You need to compile code with `NVIDIA_GPU` macro enabled and linked with `nvidia-ml` library. E.g.: 4 | 5 | $ cc -o nmon_x86_debian3 lmon.c -g -Wall -D JFS -D GETUSER -D LARGEMEM -D NVIDIA_GPU -lncurses -lm -g -D X86 -lnvidia-ml 6 | 7 | Press '`a`' or '`E`' can show GPU status screen: 8 | 9 | ![image](https://raw.githubusercontent.com/NanXiao/read-nmon-code-to-learn-analyzing-linux-performance/master/images/nvidia_gpu_status.jpg) 10 | 11 | `gpu_init()` function is used to get GPU information: 12 | 13 | void gpu_init() 14 | { 15 | int i; 16 | nvmlReturn_t nvres; 17 | if ((nvres = nvmlInit()) != NVML_SUCCESS) { 18 | printf("nvmlInit failed %d\n", nvres); 19 | return; 20 | } 21 | ...... 22 | if ((nvres = nvmlDeviceGetCount(&gpu_devices)) != NVML_SUCCESS) { 23 | printf("nvmlDeviceGetCount failed %d\n", nvres); 24 | return; 25 | } 26 | if (gpu_devices > 4) 27 | gpu_devices = 4; 28 | ...... 29 | } 30 | You can see `gpu_init()` just utilizes [NVML](https://developer.nvidia.com/nvidia-management-library-nvml) APIs to get GPU's knowledge. But there are also limitations: such as `nmon` can only support `4` GPUs, the metrics are not abundant, etc. Since source code is here, you can customize it if you want. 31 | 32 | 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2018, Nan Xiao 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | * Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /posts/cpu-information.md: -------------------------------------------------------------------------------- 1 | # CPU information 2 | 3 | When you launch `nmon` in the terminal, it will display following home screen: 4 | 5 | ![image](https://raw.githubusercontent.com/NanXiao/read-nmon-code-to-learn-analyzing-linux-performance/master/images/homescreen.jpg) 6 | 7 | Besides usage tip, the screen mainly show the CPU information of current system. The CPU information is obtained from `/proc/cpuinfo` file: 8 | 9 | # cat /proc/cpuinfo 10 | processor : 0 11 | vendor_id : GenuineIntel 12 | cpu family : 6 13 | model : 23 14 | model name : Intel(R) Core(TM)2 Duo CPU P8700 @ 2.53GHz 15 | stepping : 10 16 | microcode : 0xa07 17 | cpu MHz : 1596.311 18 | cache size : 3072 KB 19 | physical id : 0 20 | ...... 21 | 22 | and `lscpu` command output: 23 | 24 | void lscpu_init() 25 | { 26 | ...... 27 | 28 | if (lscpu_available == 1) 29 | return; 30 | pop = popen("/usr/bin/lscpu 2>/dev/null", "r"); 31 | if (pop != NULL) { 32 | ...... 33 | } 34 | } 35 | 36 | But in fact, `lscpu` command also gets value from `/proc/cpuinfo` (please refer [code](https://github.com/karelzak/util-linux/blob/200769b6c0dff6863089ea2a9ff4ea9ccbd15d0f/sys-utils/lscpu.c#L405)). 37 | 38 | The `ProcessorChips` is equivalent to `lscpu` output's `Sockets`, which identifies the number of "physical CPUs"; `PhyscalCores` is equivalent to `lscpu` output's `Cores`; `Hyperthreads` to `Thrds` and `VirtualCPUs` to `CPU`.`VirtualCPUs` is also named as "logical CPUs", which is equal to "`Sockets` * `Cores` * `Thrds`" (`2` * `26` * `2` = `104`). 39 | 40 | -------------------------------------------------------------------------------- /posts/file-systems.md: -------------------------------------------------------------------------------- 1 | # File systems 2 | 3 | Inputting '`j`' can get file systems information: 4 | 5 | ![image](https://raw.githubusercontent.com/NanXiao/read-nmon-code-to-learn-analyzing-linux-performance/master/images/file_systems.jpg) 6 | 7 | File systems information is stored in `/etc/mtab` file (Please refer [Wikipedia](https://en.wikipedia.org/wiki/Mtab)): 8 | 9 | # cat /etc/mtab 10 | proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0 11 | sys /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0 12 | dev /dev devtmpfs rw,nosuid,relatime,size=1989392k,nr_inodes=497348,mode=755 0 0 13 | run /run tmpfs rw,nosuid,nodev,relatime,mode=755 0 0 14 | /dev/sda / ext4 rw,relatime 0 0 15 | securityfs /sys/kernel/security securityfs rw,nosuid,nodev,noexec,relatime 0 0 16 | tmpfs /dev/shm tmpfs rw,nosuid,nodev 0 0 17 | devpts /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0 18 | ...... 19 | 20 | This file is processed by `jfs_load()` function: 21 | 22 | void jfs_load(int load) 23 | { 24 | ...... 25 | mfp = setmntent("/etc/mtab", "r"); 26 | for (i = 0; i < JFSMAX && (mp = getmntent(mfp)) != NULL; i++) { 27 | strncpy(jfs[i].device, mp->mnt_fsname, JFSNAMELEN); 28 | strncpy(jfs[i].name, mp->mnt_dir, JFSNAMELEN); 29 | strncpy(jfs[i].type, mp->mnt_type, JFSTYPELEN); 30 | mp->mnt_fsname[JFSNAMELEN - 1] = 0; 31 | mp->mnt_dir[JFSNAMELEN - 1] = 0; 32 | mp->mnt_type[JFSTYPELEN - 1] = 0; 33 | } 34 | endmntent(mfp); 35 | ...... 36 | } 37 | 38 | We should use dedicated functions: `setmntent()`, `getmntent()` and `endmntent()` to parse `/etc/mtab` file. -------------------------------------------------------------------------------- /posts/kernel-statistics.md: -------------------------------------------------------------------------------- 1 | # Kernel statistics 2 | 3 | Inputting '`k`' can get kernel statistics: 4 | 5 | ![image](https://raw.githubusercontent.com/NanXiao/read-nmon-code-to-learn-analyzing-linux-performance/master/images/kernel-statistics.jpg) 6 | 7 | The first "column" (`RunQueue`, `Blocked`, etc) is read from `/proc/stat` file; the second "column" (`user`, `user_nice`, etc) is just the first line of `/proc/stat` (please refer [CPU utilization](cpu-utilization.md)). 8 | 9 | The third column (`Load average`) is read from `/proc/loadavg` file: 10 | 11 | $ cat /proc/loadavg 12 | 2.38 1.92 1.83 4/3725 102478 13 | They are the numbers of jobs in the run queue (state `R`) or waiting for disk I/O (state `D`) averaged over `1`, `5`, and `15` minutes. 14 | 15 | The fourth column (`Uptime` related things) is read from `/proc/uptime` file: 16 | 17 | $ cat /proc/uptime 18 | 1215709.48 121718010.10 19 | 20 | The first field is system boot time while the second one is time spent for idle process (both units are seconds). 21 | 22 | The third and fourth columns are processed by `proc_kernel()` function: 23 | 24 | void proc_kernel() 25 | { 26 | int i; 27 | p->cpu_total.uptime = 0.0; 28 | p->cpu_total.idletime = 0.0; 29 | p->cpu_total.uptime = atof(proc[P_UPTIME].line[0]); 30 | for (i = 0; i < strlen(proc[P_UPTIME].line[0]); i++) { 31 | if (proc[P_UPTIME].line[0][i] == ' ') { 32 | p->cpu_total.idletime = atof(&proc[P_UPTIME].line[0][i + 1]); 33 | break; 34 | } 35 | } 36 | 37 | sscanf(&proc[P_LOADAVG].line[0][0], "%f %f %f", 38 | &p->cpu_total.mins1, &p->cpu_total.mins5, &p->cpu_total.mins15); 39 | } 40 | 41 | 42 | -------------------------------------------------------------------------------- /posts/disk-utilization.md: -------------------------------------------------------------------------------- 1 | # Disk utilization 2 | 3 | Inputting '`d`' can get disk utilization: 4 | 5 | ![image](https://raw.githubusercontent.com/NanXiao/read-nmon-code-to-learn-analyzing-linux-performance/master/images/disk_utilization.jpg) 6 | 7 | The `proc_disk()` function is like this: 8 | 9 | void proc_disk(double elapsed) 10 | { 11 | struct stat buf; 12 | int ret; 13 | if (disk_mode == 0) { 14 | ret = stat("/proc/diskstats", &buf); 15 | if (ret == 0) { 16 | disk_mode = DISK_MODE_DISKSTATS; 17 | } else { 18 | ret = stat("/proc/partitions", &buf); 19 | ...... 20 | } 21 | ...... 22 | } 23 | 24 | After `Linux 2.6`, `/proc/diskstats` replaced `/proc/partitions`. My `Linux` kernel's version is `4.19.4`, and the `/proc/diskstats` is like following: 25 | 26 | $ cat /proc/diskstats 27 | 8 0 sda 24517099 658117 3634832978 137524335 5161201 1899656 2471640416 126499269 0 15834950 222007107 0 0 0 0 28 | 8 1 sda1 24517060 658117 3634830626 137524328 5147969 1899656 2471640416 126443415 0 15730970 221884500 0 0 0 0 29 | ...... 30 | 31 | While `/proc/partitions` is very slim: 32 | 33 | $ cat /proc/partitions 34 | major minor #blocks name 35 | 36 | 8 0 1000204632 sda 37 | 8 1 1000203608 sda1 38 | ...... 39 | 40 | For every field's meaning of `/proc/diskstats`, you can refer [I/O statistics fields](https://www.kernel.org/doc/Documentation/iostats.txt). BTW, the "`Transfers`" in above image refers the sum of read and write operations: 41 | 42 | void proc_diskstats(double elapsed) 43 | { 44 | ...... 45 | p->dk[i].dk_xfers = p->dk[i].dk_reads + p->dk[i].dk_writes; 46 | ...... 47 | } 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /posts/cpu-utilization.md: -------------------------------------------------------------------------------- 1 | # CPU utilization 2 | 3 | During the home screen, you can press '`c`' to get CPU utilization chart: 4 | 5 | ![image](https://raw.githubusercontent.com/NanXiao/read-nmon-code-to-learn-analyzing-linux-performance/master/images/cpu_utilization.jpg) 6 | 7 | CPU utilization metrics are read from `/proc/stat` file: 8 | 9 | $ cat /proc/stat 10 | cpu 69329351 1546 2133140 1777137470 701736 266457 200025 0 0 0 11 | cpu0 1381282 4 75089 16197830 12424 6417 107331 0 0 0 12 | cpu1 1368760 13 67306 16310343 9995 6896 19434 0 0 0 13 | ...... 14 | 15 | After `Linux 2.6`, every CPU row has `10` items: `user`, `nice`, `system`, `idle`, `iowait`, `irq`, `softirq`, `steal`, `guest` and `guest_nice` (For the meaning of every metric, please refer [/proc](http://man7.org/linux/man-pages/man5/proc.5.html) document), and the value is measured in units of `USER_HZ`. The first row is the total statistics of the system, and followings are the information of every CPU. In the screen, `User%` consists of `user` and `nice`, `Sys%` is composed of `system`, `irq` and `softirq`, etc. Please refer `nomon` code: 16 | 17 | ...... 18 | cpu_user = RAW(user) + RAW(nice); 19 | cpu_sys = 20 | RAW(sys) + RAW(irq) + RAW(softirq); 21 | /* + RAW(guest) + RAW(guest_nice); these are in addition to the 100% */ 22 | cpu_wait = RAW(wait); 23 | cpu_idle = RAW(idle); 24 | cpu_steal = RAW(steal); 25 | 26 | cpu_sum = 27 | cpu_idle + cpu_user + cpu_sys + cpu_wait + 28 | cpu_steal; 29 | ...... 30 | 31 | BTW, press '`l`' can display CPU utilization in `long-term` format, which can help you get the overview of system better in real time: 32 | 33 | ![image](https://raw.githubusercontent.com/NanXiao/read-nmon-code-to-learn-analyzing-linux-performance/master/images/cpu_utilization_long_term.jpg) 34 | 35 | 36 | -------------------------------------------------------------------------------- /posts/memory-utilization.md: -------------------------------------------------------------------------------- 1 | # Memory utilization 2 | 3 | Inputting '`m`' can show memory utilization: 4 | 5 | ![image](https://raw.githubusercontent.com/NanXiao/read-nmon-code-to-learn-analyzing-linux-performance/master/images/mem_utilization.jpg) 6 | 7 | Memory utilization metrics are parsed from `/proc/meminfo` file (For the meaning of every metric, please refer [/proc](http://man7.org/linux/man-pages/man5/proc.5.html) document): 8 | 9 | $ cat /proc/meminfo 10 | MemTotal: 196664796 kB 11 | MemFree: 160337264 kB 12 | MemAvailable: 177147604 kB 13 | Buffers: 1098864 kB 14 | Cached: 16097336 kB 15 | SwapCached: 0 kB 16 | Active: 19958356 kB 17 | Inactive: 13062956 kB 18 | ...... 19 | 20 | Please beware that in `proc_mem()` function, some metrics are only valid if `LARGEMEM` macro is defined (Refer this [document](https://wiki.debian.org/Hugepages) to know what is "Huge pages".): 21 | 22 | void proc_mem() 23 | { 24 | ...... 25 | #ifdef LARGEMEM 26 | ...... 27 | p->mem.hugetotal = proc_mem_search("HugePages_Total"); 28 | p->mem.hugefree = proc_mem_search("HugePages_Free"); 29 | p->mem.hugesize = proc_mem_search("Hugepagesize"); 30 | #else 31 | p->mem.bigfree = proc_mem_search("BigFree"); 32 | #endif /*LARGEMEM*/ 33 | } 34 | 35 | You can also press '`V`' to get "virtual memory" statistics: 36 | 37 | ![image](https://raw.githubusercontent.com/NanXiao/read-nmon-code-to-learn-analyzing-linux-performance/master/images/virtual_memory.jpg) 38 | 39 | The information is read from `/proc/vmstat`: 40 | 41 | $ cat /proc/vmstat 42 | nr_free_pages 34583276 43 | nr_zone_inactive_anon 77718 44 | nr_zone_active_anon 8755682 45 | nr_zone_inactive_file 2972621 46 | nr_zone_active_file 1707733 47 | nr_zone_unevictable 56 48 | nr_zone_write_pending 19037 49 | nr_mlock 56 50 | ...... 51 | 52 | and processed by `read_vmstat()` function. --------------------------------------------------------------------------------