When it comes to system monitoring tool, Linux is unbeatable. There are a bunch of tools you can use to monitor the system performance, be it GUI based tools or command line-based tools. One of which is nmon.
nmon is a command line-based system monitoring tool. It is a versatile tool which you can use to check the resource usage on your Linux system. From CPU, memory to disk. This tool was written by Nigel Griffiths from IBM. nmon itself stands for Nigel’s Monitor.
nmon is completely easy to use. Simply type
nmonon the terminal and the tool will display the menu. To perform certain analysis, simply hit one of buttons displayed on the menu. For instance, if you want analyze the CPU usage, you can hit the
C button on your keyboard.
The vast majority of Linux distros haven’t installed nmon by default, but they commonly have added the tool on their software repositories. If you use a distro that haven’t added nmon on its software repository, you can download the binary file of nmon on its official site. If you use Debian-based distro, you can install nmon by typing the following command.
sudo apt install nmon
As I said, nmon is extremely easy to use and requires no complex options to use. You can start using the tool by simply typing
nmon on the terminal. This command doesn’t require root access so all users on your system will be able to use it. The downside of nmon is that is has no back menu. To switch from a certain analysis page to another one, you have to quit first before being able to perform another analysis. To quit from nmon, you can hit the
Following is the list of keyboard shortcuts you can use on nmon:
- c = check CPU stats
- m = check memory stats
- d = check disk stats
- k = check kernel stats
- n = check network stats
- j = check file system stats
- t = check top processes
- V = check virtual memory stats
- v = check verbose mode
Example uses of nmon
Let’s take an example. Let’s say you want to check the current CPU usage on your system. As you can see on the list above, you can use the
cbutton to check the CPU usage on your system. nmon will display the usage stats of your CPU in a real-time. To get started, simply type the
nmoncommand on the terminal then hit the
cbutton. You should see the following output.
Writing nmon data to a file
In addition to display the system resource usage in a real-time, you can also write the data generated by nmon in a file. To do so, you have to specify a time frame of seconds and snapshots options. What this does is set the amount of data snapshots incremented by your time options. As nmon runs, it snapshots the data to a CSV file to work with later on.
There are two options for filname you can use: “f” and “F”. If you use the option of “f”, you will get the default filename with the format of “<hostname>_YYYYMMDD_HHMM.nmon”. Conversely, you can use the option of “F” to specify a custom filename. Following is the example of how to write the nmon data to a file using the “F” option.
nmon -F nmon_stat -s 30 -c 20
The command above will launch nmon in the background and take a snapshot every 30 seconds up to 20 times. This should equate to 10 minutes of data snapshots. “nmon_stat” on the command above is the custom filename. You can use the raw data collected by nmon to perform a further analysis using a more decent analyzing tool.