Nagios on a Rasp Pi 3 with NEMS
Small but Mighty
Enterprise asset monitoring can be a daunting and expensive task. If you are interested in asset monitoring but have avoided it in the past because of price or complexity, you can now get a fully configured open source Nagios distribution made for easy deployment on affordable hardware. Nagios Enterprise Monitoring Server (NEMS) [1] is a pre-configured, customized, and ready-to-deploy Nagios Core [2] image designed to run on the Raspberry Pi 3 microcomputer and the Odroid XU4/4Q – so far. NEMS was developed by Robbie Ferguson [3] to be a nearly turnkey package; that is, the majority of the work required to integrate the various open source software components has been done for you.
NEMS begins with a lightweight Debian Stretch deployment optimized for performance, reliability, and ease of use. It monitors network-attached servers, switches, applications, and services, generating alerts when things go wrong and again when the problem has been resolved.
The Hardware
I run NEMS on a Raspberry Pi 3, which needs a minimum 8GB microSD card (a 16GB+ card is recommended). My server has been running for more than a year with a 32GB microSD without coming close to filling the disk.
Access is through a browser and SSH, in which case no other hardware is necessary (i.e., a keyboard, monitor, or mouse). The Pi is powered by a 5V micro-USB. To avoid power issues, use a power supply that provides 2.5A to the Pi.
The Software
In this article, I cover the download and installation of the latest version of NEMS with a subsequent installation of the most current rolling updates. At the time of writing, the latest version was 1.2.1, with rolling updates upgrading the system to version 1.2.2. The latest version of NEMS is available from the developer's website [1].
After downloading the ZIP file of about 1.27GB, extract the image file from the archive. The software you use to copy the image file to the microSD is dependent on the operating system you are using to create the microSD. The NEMS web page has links to instructions for Windows, Linux, and Mac systems.
Installation
Before inserting the imaged microSD card into your Pi, make sure it is not plugged in or is turned off. Plugging in the Pi power supply will boot NEMS. The server will then obtain an IP address via DHCP and connect to your network. For ease of access via SSH and browsers, reserve an IP address on your DHCP server.
Using an SSH program (e.g., PuTTY), you connect to the server on port 22 with the reserved IP address. The default username is pi , and the default password is raspberry (Figure 1). Now enter
sudo nems-init
to initialize NEMS. The nems-init
process:
- allows you to set the Pi user password,
- requests a username and password for use by the NEMS applications,
- asks you to set your time zone,
- resizes the root partition to take advantage of all the available microSD storage, and
- reboots the device.
As of version 1.2.1, you do not have to download and re-image when a newer point release becomes available, although major releases will require re-imaging.
The NEMS logon splash screen displays the version running, along with the most current version available. To update to the most current version, enter:
sudo nems-upgrade
The upgrade process includes downloading and installing project and operating system updates. Depending on the number of updates required, it can take anywhere from five to 20 minutes. After the upgrade is complete, reboot the server.
Once the reboot is complete, connect again via SSH and use the Nano editor to modify the resource.cfg
file:
sudo nano /etc/nagios3/resource.cfg
Now add your SMTP information to the sendemail section (Listing 1). The settings in this section are used by the server to send email notifications. For a more detailed look at how to set your SMTP information for your specific needs, please see the documentation on the NEMS website.
Listing 1
resource.cfg (Excerpt)
### sendemail SMTP Config added in NEMS 1.1 # The "from address" for notifications $USER5$=example@gmail.com # The SMTP server $USER7$=smtp.gmail.com # the SMTP authentication username and password $USER9$=example@gmail.com $USER10$=examplepassword
Once more, reboot after changing and saving the settings. NEMS setup is now complete, and you'll see the updated version information on the splash screen.
Buy this article as PDF
(incl. VAT)