Network monitoring with Raspberry PI and NEMS (Nagios)

Check my RPI articles in Best Raspberry PI projects article or peppe8o.com home page. Or subscribe my newsletter (top right in this page) to be notified when new projects are available!
5
(1)

Home systems and small office servers failures can be annoying when you rely on their availability and realize that they aren’t working only when you need them.

For similar reasons, big companies (which can get economic damages from outages) adopted complex monitoring systems able to check services status and activate support groups on failures.

What common people don’t know is taht one of most powerful monitoring system available on market is an open source software: Nagios. It is so spread in ICT Field that it forked in a version dedicated to single board computers (NagiosPI), on which NEMS adds very usefull GUIs.

In this tutorial I’m going to show you how to install NEMS on Raspberry PI. I will also show a very first configuration example, setting from GUI a simple ping monitoring task.

What is NEMS

NEMS is the Nagios Enterprise Monitoring Server. It is a sophisticated, ready-to-use network monitoring distro for single board computers (SBCs), designed include in a single distribution image all the software needed to to run Nagios on the Raspberry Pi and other micro computers such as those from ODROID or PINE64. Evolved to include enterprise builds for VMWare ESXi, Amazon Web Services’ EC2, Docker and more, it features a modern, self-hosted browser-based UI, and countless extras. At its core NEMS is a lightweight Debian Buster deployment optimized for performance, reliability and ease of use.

What You Need

As usual, I suggest adding from now to your favourite ecommerce shopping chart all needed hardware, so that at the end you will be able to evaluate overall costs and decide if continuing with the project or removing them from shopping chart. So, hardware will be only:

  • Raspberry PI (including proper power supply or using a smartphone micro usb charger with at least 3A). Raspberry PI 3 Model B or newer are
  • high speed micro SD card (at least 16 GB, at least class 10). Consider that the raw OS will use more that 6GB of space, so 8GB SD Cards are too small.

You will also need an ethernet cable for first boot because NEMS OS hasn’t wi-fi pre-config procedure and because it suggested to use wired connection. If your board does not have Ethernet (like RPi Zero W and RPI 3 model A+) you’ll need to boot, press CTRL-ALT-F1 and type: raspi-config to go through the standard WiFi setup for the device before you can use NEMS.

Check hardware prices with following links:

Amazon raspberry pi boards box
Amazon Raspberry PI Power Supply box
Amazon Micro SD box

Step-by-Step Procedure

Preparing SD Card

First of all, get OS image. From NEMS Linux home page select GET NEMS LINUX from top main menù and click “NEMS for Raspberry PI”. Scroll page to bottom and choose your favourite download type (direct or torrent).

You will get a “.zip” file which includes the “.img” operating system image.

Flash it in your SD card with your preferred software. If you use Raspberry PI Imager, please remember to extract (uncompress) image before flashing it.

Using Balena Etcher, insert SD card in your PC and run Etcher as administrator and select previously downloaded zip file. SD card should be already set:

Etcher NEMS (Nagios) image selected

Click “Flash!” button and wait for operation to be finished.

Inser SD card in Raspberry PI, connect ethernet cable and power on.

Connecting NEMS Dashboard

First time you power on, NEMS will automatically resize its filesystem to fill your SD card and reboot. So, it is better to wait a few minutes before log-in (only on very first boot).

Identify your Raspberry PI IP address (consider that default hostname will be nems.local). Mine one is 192.168.1.21, so you will use your one instead of mine.

From your favourite browser, connect to your Raspberry PI address:

NEMS boot first page

Click “open a browser-based terminal session”. You may have a security warning because this url doesn’t use a certificate:

NEMS boot certificate warning

This screen may vary depending on your browser. Go to advanced and click “Accept the risk and continue”. NEMS login page will be showed:

NEMS login page

Use default NEMS user credentials:

  • use: nemsadmin
  • password: nemsadmin

This default user/password will be same also for SSH connections. Click “Log In” button. A terminal session appears now:

NEMS home browser terminal session

In this session, type command:

sudo nems-init

A sudo password will be required, use the default one (nemsadmin). Following steps will help in initial comfiguration. It will start from timezone selection:

NEMS timezone select

Select your one with up/down arrow keys and got to OK with tab key, then confirm. Next screen will allow to configure your city:

NEMS city or region select

Select your one and push Ok. Next screen will let you choose what locales to generate. You can select your one or go direct on “Ok” and confirm with next default ones (en_US.UTF-8).

Next screen will let you configure your keyboard model:

NEMS keyboard layout select

(generic ones will probably work with most models) and then keyboard layout:

NEMS keyboard language select

Next screen showing keyboard configuration can be left as default and go on:

NEMS keyboard configuration

In next screen, you can leave compose key setup with default configuration (no compose key):

NEMS compose key select

Final operations will ask you from console to set a username and password different from default one, with a n email address.

Initializazion procedure will finish. You can now logout from nemsadmin and from here you will use last credentials set.

Main NEMS Pages

After NEMS installation. you have to go back on home page by using only Raspberry PI IP address in URL (removing sub directories):

NEMS home page

From this page, which shows main Raspberry PI system parameters.

Configuration Page

From home you can reach a very important page: NEMS Configurator (NConf). Available from “CONFIGURATION” main menu, it is used to add hosts and services and to configure your monitoring tasks. Remember that each configuration needs a “deploy” action to be alive.

NEMS NConf home page

Reporting Pages

Another important section is “REPORTING”. From here you can select your favourite reporting dashboard, like Adagios:

NEMS Adagios home page

Nagios Core:

NEMS Nagios Core home page

NEMS Tactical Overview:

NEMS Tactical Overview home page

Configure Your First Network Monitoring Task From GUI

Nagios and NEMS doc pages are not very rich on how to configure monitoring services from GUI, while configuration from terminal are more detailed. But following example will explain hot to do it in the easier way.

I will setup a very simple monitoring task which will control my second Raspberry PI (which has IP address 192.168.1.91) only by pinging it.

We’ll need to define the new host, configure ping monitoring and generate new configuration to deploy on live monitoring.

Define New Host

From NEMS NConfig, on left menù, find “Hosts” row and click “Add” button near it.

NEMS Add Hosts page

Even if you can configure a huge number of parameters, for this basic purpose complete following ones:

  • hostname: raspberrypi.local
  • alias: My Second Pi
  • address: 192.168.1.91
  • host preset: linux-server
  • monitored By: Default Nagios
  • host template(s): linux-server
  • contact groups: admins
  • check interval: 1
  • retry interval: 1
  • first notification delay: 3

At the end, click Submit button (bottom part of page).

You don’t need to create services for this basic configuration. On left menù, click “Generate Nagios config”

NEMS NConfig Generate nagios config

And click “Deploy”. After configuration deployment is finished, the new host will appear in Adagios page under hosts menù:

NEMS Adagios hosts list with raspberry pi

This page shows that host has been reached and is up (which means it is correctly answering ping signals).

Shutting down the monitored RPI, we need only to wait for set “check interval” time on host definition.

A real time monitor is available from NEMS Tactical Overview, which refreshes itself automatically and will warn once failed ping is detected:

NEMS Tactical Overview 1st failure

while NEMS Adagios require a manual refresh to show current state:

NEMS Adagios raspberry pi failure

More documentation about NEMS can be found in NEMS official docs page.

Nagios info for deeper configutations can be found in Nagios official docs page.

Enjoy!

How useful was this post?

Click on a star to rate it anonymously!

Average rating 5 / 5. Vote count: 1

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?