In this article, we will examine the configuring of a Monit monitoring system for the operation with NetPing devices for monitoring server rooms. Monit is a light system for server monitoring that is installed in a server and provides a possibility to send notifications if the issues are discovered. Besides, Monit can autonomously execute the action determined by you as a reaction to specified events. It is an independent daemon that works from the user root. The simplicity of the system is its main advantage. In a minimal configuration, having the executable and the configuration file is enough. A functionality of the system can be extended by using scripts.
To implement the operation of the example of server room monitoring on the basis of Monit and NetPing server room environmental monitoring units, we will need:
Configuring UniPing server solution v4/SMS and connecting sensors
To start the operation, we need to execute basic configuration of the equipment:
- Go to the section of settings of a server room monitoring unit;
- Implement a basic configuration of a network interface;
- Implement a basic configuration of access parameters (login and password of a Web interface, community read and write, IP access filter) when necessary.
To connect a 1-Wire sensor, there is a need to know its unique ID. The connection process is described well in this article. This way, 1-Wire temperature sensors and 1-Wire humidity sensors are connected.
It is possible to get the information about connecting and configuring sensors from the official documentation.
Supply voltage sensor, leakage, door opening and air flow are connected to IO lines. These sensors are sensors of a dry contact type. In the documentation, there is a good description of their configuration.
Installing and Configuring Monit
As the first step, you need to download and install a monitoring system Monit and install its auxiliary packages that are necessary for the operation of the scripts on a server with a preinstalled OS Ubuntu x64.
Download the archive with Monit from their official website:
copy it to a home folder and rename as shown below:
There is a need to configure a built-in web server for the first test start of the system:
In the file /home/user/monit/conf/monitrc, find the section that starts with set httpd port 2812 and, and make it look like below:
In the end of the file, configure connecting of user configuration files and show their location:
Install SNMP and Curl packages. To gather readings, we will need snmpget, and curl will be necessary to record data to a database.
Start a monitoring system. Clearly specify the path to the executed file and a configuration file on the start.
A system interface is not remarkable and contains a minimum of necessary elements. On default, we see the information on the server, where Monit is installed.
To add new monitoring elements, there is a need to specify services for monitoring in a configuration according to the documentation. By default, Monit cannot read any readings via SNMP, but it can execute third-party scripts and on the basis of the code, it can perform certain actions, which opens space for customization. This is what we will do.
To monitor the sensors that are used in this example, we have prepared three scripts, and they must be located to /home/user/monit/conf/scripts:
- get_io.sh - a script reads a status of an IO line of a UniPing server solution v4/SMS server room environmental monitoring unit, and is launched with the parameters ./get_io.sh <IO line number> <normal value> <alert value> (for example, for a supply voltage sensor that is connected to IO1 - /get_io.sh 1 1 0). IP address of a device and community are specified in the body of a script.
- get_relhumtemp1w.sh - a script reads the readings of a relative humidity sensor and a built-in temperature sensor, it is launched with the parameter ./get_relhumtemp1w.sh <sensor number>, top and bottom threshold of a humidity and temperature range are taken by the script from UniPing server solution v4/SMS, and on this basis, it issues the alert. The IP address of a device and community is specified in the body of the script.
- get_temp1w.sh - a script reads the readings of a temperature sensor and is launched with the parameter ./get_temp1w.sh <sensor number>, top and bottom thresholds of a temperature range are taken by the script from UniPing server solution v4/SMS, and on this basis, it issues the alert. The IP address of a device and community are specified in the body of a script.
Place a configuration file that must be extracted from the archive to /home/user/monit/conf/user:
- netping - monitoring the accessibility of UniPing server solution v4/SMS (ping) and readings of sensors connected to it are configured in a configuration file.
Afterwards, reload Monit:
And, we see the information on the sensors connected to a device for monitoring a server room UniPing server solution v4/SMS in a web interface of monitoring system Monit:
At this point, the main part of configuring Monit and UniPing server solution v4/SMS for monitoring a server room is completed. Monit cannot draw graphs "out of the box". To achieve this, use the link of InfluxDB + Grafana:
- InfluxDB - is a time-series database that is similar to RRD in its peculiarity;
- Grafana - is a powerful and flexible Dashboard.
Installing and Configuring InfluxDB
To install InfluxDB, go to the official website in the section downloads. Search for our operating system in the list - Ubuntu x64 is used in the example:
Now, we need to allow controlling the base through HTTP API in a configuration file. To do this, there is a need to uncomment the next lines shown below in the file /etc/influxdb/influxdb.conf:
Then, reload InfluxDB to apply new settings:
And create a database for storing readings of sensors:
You can read a complete documentation for InfluxDB on the official website.
Installing and Configuring Grafana
Go to the official website in the section downloads.
According to the version of our OS, download and install a package:
Load and configure to autoload:
Then edit the file /etc/grafana/grafana.ini
Now, we can see a web interface on the addressas shown below:
At first, we must specify where the stored readings of the sensors are saved, so-called Data Source. Go to the linkClick Add data source:
Then, fill in the fields in a next way:
- Type - InfluxDB (data source type).
- Name - netping_ds (data source name).
- URL - (database connection address).
- Database - netping (a name of a database that was created by us during the step of installing InfluxDB).
Below, click Save & Test:
After this, our data source will appear on the list, in the database InfluxDB, where the data gathered from sensors are stored:
A process of configuring a Dashboard is described in the documentation. Within the framework of this article, we will not examine it, but we will import a ready Dashboard instead:
Then, download a JSON file.
Specify a desired name for our Dashboard and a unique identifier (leave on default), and click Import:
And, we see a ready Dashboard showing all connected sensors:
Monit is a lightweight monitoring system that is directed first of all on monitoring of servers, network, and a variety of services. Gathering readings of sensors using this system is significant and needs skills of working with a command line and writing scripts. Besides, a system does not allow to build graphs "out of the box" which creates certain difficulties in the operation. Nevertheless, a system manages to monitor a single host completely, the same as automation when making decisions on the basis of monitoring data.