# Icinga2 Cisco

Icinga 2, Check Cisco Switch with Centreon

Updated. 6.11.2016

We are going to install the centreon plugins and use it to check several cisco switchs.
You can find alot of informations about the plugins here
I assume you are familiar with the cisco commands. If not, check out my cisco helper


Plugin Installation
  1. Create a folder to store the plugin
    mkdir /usr/lib/nagios/plugins/thirdparty cd /usr/lib/nagios/plugins/thirdparty

  2. Let's clone the plugins
    git clone https://github.com/centreon/centreon-plugins.git

  3. We need to install another piece of software
    aptitude install perl libsnmp-perl

List available Plugins & Functions

There are alot of plugins included, separated in different categories.
os apps storage hardware snmp_standard network cloud database

There are many plugins available, let's list them all.
perl centreon_plugins.pl --list-plugin

Damn...they have a lot of plugins. We can filter to list all the cisco plugins. This is gonna make the list a little bit more clearer.
perl centreon_plugins.pl --list-plugin | grep 'PLUGIN: network::cisco'

It's interesting to know what we can do with this plugin
perl centreon_plugins.pl --plugin=network::cisco::standard::snmp::plugin --list-mode

This modes are later used when we create our icinga commands.


Enable Snmp

We will activate Snmpv1/v2. Be aware that Snmpv1/v2 is not very secure.
Snmpv3 would address this issue. There is more config needed for Snmpv3. I will cover it in on of my next blog posts.

Log in to your switch, change to the config mode

Enables snmp, Read-Only
snmp-server community MYCOMMUNITYCODE RO
Enables snmp, Read-Write
snmp-server community MYCOMMUNITYCODE RW
The Community Code is the name/password we will use to access the switch. Set a random name.


We are ready to switch to the the icinga environment.


First I created a new conf file for all cisco commands. You can store it wherever you want.

object CheckCommand "check-cisco" {
        import "plugin-check-command"
        command = [ PluginDir + "/thirdparty/centreon-plugins/centreon_plugins.pl" ]

        arguments = {
                "--plugin" ="network::cisco::standard::snmp::plugin"
                "--mode" = "$mode$"
                "--host" = "$address$"
                "--snmp-community" = "MYCOMMUNITYCODE"

We keep this command generic. We will pass the mode variable later in the service section. The address will be set from the host entry.


We have to define a service, where we can use the check-cisco command

apply Service "cisco-memory"{
  import "generic-service"
  check_command = "check-cisco"
  vars.mode = "memory"
  assign where host.vars.type == "switch"

This is an example for a service to check the memory.


I created a new subfolder to organize my different host types

object Host "mySwitch" {
  import "generic-host"
  address = "x.x.x.x"
  vars.type ="switch"
  display_name = "mySwitch"

Simple Host config file. I created the type "switch". The Service cisco-memory will be applied automatically to this host.

Eh voila. The host is listed and the memory usage is shown
Memory usage


Permission denied

The permissions are missing to run the script. x stands for execute bye the way.
Missing Permissions
I allow the execute for all users. Choose the appropriate permissions for your environment.

chmod 755 centreon_plugins.pl

Need write permissions

This is actually documented on the centreon webpage.

Nice. So let's do this.

mkdir /usr/lib/centreon/centplugins -p

And change the owner.

chown -R nagios:nagios centreon 
Icinga2, Upgrade failed
Cisco helper

Share it

Written by

Martin Schmidli

Welcome! This page is all about my journey in the IT World. I love automation and everything that makes my customer's life easier.