Nmon (Nigel’s performance Monitor for Linux) is another very useful command line utility that can display information about various system resources like cpu, memory, disk, network etc. It was developed at IBM and later released open source. It works on Linux, IBM AIX Unix, Power, x86, amd64 and ARM based system such as Raspberry Pi.
Here I will actually show you this utility and how it works by running it on Linux VM in Microsoft Azure. Why Azure? Because I can spin up VM, run tool on it and destroy it when not needed vs. creating a separate VM for Hyper-V or VirtualBox.
Creating Ubuntu Linux VM is deceptively simple in Azure. Just login into portal, pick Ubuntu from Virtual Machine Gallery and here you go:
However, there is one thing… You will need an SSH certificate to connect to your Linux VM, therefore Azure expects you to have one when you create your VM. To do that I had to install Cygwin and follow directions from here – http://azure.microsoft.com/en-us/documentation/articles/virtual-machines-linux-use-ssh-key/
Using Cygwin you should be able to generate key and then certificate after (.cer file)
To be fair I did attempt to use OpenSSL for Windows to do same first, but Cygwin ended up a lot easier.
Once VM is created you will still need to download Putty to get to it – http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
Puttygen may not be able to read the private key that was created earlier (
myPrivateKey.key). Run the following command to translate it into an RSA private key that Puttygen can understand:
Now lets import that key into Puttygen. I am still following instructions from Azure doc link above. Now I will run PuTTY and attempt to connect to IP of my Ubuntu Azure role that I got from Azure
Next also add your key
Next get this warning:
Finally I can connect:
Next I am going to make sure all my packages are up to date via
sudo apt-get update
Next I will install nmon. That can be done via:
sudo apt-get install nmon
Once the installation of nmon has been finished and you launch it from the terminal by typing the ‘nmon‘ command you will be presented with the following output.
For example, if you would like to collect some statistics on CPU performance you should hit the ‘c‘ key on the keyboard of the system you are using. After hitting the ‘c‘ key on my keyboard I get a very nice output that gives me information on my CPU usage.
Lets add memory by hitting ‘m’ and virtual memory by hitting ‘V’
The following are the keys you can use with the utility to get information on other system resources present in your machine.
- m = Memory
- j = Filesystems
- d = Disks
- n = Network
- V = Virtual Memory
- r = Resource
- N = NFS
- k = kernel
- t = Top-processes
- . = only busy disks/procs
I can get stats on top processes running on my Linux system by using ‘t’
Of course there are other utilities you can use to troubleshoot and monitor Linux, but overall I find nmon really the easiest. If you are running systems like Java on Linux in Azure make sure you use this utility in conjunction with JVM troubleshooting tools such as jstack and jmap and jhat, as I described previously.
For more see – http://www.cyberciti.biz/faq/nmon-performance-analyzer-linux-server-tool/, http://www.tecmint.com/nmon-analyze-and-monitor-linux-system-performance/, http://www.binarytides.com/nmon-linux-system-monitor/