Recently, Colin Ian King from Canonical has developed a new tool called 'pagemon'. It is an ncurses based interactive memory monitoring tool which allows users to browse the memory map of an active Linux process. Page Table Entries (PTEs) are the basis for the working of this tool. Pagemon continuously scans the PTEs of a given process and displays the dirty activity in real-time. It can also identify the type of mapping a memory page belongs to. Due to this, users can easily scan through the memory and easily identify pages of memory that belongs to code, data, stack, heap, anonymous mappings or swapped out pages. The tool is available in Ubuntu Xenial.
In order to install pagemon on Debian based systems, first install the ppa repository "ppa:colin-king/pagemon".
Note: Ubuntu 15.10 has been used in the below examples.
sudo add-apt-repository ppa:colin-king/pagemon
[email protected]:~$ sudo add-apt-repository ppa:colin-king/pagemon
[sudo] password for poornima:
Page monitoring tool
More info: https://launchpad.net/~colin-king/+archive/ubuntu/pagemon
Press [ENTER] to continue or ctrl-c to cancel adding it
gpg: keyring `/tmp/tmpsdek8lba/secring.gpg' created
gpg: keyring `/tmp/tmpsdek8lba/pubring.gpg' created
gpg: requesting key B0F01786 from hkp server keyserver.ubuntu.com
gpg: /tmp/tmpsdek8lba/trustdb.gpg: trustdb created
gpg: key B0F01786: public key "Launchpad PPA for Colin King" imported
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)
Now, update the repository and install pagemon
sudo apt-get update
sudo apt-get install pagemon
[email protected]:~$ sudo apt-get install pagemon
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
gcj-4.9-jre-headless gcj-4.9-jre-lib gir1.2-gconf-2.0 libboost-thread1.55.0
libdirac-encoder0 libgcj15 libmediaart-1.0-0 libmircommon3 libts-0.0-0
ruby-celluloid ruby-hitimes ruby-timers tsconf
Use 'apt-get autoremove' to remove them.
The following NEW packages will be installed:
0 upgraded, 1 newly installed, 0 to remove and 65 not upgraded.
Need to get 16.0 kB of archives.
After this operation, 42.0 kB of additional disk space will be used.
Get:1 http://ppa.launchpad.net/colin-king/pagemon/ubuntu/ wily/main pagemon i386 0.01.06-1~w [16.0 kB] Fetched 16.0 kB in 0s (25.0 kB/s)
Selecting previously unselected package pagemon.
(Reading database ... 319256 files and directories currently installed.)
Preparing to unpack .../pagemon_0.01.06-1~w_i386.deb ...
Unpacking pagemon (0.01.06-1~w) ...
Processing triggers for man-db (2.7.4-1) ...
Setting up pagemon (0.01.06-1~w) ...
You are now ready to launch pagemon and use it. But remember that you need to always use 'sudo' as it needs to intrude a running process.
Here is the screen shot showing the options available as of now with pagemon.
In order to monitor a process, we need to pass the process id to pagemon tool.
sudo pagemon -p <process name> OR
sudo pagemon -p <pid> OR
sudo pagemon -p $(pidof process) - if you do not know the pid.
The example below shows how to monitor the memory activities of init process using pagemon.
[email protected]:~$ sudo pagemon -p init
[email protected]:~$ sudo pagemon -p 1
[email protected]:~$ sudo pagemon -p $(pidof init)
Another interesting feature of this tool is that it is also possible to view the memory pages belonging to heap, stack, data, code, anonymous mappings and swapped out pages by hitting the 'enter' key when in the pageview. Its ability to show memory pages getting swapped out under high memory pressure is quite useful.
We can view the VM state by using the -v option with pagemon. It displays details like the state of the process (running / sleeping), VM size, PTE, Swap, major and minor page faults etc.
sudo pagemon -p <pid> -v
If you want to increase or decrease the delay (in microseconds) in data refreshes, use the '-d' option. Default is 10,000 microseconds.
Pagemon is useful in tracking page activity of running processes. The developer claims that the code is of early developmental quality but does work quite well if anyone is interested in trying. There could be more features added to it in the coming days. Overall, a cool tool to try out.