How to Install Nmon on Ubuntu Linux

Nmon monitors CPU usage, memory consumption, disk I/O, and network traffic in real time through an interactive terminal interface. Whether you need to diagnose performance bottlenecks, track resource usage during application testing, or record system metrics for capacity planning, nmon provides the visibility required without the overhead of graphical monitoring tools. By the end of this guide, you will have nmon installed on Ubuntu, understand how to navigate its interactive interface, and know how to capture performance data to CSV files for later analysis.

Update Ubuntu Before Nmon Installation

Before installing nmon, refresh your package index to ensure you install the latest available version from Ubuntu’s repositories:

sudo apt update

Install Nmon via APT

Nmon is available in Ubuntu’s default repositories for all currently supported LTS releases. Install it using the following command:

sudo apt install nmon

Once the installation completes, verify that nmon is accessible by checking its version:

nmon -V

Expected output confirming the installed version:

nmon version 16p

This guide supports all currently active Ubuntu LTS releases. Nmon is available in Ubuntu’s default repositories across all versions, and the commands shown work identically regardless of your Ubuntu release.

Launch Nmon Interactive Monitor

Nmon operates in two modes: interactive mode for real-time monitoring and recording mode for data collection. First, to start interactive monitoring, launch nmon without any flags:

nmon

This displays the nmon welcome screen showing your hostname, operating system details, and available keyboard shortcuts. Furthermore, press individual keys to toggle different performance views on and off. Additionally, the interface updates automatically at regular intervals, allowing you to monitor changes as they occur.

Essential Nmon Interactive Keys

After launching nmon in interactive mode, press individual keys to toggle performance views. The following keys provide access to the most commonly used monitoring screens:

Monitor CPU Usage

Press c to display CPU utilization statistics with bar graphs showing user, system, and idle time for each CPU core or thread. Consequently, this view helps identify whether CPU bottlenecks are affecting system performance:

Press: c

Alternatively, for systems with many CPU cores, press C instead to see a more compact wide view that displays up to 192 CPUs simultaneously.

View Memory and Swap Statistics

Press m to toggle memory and swap statistics showing used, free, and cached memory along with paging activity. This view reveals whether your system has sufficient RAM or relies heavily on swap space:

Press: m

The memory panel displays percentages and absolute values in megabytes, making it easy to track memory consumption over time.

Track Network Interface Activity

Press n to display network statistics for all active interfaces showing kilobytes per second sent and received, packet counts, and error rates. Network statistics disappear automatically if no errors occur after three screen refreshes:

Press: n

This view helps diagnose network saturation and identifies which interfaces carry the most traffic during peak usage.

Monitor Disk I/O Performance

Press d to show disk I/O statistics with graphs displaying read and write activity in kilobytes per second. Press D multiple times to cycle through additional disk views showing transfers, block sizes, service times, and queue depths:

Press: d (graphs) or D (detailed stats)

These views identify slow disks and reveal whether I/O wait times contribute to performance degradation.

View Top Processes

Press t to display the top processes sorted by CPU usage. Once the top processes view is active, press number keys to change the sort order and detail level:

Press: t (basic view)
Then: 3 (sort by CPU), 4 (sort by memory), 5 (sort by I/O)

Press u instead of t to see full command line arguments for each process, which helps identify exactly which scripts or binaries consume resources.

Check Filesystem Capacity

Press j to display filesystem statistics showing mount points, total capacity, used space, and percentage full for each partition:

Press: j

This view reveals which filesystems approach capacity limits before disk space issues affect system stability or application performance.

Additional Useful Keys

Press h at any time to display the complete help screen listing all available keys. Press q to quit nmon and return to your shell. Press + or - to double or halve the screen refresh interval, and press 0 to reset peak counters to zero.

Capture Performance Data to CSV Files

For capacity planning or post-analysis, nmon can record performance metrics to CSV files that you can import into spreadsheets or analyze with specialized tools. Recording mode runs in the background and continues even after you log out:

nmon -f -s 30 -c 120

This command captures snapshots every 30 seconds for 120 iterations, producing one hour of data. The -f flag switches to recording mode and creates an automatically named file in the format hostname_YYYYMMDD_HHMM.nmon in your current directory. The resulting CSV file contains timestamped metrics for CPU, memory, disk, network, and top processes.

To specify a custom filename instead of the automatic naming, use the -F flag:

nmon -F server_performance.nmon -s 60 -c 1440

This captures one snapshot per minute for 24 hours. To include top process statistics in your recording, add the -t flag, or use -T to also capture full command line arguments:

nmon -fT -s 120 -c 720

For quick capacity planning sessions, nmon provides preset recording modes: -x captures data every 15 minutes for one day (96 snapshots), while -X captures every 30 seconds for one hour (120 snapshots).

To analyze recorded data, you can open the resulting .nmon files directly in spreadsheet applications or use dedicated tools like nmon Analyser, an Excel macro that generates charts and summary reports from nmon CSV data.

Automate Recording with Cron

To collect performance data automatically on a schedule, add a cron entry that starts nmon recording at system boot or at specific intervals. Open your crontab for editing:

crontab -e

Add the following line to start a 24-hour recording session at midnight each day:

0 0 * * * /usr/bin/nmon -fT -s 60 -c 1440 -m /var/log/nmon

The -m flag specifies the output directory for recording files. Create the directory first with sudo mkdir -p /var/log/nmon and ensure your user has write permission. Recording files accumulate over time, so implement a cleanup policy to remove files older than your retention period.

Troubleshooting Common Nmon Issues

Command Not Found After Installation

If the shell reports nmon: command not found immediately after installation, verify that nmon installed correctly by checking the package status:

dpkg -l | grep nmon

Expected output showing the installed package:

ii  nmon  16p-1  amd64  performance monitoring tool for Linux

If the package appears as installed but the command still fails, refresh your shell’s command cache with hash -r or open a new terminal session.

Recording Files Not Created

When nmon recording mode produces no output file, verify that you have write permission in the current directory. Additionally, check that nmon is running by searching for its process:

ps aux | grep nmon

If nmon exits immediately, increase the snapshot count or check system logs with journalctl -xe for permission or disk space errors.

Display Corruption in Terminal

If nmon’s interactive display shows garbled characters or misaligned columns, your terminal window may be too small. Resize the terminal to at least 80 columns by 24 rows, or make the font smaller to fit more data. Alternatively, press B to disable box drawing characters if your terminal emulator does not support them properly.

Remove Nmon from Ubuntu

If you no longer need nmon, remove it along with its configuration files using the following command:

sudo apt remove --purge nmon

Clean up any unused dependencies that were installed alongside nmon:

sudo apt autoremove

Verify the removal by attempting to run nmon, which should now report that the command is not found:

nmon -V

Expected output confirming removal:

nmon: command not found

Removing nmon does not delete any CSV recording files you created in your home directory or other locations. If you want to remove recorded performance data, manually delete the *.nmon files from the directories where you ran recording sessions.

Conclusion

You now have nmon installed and configured for monitoring CPU, memory, disk, and network performance on Ubuntu. The interactive interface lets you toggle between different views by pressing single keys, while recording mode captures metrics to CSV files for post-analysis or capacity planning. For remote server monitoring, connect via SSH and run nmon directly in your terminal session. For more comprehensive system monitoring workflows, consider pairing nmon with htop for process management or setting up automated recording sessions via cron for long-term performance tracking.

Leave a Comment