The sys admin's daily grind: Nmon

Easy, Mon


Nmon monitors system information. You can use the Nmon's capture mode to output data to a file, then extract the values you need with a script.

By Charly Kühnast

The Nmon [1] performance monitoring application uses two operating modes: interactive and capture. In interactive mode, this alternative to the top command is a more straightforward, and more communicative, system monitor. Keyboard shortcuts let you view the CPU, disk, and network load statistics in this autonomously refreshing command-line program. Additionally, you get statistics on the kernel's workload and individual volume groups, as well as an overview of the physical and virtual memory and the NFS. Verbose simple checks, which you can display by pressing V, are also interesting. The checks show critical system parameters at a glance, giving you a traffic-light-style green, amber, or red view.

Overview or Detail?

If you have a large enough display - or just good eyesight - you can display all of this information at the same time. If you lack this ability to survey the whole battlefield at a glance, you can instead restrict the view to critical values for each system. To see the view shown in Figure 1, simply press the C (CPU), D (Disks), N (Network), and V (Verbose Checks) keys after launching the program. T adds a list of active processes, like the list in the legacy top tool.

Figure 1: Press the C, D, N, and V keys for a verbose display of the CPU, disk, and network load.

In capture mode (a.k.a. non-interactive mode), Nmon collects all of this data at a selectable interval and writes it to a file. In this way, you can monitor the development of system parameters over time and forward the data to evaluation tools should the need arise. The tool could be a spreadsheet application that creates a chart from the rows of figures or it could be a script that feeds the data to the RRD tool and thus gives you a continuous, long-term analysis of the system's behavior.

Recording Session

The -f option starts capture mode:

nmon -f -s30 -c120

The file this creates is given a name such as elba_100403_1351.nmon, in which the first part is the hostname, followed by the timestamp (YYMMDD_HHMM). If this format is too bulky for you, you can use -F Name to define your own name. The -s30 parameter tells Nmon to write its results to the file every 30 seconds, with 120 repeats (-c120), which gives you an hour of measured values. The file is cleartext with comma-separated measured values:

CPU04,T0029,0.0,0.0,0.0,100.0

This output example shows load values for a CPU; T0029 means that this is the 29th interval since sampling started. Armed with the right evaluation tool, you can easily use a script to extract the values you need.

That's all there is to it!

INFO
[1] Nmon: http://nmon.sourceforge.net
THE AUTHOR

Charly Kühnast is a Unix operating system administrator at the Data Center in Moers, Germany. His tasks include firewall and DMZ security and availability. He divides his leisure time into hot, wet, and eastern sectors, where he enjoys cooking, freshwater aquariums, and learning Japanese, respectively.