Monitor your network with RaspBerry Pi

Welcome to our blog post today.


As my colleague has already described to you, since the move in March we have had problems with our availability by telephone.

There are a variety of solutions to keep an eye on the status of the Internet connection and other devices in the network. Today I present you a solution with a RaspBerry Pi, which you can also implement at home to monitor your home network.

I opt for a solution in which no packages need to be installed and configured. When setting up, you only need to connect to the RaspBerry Pi once via SSH and carry out the initialization with a simple command.


For this we need the following:

1x Raspberry Pi (Model 3 B + recommended)
1x suitable SD card with at least 16GB
1x USB card reader

 

NEMS - Nagios Enterprise Monitoring Server

1. Preparation


NEMS is a pre-configured Linux distribution with all the necessary packages. Installation is kept as simple as possible. First we download the ISO file from the manufacturer's website:

https://nemslinux.com/

We go to "Get NEMS Linux" → "NEMS for RaspBerry Pi" and either choose "Direct Download" or can download the file via BitTorrent.

We use the Etcher program to write the ISO file to the SD card. We download this from https://etcher.io/ and install the program.

After starting Etcher, the following window appears:

 

Etcher

First, we select our NEMS ISO file using "select image".


With "Select Drive" we now select the target drive. ATTENTION:  all data on the drive will be overwritten! To ensure that you have selected the correct drive, I recommend, if possible, first clicking on "Select Drive" and only then connecting the card reader. The device will then appear in the selection and we can be sure not to accidentally overwrite the wrong drive:

etcher2

etcher3


Now we click on "Flash", confirm the security dialog that may appear, and the data is written to the SD card and checked.

2. The first start-up


I strongly recommend using a RaspBerry Pi with an Ethernet interface, and I will not go into the WLAN setup in this article. So if you want to use a RaspBerry Pi Zero, you can use a USB to Ethernet adapter.

We connect the RaspBerry Pi via HDMI cable to a screen, insert the prepared SD memory card, and connect our Pi to electricity.

After an inconspicuous boot process, a display appears on which we see the IP address which was assigned to the Raspberry Pi via DHCP.

 

So we open a web browser and call up the IP address. The message appears that our NEMS server has not yet been initialized. We should connect via SSH and execute the command "sudo nems-init".



Under Windows 10 I can now simply call up the command line by pressing the Windows key and R together for "run". A window appears with the title "Run" in which I can specify which program Windows should run. I type "cmd" and confirm with the Enter key.


In the command line, we now enter the command "ssh", followed by the user name, an @ sign, and the IP address. The username with which we should log in is "nemsadmin". So we enter: "ssh nemsadmin@196.168.168.45".

Since we have not yet established an SSH connection to this system, we are asked whether we are sure that we want to establish the connection. We can confirm this by entering "yes".
Only the password for the user "nemsadmin" is asked. This is also called "nemsadmin".

SSH

We now enter the "sudo nems-init" command to begin initializing the server and confirm this again by entering the password.

The user nemsadmin is removed during the initialization and a new user is created for us. So we have to provide a username. I call the user markus and provide a password.

Next we have to choose the time zone. In my case I choose "Europe" and then "Berlin".

Select time zone

Initialization via SSH is now complete. We are asked to restart the RaspBerry Pi by pressing any key.

 

Now our device restarts and makes the necessary changes to the system. After the restart, the system load may appear somewhat high. This may take a few minutes and shouldn't worry us.

A look back at the web interface shows that the initialization was successful:

After the nems init

First we go to "CONFIGURATION" → "NEMS System Settings Tool". Modern browsers like Firefox and Chrome will now issue a warning because we use a self-created SSL certificate. We click on "ADVANCED" and below on "Continue to 192.168.x.x (unsafe)".

Warning message in the browser

Now we log in with the newly created user account.

registration

In the NEMS System Settings Tool, we should now enter a password for encrypting and decrypting backup files.

In addition, on this page we can provide the access information for a Telegram chatbot, a pushover account, or for an SMTP mail server, so that NEMS can notify us in this way.

We save the changes by clicking on "Save all Settings".

Post init

 

Next we look at what is currently being monitored. For this we go to the menu item "Reporting" and select "Adagios". Adagios is a somewhat more modern interface for displaying the various Nagios data.

Here, too, I log in with my user markus. On the overview page we see that only one host is monitored and all hosts and all services are running.


With a click on "Hosts" we see a list of all monitored systems. Only our RaspBerry Pi with the name NEMS currently appears in the list.

 

 

This would complete the installation, and I would normally say goodbye here and point to an upcoming blog post - however, I would like to add a host to monitor as this is not self-explanatory and I do not want to leave you hanging here .



We close the Adagios tab from the browser and are back on our NEMS main page. Now we can use the menu "Configuration" → "NEMS Configurator (NConf) to call up the page with which we can configure Nagios.
Here, too, I log in with my user markus.

NConf

Welcome to the NConf main page. At this point I cannot give an introduction to the functionality and configuration of Nagios, but anyone who has had to work with the configuration files manually will confirm that this initially confusing tool simplifies a lot.

I would like to add a destination on the Internet, the availability of which I check at regular intervals using a ping command. As long as I get an answer from the target, our internet connection is available. However, as soon as the goal cannot be reached, our NEMS notices this. The time and failure of the Internet are logged.
Many use the IP addresses of Google or Cloudflare DNS servers for this. For this example I use the Google DNS server with the IP address 8.8.4.4

You can use any destination on the Internet as long as you are sure that the destination server is always available and responds to ping requests.

So in NConf we go to “Hosts” on “Add”. In our case, we can enter anything as the host name and alias. I just call it "Internet". We take the address 8.8.4.4 already mentioned as the IP address
"Default Nagios" must be selected in the "monitored by" field.

For Host Template we choose "generic-host" and push it with the green arrow into the window "selected items". We do the same with the entry "admins" in the area "contact groups". (Please ignore the IP in the screenshot, this should be 8.8.4.4):

 

Below we give the values ​​for "max check attempts", "check interval", "relay interval", "first notification delay", "notification interval".

With "notification options" I only want to be notified if the target is "down" or "unreachable", so I enter "d, u".


By clicking on "Submit" we save the installations.

On the next page we mark the entry "PING" in the text field "Advanced services (directly linked)" and push it with the upper arrow into the right window. Please don't forget to click "Save".


Now comes the stumbling block on which most users get stuck: so that our NEMS takes over the settings, a Nagios configuration file must first be created from the settings made, and this must then be made available.

So we click on "Generate Nagios config". Due to the few changes, this should go through without errors. Then we go to "Deploy".



If the deployment went through with 3 OK, we can look at our Adagios overview again:



The number of hosts has now increased to 2 and there are currently no faults. If we go to “Hosts” in the menu, both currently monitored hosts are displayed.

With the RaspBerry Pi, we have installed a cost-effective solution for network monitoring in a short time.

Now you can set up notification options, add devices and services, and more, as needed.

Nems also offers some nice "out-of-the-box" functions. It is e.g. possible to save the complete configuration of the NEMS system in a file via the browser. If the SD card or the RaspBerry Pi fails, it can be restored very quickly and easily.

Also nice is the display at http: // nems / tv / which you can call up in any web browser to see the current status.

 

Of course there are still a lot of options and possibilities, but I hope this article has sparked your interest in the world of network monitoring.

To our contribution "we are online"have already given some expert readers feedback. The alternative solutions proposed are definitely superior to the NEMS system in all areas - however, the installation and setup with NEMS is so elegant that I wanted to present this solution.

Did you find today's post interesting? Feel free to leave a comment or write us via email.

I hope we were able to get some people to get their RaspBerry out of the drawer or box to try out the NEMS system.

So I say goodbye for today, and wish everyone a lot of fun with the handicrafts.

Yours Markus Neumann

 

Grundlagen softwareRaspberry pi

6 comments

Ben

Ben

Hi,
I just install nems on a pi3b+, i’m noob in monitoring nrtwork and your small tuto help me to discover that.
Thanks a lot.
Sincerly
Ben (from France)

Denny

Denny

Hi,

vielen Dank für den Guide. Ich habe erfolgreich mit der Anleitung einen Rasp Pi 3b mit der aktuellsten Version von NEMS aufgesetzt. Nun bin ich dabei, die IT unseres Unternehmens damit zu Überwachen. Wir haben 2 physische Server, 10 virtuelle, 13 Clients, 1 Firewall, 4 Switche. Gerne würde ich alle über NEMS im Auge behalten. Jedoch komme ich mit der Konfiguration nicht zurecht. Könnte mir da jemand behilflich sein? denny.lukic@gmail.com wäre meine Mail. Vielen Dank

Udo

Udo

Hallo ,
die Erklärung um das einzurichten genial ,mit dem Programm ,muss man sich rein Arbeiten .
Hallo OlegR ,
habe ich Versucht bin aber ohne Erklärung nicht zum Testen gekommen .

Markus sehr gut rüber gebracht ,Dankeschön

Udo

Rozaanywowl

Rozaanywowl

Great post!

OlegR

OlegR

Viel einfacher geht’s mit Check_MK https://github.com/chrisss404/check-mk-arm

Kann ich nur empfehlen….

Sanofit

Sanofit

Sehr guter Beitrag, sehr ausführlich und Praxis bezogen erklärt. So sollte der Service bei einem Händler aussehen. 1A+++ Vielen Dank Richard Samt.

Leave a comment

All comments are moderated before being published