Example of Server Room Monitoring on the Basis of Monit, InfluxDB, Grafana and NetPing Monitoring Units

  • Published In: Tutorial
  • Created Date: 2018-08-09
  • Hits: 62

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:

  1. Go to the section of settings of a server room monitoring unit;
  2. Implement a basic configuration of a network interface;
  3. Implement a basic configuration of access parameters (login and password of a Web interface, community read and writeIP access filter) when necessary. 

Configuring UniPing Monitoring Units

Connecting sensors

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

1-Wire temperature sensors

Configuring UniPing Monitoring Units

1-Wire humidity sensors

Configuring UniPing Monitoring Units

Supply voltage sensorleakagedoor 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.

Configuring UniPing Monitoring Units

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:

wget https://mmonit.com/monit/dist/binary/5.25.2/monit-5.25.2-linux-x64.tar.gz

unpack it:

tar xvf monit-5.25.2-linux-x64.tar.gz

copy it to a home folder and rename as shown below:

cp -R monit-5.25.2-linux-x64 /home/user/monit

create folders for your configuration files and scripts:

mkdir /home/user/monit/conf/user

mkdir /home/user/monit/conf/scripts

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:

set httpd port 2812 and #change a server port for a necessary one, if needed
    use address 192.168.0.123 #specify address, where a server will wait for incoming connections
    allow admin:monit #credentials for logging in to a web interface

In the end of the file, configure connecting of user configuration files and show their location:

include /home/user/monit/conf/user/*

Install SNMP and Curl packages. To gather readings, we will need snmpget, and curl will be necessary to record data to a database.

apt-get install snmp curl

Start a monitoring system. Clearly specify the path to the executed file and a configuration file on the start.

/home/user/monit/bin/monit -c /home/user/monit/conf/monitrc    

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.

NetPing Monit Dashboard

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:

Afterwards, reload Monit:

/home/user/monit/bin/monit -c /home/user/monit/conf/monitrc reload all

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:

NetPing Monit Dashboard with sensors

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:

wget https://dl.influxdata.com/influxdb/releases/influxdb_1.5.4_amd64.deb
sudo dpkg -i influxdb_1.5.4_amd64.deb

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:

enabled = true
bind-address = "localhost:8086"

Then, reload InfluxDB to apply new settings:

service influxdb restart

And create a database for storing readings of sensors:

curl -i -XPOST http://localhost:8086/query --data-urlencode "q=CREATE DATABASE netping"

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:

wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana_5.2.1_amd64.deb 
dpkg -i grafana_5.2.1_amd64.deb

Load and configure to autoload:

service grafana-server start
update-rc.d grafana-server defaults

Then edit the file /etc/grafana/grafana.ini

htpp_addr = 192.168.0.123 #interface, in which a web server will be waiting for incoming connections

http_port = 8484 #port, where a web server will be waiting for incoming connections

Reload:

service grafana-server start

Now, we can see a web interface on the address http://192.168.0.123:8484 as shown below:

Grafana Home

At first, we must specify where the stored readings of the sensors are saved, so-called Data Source. Go to the link http://192.168.0.123:8484/datasources. Click Add data source:

Grafana adding a data source

Then, fill in the fields in a next way:

  • Type - InfluxDB (data source type).
  • Name - netping_ds (data source name).
  • URL - http://localhost:8086 (database connection address).
  • Database - netping (a name of a database that was created by us during the step of installing InfluxDB).

Grafana adding a data source

Below, click Save & Test:

Grafana save DS

After this, our data source will appear on the list, in the database InfluxDB, where the data gathered from sensors are stored:

Grafana data source NetPing

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:

Download:

Go to:

Grafana import NetPing Dasboard

Then, download a JSON file.

Grafana import NetPing Dashboard

Specify a desired name for our Dashboard and a unique identifier (leave on default), and click Import:

Grafana import NetPing Dashboard

And, we see a ready Dashboard showing all connected sensors:

Grafana NetPing Dashboard

Conclusion

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.


Tags: All devices
comments powered by Disqus