Friday 3 July 2015

Monitor your local network with NagiosPi

Monitor your local network with NagiosPi

Embrace the power of Nagios to keep an eye on servers, switches and applications on your network

Is your PC offline? Has your Linux box stopped serving Minecraft or Counter-Strike? If you’re out of the house, or even the country, there is no real way of knowing without trying to log in – something you probably won’t be able to do without being on the premises (unless you’re using remote desktop software).

A far better way would be to simply receive notifications when your network devices are knocked offline, and this is why we turn to NagiosPi, a Raspberry Pi-built version of the popular open source network monitoring tool.

NagiosPi is available as a full image ready to be written to SD card, with the real configuration taking place once it’s up and running. Let’s get started.

What you’ll need
- NagiosPi (piimagehub.com/project/nagiospi)
- Win32 Disk Imager (bit.ly/L8JdYG)
- Disk Utility (bit.ly/1Lec9r5)
- Internet connection
- 4 GB (or larger) SD card

01 Download and write NagiosPi to SD


Windows users should write the extracted contents of the NagiosPi_v2.0.zip file to a formatted SD card using Win32 Disk Imager. Linux desktop users can use Disk Utility or the command line (bit.ly/1z36sp8). With the image written to SD, safely eject the card and insert it into your Pi before booting.

02 Log in to NagiosPi


As with most Pi projects, you’ll probably want to operate via SSH, so check your router’s list of connected devices to find the IP address and connect. You can also use a keyboard and monitor connected to your Raspberry Pi. The default username and password for NagiosPi is pi/raspberry.

03 Expand the filesystem


Before proceeding, run sudo raspi-config. You’ll need to select the first option, Expand Filesystem, and wait a moment as the filesystem is expanded to the full size of the SD card.

Once done, select Change User Password to add some security to your NagiosPi, then select Finish and reboot.

04 Open NagiosPi in your browser


With the Pi rebooted, you’ll be able to open the NagiosPi web console in your browser. Visit http://[your.IP.address.here] to see the available options.

Here you’ll spot a menu of links in the top-left corner, each accompanied with the username and password to sign in. Start with RaspControl.

05 Monitoring your NagiosPi box


In the RaspControl section you’ll get a flavour of just what Nagios can do. On the home screen you’ll see general hardware information such as connectivity and system status, and as you flick through Details, Services and Disks you’ll see what level of monitoring is possible.

06 View host status in NagiosPi


Next, go to Nagios and pick Hosts. Here you will see the current status for the configured hosts, which is a combination of items detected on your local network and preset entities. Look for Current Network Status in the upper-left area of the console; just below this you will find alternate views.

07 Adding a host to monitor


Open NConf to add the server you wish to monitor, using the Hosts – Add button to input the device hostname, IP address and alias. Click Submit when done, then switch to Services – Add, where you can assign a name and check command (such as check_ping) to monitor.

08 Create your configuration file


Each check must be set up individually. Some require the installation of NRPE (Nagios Remote Plugin Executor) on remote devices to interrogate and present full system details, but this isn’t necessary for basic things like ping.

When you’re done, click Submit, then Generate Nagios Config. Following this, select Deploy.

09 Monitor your server


In the NagiosPi window, select Services for a view of currently monitored servers and devices. For each listed device, there will be additional information that you drill down into by clicking under Actions.

We’ve only shown you the basics of NagiosPi – investigation will demonstrate just how powerful it really is!