Lead Image © AndreaDanti, 123RF.com

Lead Image © AndreaDanti, 123RF.com

Network monitoring with Icinga and Raspberry Pi

Close Watch

Article from ADMIN 25/2015
Icinga on the Raspberry Pi monitors your network, letting you see the good, the bad, and the ugly, so you can address problems proactively.

The admirable efforts of the Raspberry Pi Foundation have been providing an excellent single-board computer (SBC) that can be applied to almost any need. A simple Raspberry Pi can become a robot, a beer brewing sensor, and even a home media center.

In this article, I will show you how to apply a Raspberry Pi and the network monitoring software Icinga to monitor your networks.

Many people have networks and servers – physical, virtual, cloud, or otherwise – that they want to monitor. For example, you might want to keep tabs on your LAN at home, check in on a remote office, or even monitor your Bitcoin mining rig. Network monitoring is extremely helpful in maintaining an IT infrastructure.

Network monitoring gives you deep insights into what is up, what is down, what is having problems, and network dependencies. You can check availability and be notified of outages.

Over time, performance data can even help you see trends that allow you to address them proactively. You can delve deeply into your routers, switches, firewalls, and servers and understand what's going on in your networks. At a fundamental level you gain actionable insights on maintaining uptime for your networks and servers. Unfortunately, the powerful yet sometimes underutilized tools of network monitoring are often not given the limelight. In this article, I will explore one such unsung technology hero of IT uptime – Icinga.


Icinga [1] is feature-rich, impressive, open source network monitoring software [2]. Started in 2009, Icinga began as a fork of the Nagios project. The creators focused their attention on a modern web interface, a REST API, and support for a wider array of databases. Because Icinga was forked from Nagios code, it maintains compatibility with Nagios plugins [3]. Some of Icinga's key features are:

  • Flexible and scalable architecture.
  • Sleek web interface.
  • Intuitive, template-based configuration.
  • Remote monitoring support.
  • Plugin compatibility with Nagios.
  • Monitoring services on ICMP (ping) or a variety of services (HTTP, DNS, IMAP, POP3, SMTP, etc.).
  • Notifications via alerts on SMS, email, Jabber, etc.
  • Support for Livestatus and Graphite.
  • Support for additional databases such as Oracle or PostgreSQL.
  • Command-line tool with command completion (Icinga 2).
  • Icinga Mobile (for iPhone and Android).

Herein, I focus on the Icinga 1.7.1 release in the existing repositories.

Raspberry Pi

The Raspberry Pi SBC packs some high-quality hardware at a very affordable price. It's compact and requires very little power, and for less than $100, you can build a feature-rich network monitor (see the "What You Need" box). The current version, the Raspberry Pi Model B+ [4] (Figure 1), continues a history of iterative improvements.

What You Need

Keep in mind that once you have a Rasp Pi B+, you need to make a few more purchases. The following list indicates what you will need to complete this project:

  • Raspberry Pi Model B+.
  • 5V, 1A USB power supply.
  • 4GB MicroSD card (minimum); I'm using a 32GB card.
  • Micro USB cable.
  • USB keyboard.
  • Monitor with HDMI, or use a video converter cable for VGA or DVI.
  • Case (optional). A free PDF template allows you to create your own case [5].
  • SD card writer [6]-[8], or buy a MicroSD card with the operating system already installed [9].

The Rasp Pi Model B+ needs a 5V Micro USB power supply, but not just any USB cable will do. Specifically, the Model B+ needs a current of 700mA, often found on conventional phone chargers. Failing to heed these power requirements will leave you with lockups and other system problems.

A MicroSD card of at least class 4 speed will work. SD class ratings relate to performance, so class 10 would be optimal, with a minimum performance of 10MBps, compared with a class 4 of 4MBps. The economics of the storage market produce ever cheaper, higher capacity drives, so you could easily go with an 8, 16, or 32GB option.

Figure 1: Raspberry Pi Model B+.

This new model sports better power consumption, greater I/O, and an even greater array of connectivity options. It is perfect for a project like this that needs a simple, low-power solution but not a full-blown power-guzzling server. For the purposes of this article, my operating system of choice is Raspbian "Wheezy" (i.e., Debian Linux). This can be found in the download section of the Raspberry Pi website [10].

Putting together your system is as easy as pie; simply connect your monitor via HDMI, connect your USB keyboard, connect the Ethernet cable, plug in your MicroSD card, and power up your Pi by plugging in the Micro USB. Once running, you need to log in and set it up. The default username for Raspbian is pi and the default password is raspberry .

Before going live on any network, a machine should be fully patched and updated. Nothing can shield you from zero-day attacks, but you can address any known security issues and bugs. Patching is critical in all cases – even with a simple project such as this. To begin, you should update and upgrade Raspbian, then update the firmware and reboot:

$ sudo apt-get update && sudo apt-get upgrade
$ sudo rpi-update
$ sudo reboot

Your Pi will boot into a configuration program called raspi-config (Figure 2). Navigating it is much like navigating the BIOS or ncurses application where you use the Up, Down, Right, and Left arrow keys and the Tab and Enter keys to navigate and configure the options. Of the many available options, you only need to worry about making changes to a handful of configuration variables.

Figure 2: Raspi-config in all its glory! I do love me a nice ncurses interface.

Expand Filesystem (option 1). Base install images are 2GB, so when you first install or flash Raspbian "Wheezy" to your SD card, it will not show all the available space. Expanding rootfs will expand the root partition to fill the SD card and show the total storage capacity. After a reboot, I saw a full 32GB available. To be sure you have access to all your SD card storage, enter df - hl.

Change User Password (option 2). Keeping the default username and password is never a good idea; you want to change your password to a more secure choice.

Memory Split (option 8). This option is listed under Advanced Options. Your Pi by default is configured to split or share the available memory between both the ARM CPU and the GPU (graphics card). The default configuration is to split it 192MB  ARM/64MB  GPU, but you want to change this to 240MB  ARM/16MB  GPU because you are not planning to run anything other than a server "headless" (i.e., without a monitor), so you really don't need to waste memory on the GPU.

Configuring the Server

Because the Rasp Pi will function as a server, you should set it up to have a static IP on the network. Afterward, you can disconnect the monitor and keyboard and operate the Pi in headless mode. Be sure to give the Rasp Pi an address that isn't within your DHCP range. In this case, you want to go into the interfaces configuration file,

cd /etc/network
sudo nano interfaces

and change the line that begins iface eth0 inet from dhcp to static, then define the address, netmask, and gateway as follows:

iface eth0 inet static

The address reveals that the network is private, that is, an RFC  1918 private network address space. I'm assuming you are using some form of hardware firewall in addition to your server iptables configuration.

If you are interested in rolling your own firewall, then the world of Linux is the place to start. You can build on any distribution or use firewall-focused distros, such as Endian, Untangle, pfSense, or Smoothwall, to name a few. These can be built with conventional desktop-server hardware or in embedded configurations.

To set up name resolution, begin by editing your /etc/resolv.conf to point to the DNS server correct for your network or ISP. For my setup, that is:

pi@raspberrypi ~ $sudo nano resolv.conf

Of course, you could run X11 over SSH and even VNC, but that would just take away from the power you want to give your server. Besides, servers don't need resource-wasting GUIs – the command line is a better, leaner and faster path.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy ADMIN Magazine

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Monitoring network computers with the Icinga Nagios fork
    A network monitor supports administrators by displaying a full set of critical information at a central location and alerting in case of trouble.
  • Understanding Autodiscovery

    A lack of information about your infrastructure can result in faulty system configuration and other difficulties. Automatic discovery of all hosts and services would seem to be the best solution – but can it also prove itself in practice?

  • Monitoring with collectd 4.3
    Collectd 4.3 is a comprehensive monitoring tool with a removable plugin architecture.
  • All for Admins
    Our Admin special edition was so popular we're back, with a new quarterly magazine that is all for admins. Welcome to the first issue of Admin: Network and Security – a magazine for administrators of heterogenous networks.
  • Time-series-based monitoring with Prometheus
    As Prometheus gave fire to mankind, the distributed monitoring software with the same name illuminates the admin's mind in native cloud environments, offering metrics for monitored systems and applications.
comments powered by Disqus