Quantcast
Channel: LinOxide
Viewing all articles
Browse latest Browse all 1287

How to Install pagemon - A Tool to Monitor Process Memory

$
0
0

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.

Installation

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

poornima@poornima-Lenovo:~$ 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)
OK

Now, update the repository and install pagemon

sudo apt-get update

sudo apt-get install pagemon

poornima@poornima-Lenovo:~$ 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
linux-headers-3.16.0-23 linux-headers-3.16.0-23-generic
linux-image-3.16.0-23-generic linux-image-extra-3.16.0-23-generic
ruby-celluloid ruby-hitimes ruby-timers tsconf
Use 'apt-get autoremove' to remove them.
The following NEW packages will be installed:
pagemon
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.

Usage

Here is the screen shot showing the options available as of now with pagemon.

pagemon help options

In order to monitor a process, we need to pass the process id to pagemon tool.

sudo pagemon -p 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.

poornima@poornima-Lenovo:~$ sudo pagemon -p 1

poornima@poornima-Lenovo:~$ sudo pagemon -p ($pidof init)

Page view of 'init' process

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.

Memory view of init process

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

VM state of a process

If you want to increase or decrease the delay (in microseconds) in data refreshes, use the '-d' option. Default is 10,000 microseconds.

For more options, refer the man page of the tool and its source can be cloned from ubuntu kernel page.

Conclusion

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.

The post How to Install pagemon - A Tool to Monitor Process Memory appeared first on LinOxide.


Viewing all articles
Browse latest Browse all 1287

Trending Articles