If you are administering a server on Linux, you are probably looking for simple, reliable and convenient tools for solving a variety of problems. One of them is monitoring the condition of servers.
Although there are plenty of monitoring tools, it is usually not so simple to find what will be included in the everyday set of programs. That is why today we want to talk about one such solution, the utility that we use every day. The program in question is called Nigel’s Monitor , or just nmon.
This is real-time, simple interface but full of information to display various indicators characterizing the health of the server. This simple utility would show you the usage of processor and memory, information about network resources, disk drives, file system and NFS, and about processes. The set of indicators displayed can be customized. Nmon has a text interface, therefore, to work with it, just connect to the server via SSH. We strongly recommend to install and use nmon.
The nmon utility can be installed from standard repositories of server OS distribution kits. That is, you are unlikely to encounter any difficulties. If your system uses
apt(these are Debian, Ubuntu, and others), you need to execute the following commands in the terminal:
sudo apt-get update sudo apt-get install nmon
For distributions using
dnf(among them Red Hat, Fedora, CentOS), the installation will look like this:
dnf install epel-release dnf install nmon
As you can see, everything is simple. We pass to work with nmon.
Working with nmon
So, nmon is installed, now you can run it by running the command
nmon. In the utility window, shown in the figure below, you need to specify exactly what information you are interested in, including and disabling the relevant information sections.
The main nmon window contains tips on enabling and disabling the various sections of system information.
Let’s say you’re interested in disk drives. If you press a key
don the keyboard, nmon will display information about all disks connected to the server.
The nmon monitoring tool displays disk data.
Next, add information sections with network and memory information by pressing the
m. As a result, the data set about the system will be supplemented by indicators of interest to us.
Adding information about the network subsystem and memory to the monitoring window You can turn off the display of certain sections using the same keys that were used to display them. In addition, nmon supports the ability to change the refresh rate of data. This is done using the keys “
-” and “
+” on the keyboard. The first, accordingly, reduces the speed of updating indicators, the second – increases.
In order to exit nmon, press the key
q, this will return you to the usual bash prompt.
Data Collection with nmon
The tool includes the ability to capture data and save it to a file. This can be very useful if you need to analyze the data on the state of the system over a certain period of time.
Suppose you need 30 “snapshots” of the state of the system, which must be done every 60 seconds. You can organize this using the following command:
nmon -f -s 60 -c 30
Here, the key
-findicates that the data should be written to the file, the key
-ssets the time intervals, in seconds, between the “snapshots”, and the key
-ctells the program that we need 30 sets of indicators.
Half an hour after the above command is executed, the file with the extension we are interested in will appear in the current working directory
You can analyze this file, for example, using the nmonchart utility, which will create a web page from it containing nice graphics.
Analyzing data collected by nmon using nmonchart
Data collection planning
If you need to organize a regular collection of data on server performance indicators, for example, to identify recurring problems, you can use the cron jobs. It is done like this. First, create a bash script, say, with a name
nmon.sh, with this content:
#! /bin/sh nmon -f -s 60 -c 30
The file must be saved and given permission to execute using the command
chmod u+x nmon.sh. Now open the file
crontabfor editing with the command
crontab -eand enter the following:
30 11 * * * ~/nmon.sh
After saving the changes, the cron job will run daily at 11:30 a.m. Of course, you substitute here the time that you need, having at your disposal a convenient tool to identify the causes of server problems.
Bottom line: really simple and really useful
We are sure it will not be easy for you to find a simpler and more convenient solution for monitoring Linux-servers, suitable for monitoring systems in real-time and for collecting data that you plan to analyze later.