Network monitoring with Raspberry PI and NEMS (Nagios)

5
(4)

Last Updated on 26th May 2023 by peppe8o

In this tutorial, I’m going to show you how to install and use NEMS on Raspberry PI, also showing how to add a simple monitoring task.

Home systems and small office server 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 service status and activate support groups on failures.

What ordinary people don’t know is that one of the most powerful monitoring systems available on the 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 the NEMS server adds very useful GUIs.

What is NEMS

NEMS is the Nagios Enterprise Monitoring Server, a project of Category5 TV. It is a sophisticated, ready-to-use monitoring distro for single board computers (SBCs), designed to include all the software needed to run Nagios on the Raspberry Pi and other microcomputers in a single distribution image like 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 deployment optimized for performance, reliability and ease of use.

What You Need

As usual, I suggest adding from now to your favourite e-commerce shopping cart all the needed hardware, so that at the end you will be able to evaluate overall costs and decide if to continue with the project or remove them from the shopping cart. So, hardware will be only:

Raspberry PI 4 model B 8GB

You will also need an ethernet cable for the first boot because NEMS OS hasn’t a WiFi pre-configuration procedure and because it suggested using a wired connection.

Step-by-Step Procedure

Preparing SD Card

First of all, get the latest version of the OS image. From NEMS Linux home page select GET NEMS LINUX from the top main menù and click “NEMS for Raspberry PI”.

nems-homepage-get-raspberry-pi

Scroll the page to the bottom and choose your favourite download type (direct or torrent).

nems-raspberry-pi-download

You will get a “.zip” file which includes the “.img” operating system image but, usually, there is no need to extract it for flashing.

Flash the image to your SD card with your favourite software. If you use the Raspberry PI Imager, open it (in Windows, please run it with administrative permissions). Please click the “Choose OS” button:

raspberry-pi-imager-select-os

Scroll down and select “Use Custom” option:

raspberry-pi-imager-custom-os

Select the downloaded image of NEMS:

raspberry-pi-imager-select-nems-1.6

Now that your OS image is

raspberry-pi-imager-nems-select-storage

If not already done, you can plug the micro SD card in your PC where the flashing software is installed and please select it:

raspberry-pi-imager-nems-micro-sd-select

When using custom images, I also suggest using the Raspberry PI Imager with the Advanced Options empty. This can save your life as in some particular cases these options that work with the default Raspberry PI OS could make custom OSes not boot. So, open the Advanced Settings from the related button:

nems-raspberry-pi-advanced-options

And check that all the fields are empty:

nems-raspberry-pi-advanced-options-empty

After saving, you can now proceed with the “Write” button and wait for the image flashing to be completed. Then, insert the micro SD card in your Raspberry PI, connect the ethernet cable and power it on.

Connecting NEMS Dashboard

The first time you power on your Raspberry PI, 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 the very first boot).

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

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

nems-raspberry-pi-not-yet-initialized

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

nems-raspberry-pi-certificate-warning

This screen may vary depending on your browser. As this is your Raspberry PI address and you’re in your local network, go to “Advanced” and click “Accept the risk and continue”. The NEMS login page will be shown:

nems-raspberry-pi-login-page

Use default NEMS user credentials:

  • use: nemsadmin
  • password: nemsadmin

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

nems-raspberry-pi-browser-terminal-session

In this session, type the command:

sudo nems-init

The following steps will help in the initial configuration. It will start with the timezone selection:

nems-raspberry-pi-init-timezone

Select your one with up/down arrow keys and go to OK with the tab key, then confirm. The next screen will allow configuring your city:

nems-raspberry-pi-init-timezone-city

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

Now NEMS asks you to create a user (with your favourite credentials) that will take the place of the less secure default user with the default password. Please write your username:

nems-raspberry-pi-init-username

and your password (twice):

nems-raspberry-pi-init-password

In the following question, you can also set the email address where to send notifications.

Removing the default user will cause a disconnection of the current user (no more existing):

nems-raspberry-pi-init-disconnected

The NEMS initialization has been completed.

Main NEMS Pages

After NEMS installation and initialization, you have to go back to the home page by using only the Raspberry PI IP address as URL in your browser (removing subdirectories from the URL):

nems-raspberry-pi-home-page

This page shows the Raspberry PI main system parameters. You can find here, in the top menù, a list of internal links that will give you configuration and/or reporting access by requiring your credentials (if you are logged out).

Configuration Page

From the home page, you can reach a very important page: NEMS Configurator (NConf). Available from the “CONFIGURATION” main menu, it is used to add hosts and services and to configure your monitoring tasks:

nems-raspberry-pi-nconf-link

As we’ve been disconnected after providing the new credentials in our initialization step, we’ll be required to enter the username and password:

nems-raspberry-pi-authenticate

So, we’ll reach the NConf page, from where you can add/show devices, services and so on:

nems-raspberry-pi-nconf-page

In the following chapters, please remember that each new configuration needs a “deploy” action to be alive.

Reporting Pages

Another important part of the NEMS home page is the “REPORTING” section:

nems-raspberry-pi-reporting-menu

From here you can select your favourite reporting dashboard, like Adagios:

nems-raspberry-pi-adagios

The Nagios TV Dashboard:

nems-raspberry-pi-nagios-tv-dashboard

Nagios Core:

nems-raspberry-pi-nagios-core

NEMS Tactical Overview:

nems-raspberry-pi-nagios-tactical-overview

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 the terminal is more detailed. But the following example will explain how to do it in an easier way.

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

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

Define New Host

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

nems-raspberry-pi-nagios-add-host-01

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

  • hostname: raspberrypi.local
  • alias: My Second Pi
  • address: 192.168.1.85
  • 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

Now, please click the Submit button at the bottom part of the page:

nems-raspberry-pi-nagios-add-host-02

The following page enables us to setup a number of deeper services. For a basic ping, we don’t need to create services. On left menù, click “Generate Nagios config”:

nems-raspberry-pi-nagios-add-host-03

Once the monitoring configuration is performed, we can deploy it to the NEMS service with the button highlighted at the bottom part of the following page:

nems-raspberry-pi-nagios-add-host-04

A confirmation page will show all the deploying jobs successfully completed:

nems-raspberry-pi-nagios-add-host-05

After configuration deployment is finished, you can switch to Adagios in order to check the new host after clicking the “Hosts” link from menù:

nems-raspberry-pi-nagios-show-host-adagios

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

A real-time monitor is available from NEMS Tactical Overview, which refreshes itself automatically and will warn once failed ping is detected. For example, shutting down the monitored Raspberry PI (my 192.168.1.85 host), I’ll get warned of the issue:

nems-raspberry-pi-nagios-show-host-tactical-overview-fail

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

nems-raspberry-pi-nagios-show-host-adagios-fail

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

Nagios info for deeper configurations can be found on Nagios official docs page.

Enjoy your NEMS Raspberry PI server!

How useful was this post?

Click on a star to rate it anonymously!

Average rating 5 / 5. Vote count: 4

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?