Icinga

2.17. Monitoring Routers and Switches

2.17.1. Introduction
2.17.2. Overview
2.17.3. Steps
2.17.4. What's Already Done For You
2.17.5. Prerequisites
2.17.6. Configuring Icinga
2.17.7. Restarting Icinga

2.17.1. Introduction

This document describes how you can monitor the status of network switches and routers. Some cheaper "unmanaged" switches and hubs don't have IP addresses and are essentially invisible on your network, so there's not any way to monitor them. More expensive switches and routers have addresses assigned to them and can be monitored by pinging them or using SNMP to query status information.

We'll describe how you can monitor the following things on managed switches, hubs, and routers:

[Note] Note

These instructions assume that you've installed Icinga according to the quickstart guide. The sample configuration entries below reference objects that are defined in the sample config files (commands.cfg, templates.cfg, etc.) that are installed when you follow the quickstart.

If you installed a package then the sample files might be missing. The contents is listed here for reference.

2.17.2. Overview

Monitoring switches and routers can either be easy or more involved - depending on what equipment you have and what you want to monitor. As they are critical infrastructure components, you'll no doubt want to monitor them in at least some basic manner.

Switches and routers can be monitored easily by "pinging" them to determine packet loss, RTA, etc. If your switch supports SNMP, you can monitor port status, etc. with the check_snmp plugin and bandwidth (if you're using MRTG) with the check_mrtgtraf plugin.

The check_snmp plugin will only get compiled and installed if you have the net-snmp and net-snmp-utils packages installed on your system. Make sure the plugin exists in /usr/local/icinga/libexec before you continue. If it doesn't, install net-snmp and net-snmp-utils and recompile/reinstall the Icinga plugins.

2.17.3. Steps

There are several steps you'll need to follow in order to monitor a new router or switch. They are:

  1. Perform first-time prerequisites

  2. Create new host and service definitions for monitoring the device

  3. Restart the Icinga daemon

2.17.4. What's Already Done For You

To make your life a bit easier, a few configuration tasks have already been done for you:

The above-mentioned config files can be found in the /usr/local/icinga/etc/objects/ directory. You can modify the definitions in these and other definitions to suit your needs better if you'd like. However, we'd recommend waiting until you're more familiar with configuring Icinga before doing so. For the time being, just follow the directions outlined below and you'll be monitoring your network routers/switches in no time.

2.17.5. Prerequisites

The first time you configure Icinga to monitor a network switch, you'll need to do a bit of extra work. Remember, you only need to do this for the *first* switch you monitor.

Edit the main Icinga config file.

#> vi /usr/local/icinga/etc/icinga.cfg

Remove the leading hash (#) sign from the following line in the main configuration file:

 #cfg_file=/usr/local/icinga/etc/objects/switch.cfg

Save the file and exit.

What did you just do? You told Icinga to look to the /usr/local/icinga/etc/objects/switch.cfg to find additional object definitions. That's where you'll be adding host and service definitions for routers and switches. That configuration file already contains some sample host, hostgroup, and service definitions. For the *first* router/switch you monitor, you can simply modify the sample host and service definitions in that file, rather than creating new ones.

2.17.6. Configuring Icinga

You'll need to create some object definitions in order to monitor a new router/switch.

Open the switch.cfg file for editing.

#> vi /usr/local/icinga/etc/objects/switch.cfg

Add a new host definition for the switch that you're going to monitor. If this is the *first* switch you're monitoring, you can simply modify the sample host definition in switch.cfg. Change the host_name, alias, and address fields to appropriate values for the switch.

 define host{
        use             generic-switch          ; Inherit default values from a template
        host_name       linksys-srw224p         ; The name we're giving to this switch
        alias           Linksys SRW224P Switch  ; A longer name associated with the switch
        address         192.168.1.253           ; IP address of the switch
        hostgroups      allhosts,switches       ; Host groups this switch is associated with
        }

Monitoring Services

Now you can add some service definitions (to the same configuration file) to monitor different aspects of the switch. If this is the *first* switch you're monitoring, you can simply modify the sample service definition in switch.cfg.

[Note] Note

Replace "linksys-srw224p" in the example definitions below with the name you specified in the host_name directive of the host definition you just added.

Save the file.

2.17.7. Restarting Icinga

Once you've added the new host and service definitions to the switch.cfg file, you're ready to start monitoring the router/switch. To do this, you'll need to verify your configuration and restart Icinga.

If the verification process produces any errors messages, fix your configuration file before continuing. Make sure that you don't (re)start Icinga until the verification process completes without any errors!