nmon for Linux - Compiling from the Source Code
- Assuming you can't find a pre-compiled version (See Download Binaries in the left Menu) or want a really fresh version to match your Linux system.
nmon is pretty simple to compile - the whole thing takes no more than 3 minutes if you have your distro OS DVD media online:
- Download the latest source code (it is just one file names lmon<version>.c) and the makefile
- Install the GCC C Compiler, ncurses development library and (if its not already available) Install the make command
- Hard link the latest C source code file to the filename lmon.c (lmon.c is used in the makefile)
- Edit the makefile to find your platform, OS and version in the makefile or make a new one
- Run make and you have a new version in roughly 4 seconds. Ready to run.
For action 1: Just click on the link below to open in a different Tab and wait 10 seconds. The download should continue automatically. Ignore all the horrible adverts and deliberately confusing screen messages. I suspect lots of those links will download viruses, malware and worse.
Current Version 16e
|lmon16e.c||New function and bug fixes (7th July 2016): |
1) Boottime shown online in the Kernel "k" panel
like: 02:35 PM 12-Jan-2016 and in the nmon file as AAA,boottime,02:35 PM 12-Jan-2016
2) Utilisation stats: /proc/stat now reports 10 Utilisation stats including KVM guest VM CPU use = cool.
But Guess what? ALL 10 don't add up to 100% and it is not documented.
KVM guest CPU use is reported in the KVM host total User and Kernel time (guest virtual machines are seen
as user processes) AND reported separately in addition in the guest and guest_nice values.
Fixed the reporting of these numbers online but still learning.
The nmon file reports just the stats so you have to realise which add up to 100%
3) Bug caused Seg Faults core dumps fixed while collecting to a file including top process stats.
Fix: Improved memory handling for extreme numbers of processes (1000's) or rapid exec of processes
(100's in a millisecond) for large Linux servers. We have examples on Intel of 80 CPU cores and POWER 160+
4) Online Dot "." command no longer also changes what is displayed as users said it was confusing.
You switch on Top processes "t" and disks "d" then if you type dot "." then processes or disks doing
nothing are filters out.
5) Minor online start-up flash screen text changes to include C concise CPU stats and U for full
Utilisation stats (all 10 of them)
6) Some people what nmon data to be written on the standard output stream instead of a file.
To do this use:
nmon -F stdout <followed by your regular options>
./nmon-F stdout -s1 -c 10 -U| grep CPUUTIL_ALL
Warning: this is a little experimental as nmon still closes stdin and stderr streams which can
cause pipe issues with specific commands. Feedback welcome.
7) Copyright and GPL v3 notice in the code plus online "h" and nmon -h output
|lmon16d.c||Tiny Changes: |
a) fix to online Welcome screen + added Mainframe details
b) fix to curses handling that caused one distro on one platform to core dump
|lmon16c.c||Tiny Changes: |
a) adding back the SccsId by popular demand
b) adding #ifdef ARM for Raspberry Pi2 - even runs Ubuntu Mate now
c) running indent -kr -l200 to improve readability
|lmon16b.c||New Features: |
1) The previous nmon 16a's "Z experiment" was finished but now use On-screen Utilisation "U" (for CPU Utilisation stats)
or for capture to file -U and look for the CPUUTIL lines in the output file
Instead of the classic UNIX User, System, IO-Wait and Idle - we find Linux now has ten categories
which are user, user_nice, system, idle, iowait, irq, softirq, steal, guest, guest_nice.
This is tricky to graph and display within nmon so the 10 stats are added stats i.e. replacing the classic views/data
as there is not enough space online and changing the output file format would break many tools
2) Older code and stats maintains the classic values as User (includes nice), System (includes irq & softirq & guest & guest_nice),
IO-Wait and Idle but some online graphs show Steal.
3) On-screen Kernel stats layout was improved
4) Bug fixes: BBBP double quotes confuse spreadsheet and replaced with "Q", #ifdef corrected.
Released: 7th January 2016
|lmon16a.c||New Features: |
1) Nvidia GPU support - online & saved to file
* You need a S822LC
* With NVIDIA GPU(s)
* and Nvidia Library installed libnvidia-ml.so
2) CPU Wide View - online view for up to 192 CPUs
3) CPU MHz per Core ratings for machine that allow cores with different MHz - online & saved to file
4) lscpu stats capture - online & to file
5) Z experiment mode showing CPU interrupts - more to come in version 16b - online only
6) Online colourising stats to aid usability - online only
7) Massive improvement in help information: nmon -? and nmon -h
8) Code change to alphabetic order for getopt() and key input functions - just code clean up
9) New nmon logo on flash screen - online only
10) Extra kernel stats - online only
11) makefile - large improvement for hardware platforms and Linux versions
plus some some bugs like SLESS11.3 "lsblk" has missing TYPE option handling, networks stats trailing comma
Released: 1st January 2016
|lmon15g.c||1) Reduced time drift |
In data capture mode, zero time drift due to nmon compute time - nmon own CPU time is tracked and accumulated
even if knocked off the CPU while running. Once over a second the next inter-snapshot sleep time is reduced.
Thanks to Sergei Rodionov but 10 seconds in 5 hours was pretty good but not good enough for Sergei :-)
2) New Function Top process ordered by storage I/O
Top processes stats now supports mode 5 = reordering on storage I/O by each process.
The Page faults also gets changed to show the storage stats. Unfortunately, /proc/PID/io has permissions "r------" so
it is only readable by the process owner and root. So nmon limits this to root user only.
I think this is a Linux /proc bug that needs fixing!
So if the root user, type 5 and
now changes to
and the output is ordered on the total of these columns. Thanks to David Braun for the reminder.
3) Reduction of screen artefacts
Reordering screen output cursor function, mode the welcome screen to a pad and coloured red the new CPU details.
Fingered crossed - no more old output characters showing as you change modes etc.
Most often seen in Top Processes mode: "u" = show user command and "." show only running processes.
Thanks to David Braun pointing out the issue.
13th July 2015
|lmon15f.c||New Function stop disk stats duplication |
Added -g auto option to create a User Define Disk Group file called "auto" this takes lsblk| grep disk output
for a disk to disk map excluding disk partitions. This stops disk stats and partition stats duplication.
With this online looking at disk stats, hit "G" and the partition disappear.
With this saving to a file -g auto or regular -g file then you have -D for extra User Disk Group stats:
like disk wait time & disk service times, merges, in-flight I/O count & backlog.
For disk stats documents (read 25 lines) see https://www.kernel.org/doc/Documentation/iostats.txt
9th July 2015
|lmon15e.c||Removed saved to file Network stats trailing comma |
File systems stats accuracy
JFS stat to screen round up like df command output,
Using ceil() some Distro's need -lm in the new makefileJFS Use% calculated on available size not total size.
Delta=blocks reserved for root use.
3rd May 2015
Thanks to Sergei Rodionov for the idea
|lmon15d.c||Clean up CPU Steal% stats - April 2015|
|lmon15c.c||New Function CPU Steal stats |
Added CPU Steal% stats for VM CPU being stolen by Hypervisor - April 2015
Thanks to Sergei Rodionov for the idea & example code
|makefile||Used to compile nmon. Note: new version 3rd May 2015|
|Older versions||Use these, if we have introduced a bug in the latest version above|
|lmon14i.c||Previous stable source code version|
|lmon14g.c||Even older stable source code version|
For action 2: you have to work out how to do that for your Linux flavour. Hints:
- Debian / Ubuntu
- sudo apt-get update
- sudo apt-get install gcc*
- sudo apt-get install ncurses-dev*
- sudo apt-get install make
- Fedora / Redhat - as the root user
- yum install gcc*
- yum install ncurses-dev*
- yum install make
- OpenSUSE / SUSE - as the root user
- yast install gcc*
- yast install ncurses-dev*
- yast install make
For action 3: Assuming the version you just downloaded is 99z with: ln lmon99z.c lmon.c
For action 4:
Assuming you are OK with some UNIX/Linux editor like vi.
- Edit the makefile - You are looking for the right combination of
- Platform (Power, x86 x86_64 or mainframe)
- Linux distribution
- Linux version
- You have a POWER processor based machine and running SLES 11.3 - look for the lines starting nmon_power_SLES113
- You have a old 32 bit AMD or Intel processor based machine and running RHEL5 - look for the lines starting nmon_x86_RHEL5
- You have a 64 bit AMD or Intel processor based machine and running Ubuntu 14.10 - look for the lines starting nmon_x86_64_ubuntu1410
If you find a match remember the exact name for the make file command below.
If you don't find a match you need to make one by copying the nearest match and making changes.
- Select one using the Processor - there are compile time options for each processor. Then one with a similar Linux version.
- Don't worry about Big and Little Endian - the compiler will compile for what ever you are currently running on.
Example: Ubuntu 15.4 is just out and you have a power CPU
The closest entry is
gcc -o nmon_power_ubuntu1410 $(FILE) $(CFLAGS) $(LDFLAGS) -D POWER -D KERNEL_2_6_18
Copy and change this to
gcc -o nmon_power_ubuntu1504 $(FILE) $(CFLAGS) $(LDFLAGS) -D POWER -D KERNEL_2_6_18
For action 4:
- You are ready to compile with: make nmon_power_ubuntu1504
- or using the Platform + Linux Disto + version that you found in the makefile.
- The nmon binary will be in your local directory and called: nmon_power_ubuntu1504
* You can:
- rename the nmon command to something smaller
- or link it to say nmon with: ln nmon_power_ubuntu1504 nmon
- or if root install nmon in a regular path: cp nmon_power_ubuntu1504 /usr/bin/nmon
Hope you get your nmon working, Cheers Nigel