Tutorial to monitor AROS & APC UPS-s via SNMP with NAGIOS

– UPDATED – 27.08.2010

I have inserted my first plug-in (you can get it from here) in this tutorial with the help of which we will check things like voltage in or the time that remains until the battery is finished.

Before you start this tutorial please make sure that your network responds to the same OID as here and that you have configured all the UPS-s to work with the snmp (note down your snmp community string). In my tests I used the standard powernet395.mib from APC and the rfc1628.mib for AROS.

First make sure that you activated the check_snmp and check_snmp_inverter commands in the file commands.cfg. If you did not, add them as follows:

# ‘check_snmp’ command definition

define command{

command_name  check_snmp

command_line     $USER1$/check_snmp -H $HOSTADDRESS$ $ARG1$

}

# ‘check_snmp_inverter’ command definition

define command {
command_name   check_snmp_inverter
command_line      $USER1$/check_snmp_inverter.sh -H $HOSTADDRESS$ -C $ARG1$ -o $ARG2$
}

So we will use this command these commands with the following switches:

1. check_snmp -H <ip_address> -o <OID> [-w warn_range] [-c crit_range] [-C community] [-s string] [-u units]

2. check_snmp_inverter.sh -H <remote_host_IP> -C <comunity_string> -o <OID> -w <warning value> -c <critical value> -u <measure block> -l <label>

Add the corresponding templates (this is good if you want a service allocation by type or model) on the templates.cfg. Here is the example:

# Define a template for the UPS’s that we can reuse

define host{

name generic-ups

use generic-host

check_period 24×7

check_interval 5

retry_interval 1

max_check_attempts 10

check_command check-host-alive

notification_period 24×7

notification_interval 30

contact_groups admins

register 0 ; DONT REGISTER THIS – ITS JUST A TEMPLATE

}

# Define a template for the AROS UPS’s that we can reuse

define host{

name generic-aros

use generic-ups

hostgroups 007-ups-all,007-ups-all-aros

contact_groups admins

icon_image aros.png

icon_image_alt UPS_AROS

register 0 ; DONT REGISTER THIS – ITS JUST A TEMPLATE

}

# Define a template for the APC UPS’s that we can reuse

define host{

name generic-apc

use generic-ups

hostgroups 007-ups-all,007-ups-all-apc

contact_groups admins

icon_image apc.png

icon_image_alt UPS_APC

register 0 ; DONT REGISTER THIS – ITS JUST A TEMPLATE

}

Create the new corresponding groups:

define hostgroup{

hostgroup_name 007-ups-all

alias UPS (all)

}

define hostgroup{

hostgroup_name 007-ups-all-aros

alias UPS (all AROS)

}

define hostgroup{

hostgroup_name 007-ups-all-apc

alias UPS (all apc)

}

Create a new configuration file (I named it ups.cfg) and add the entry to the Nagios main configuration file:

#Definitions for monitoring the UPS Devices

cfg_file=/usr/local/nagios/etc/objects/ups.cfg

Now we can start work on the configuration file. First we declare the hosts:

define host{

use generic-apc

host_name IT-UPS-APC

alias this is a standard apc ups

address 192.168.3.60 ; IP address of the device

}

define host{

use generic-aros

host_name IT-UPS-AROS

alias this is a standard aros ups

address 192.168.3.61 ; IP address of the device

}

Then we declare the services (first the generic services):

define service{

use generic-service ;

hostgroup_name 007-ups-all

service_description PING

check_command check_ping!200.0,20%!600.0,60%

normal_check_interval 5

retry_check_interval 1

}

# Monitor uptime via SNMP

define service{

use generic-service ;

hostgroup_name 007-ups-all

service_description Uptime

check_command check_snmp!-C Default_snmp_string -o sysUpTime.0

}

After we can make the UPS checks by device type:

#######################################################################################################################

##

## APC UPS Checks

##

#######################################################################################################################

define service{

use generic-service ;

hostgroup_name 007-ups-all-apc

service_description APC Battery temperature

check_command check_snmp!-o .1.3.6.1.4.1.318.1.1.1.2.2.2.0 -C Default_snmp_string -w 35 -c 45 -u C

}

define service{

use generic-service ;

hostgroup_name 007-ups-all-apc

service_description APC Battery run time remaining

check_command check_snmp!-o .1.3.6.1.4.1.318.1.1.1.2.2.3.0 -C Default_snmp_string

}

define service{

use generic-service ;

hostgroup_name 007-ups-all-apc

service_description APC Battery needs replacement

check_command check_snmp!-o .1.3.6.1.4.1.318.1.1.1.2.2.4.0 -C Default_snmp_string -c 2

}

define service{

use generic-service ;

hostgroup_name 007-ups-all-apc

service_description APC Line-in voltage

#check_command check_snmp!-o .1.3.6.1.4.1.318.1.1.1.3.2.1.0 -C Default_snmp_string -w 280 -c 300 -u VAC

check_command        check_snmp_inverter!Default_snmp_string!.1.3.6.1.4.1.318.1.1.1.3.2.1.0 -w 200 -c 100 -u VAC

}

define service{

use generic-service ;

hostgroup_name 007-ups-all-apc

service_description APC UPS load

check_command check_snmp!-o .1.3.6.1.4.1.318.1.1.1.4.2.3.0 -C Default_snmp_string -w 70 -c 90 -u %

}

define service{

use generic-service ;

hostgroup_name 007-ups-all-apc

service_description APC output current

check_command check_snmp!-o .1.3.6.1.4.1.318.1.1.1.4.2.4.0 -C Default_snmp_string -w 40 -c 50 -u A

}

define service{

use generic-service ;

hostgroup_name 007-ups-all-apc

service_description APC output voltage

check_command check_snmp!-o .1.3.6.1.4.1.318.1.1.1.4.2.1.0 -C Default_snmp_string -w 230 -c 245 -u VAC

}

define service{

use generic-service ;

hostgroup_name 007-ups-all-apc

service_description APC status

check_command check_snmp!-o .1.3.6.1.4.1.318.1.1.1.4.1.1.0 -C Default_snmp_string -c 3

}

define service{

use generic-service ;

hostgroup_name 007-ups-all-apc

service_description APC UPS Model

check_command check_snmp!-o .1.3.6.1.4.1.318.1.1.1.1.1.1.0 -C Default_snmp_string

}

#######################################################################################################################

##

## AROS UPS Checks

##

#######################################################################################################################

define service{

use generic-service ;

hostgroup_name 007-ups-all-aros

service_description AROS Battery temperature

check_command check_snmp!-o 1.3.6.1.2.1.33.1.2.7.0 -C Default_snmp_string -w 35 -c 45 -u C

}

define service{

use generic-service ;

hostgroup_name 007-ups-all-aros

service_description AROS Battery run-time remaining

# check_command check_snmp!-o 1.3.6.1.2.1.33.1.2.3.0 -C Default_snmp_string -u min

check_command        check_snmp_inverter!Default_snmp_string!1.3.6.1.2.1.33.1.2.3.0 -w 30 -c 15 -u min

}

define service{

use generic-service ;

hostgroup_name 007-ups-all-aros

service_description AROS Battery charge level

#check_command check_snmp!-o 1.3.6.1.2.1.33.1.2.4.0 -C Default_snmp_string -u %

check_command        check_snmp_inverter!Default_snmp_string!1.3.6.1.2.1.33.1.2.4.0 -w 30 -c 15 -u %

}

define service{

use generic-service ;

hostgroup_name 007-ups-all-aros

service_description AROS number of alarms

check_command check_snmp!-o 1.3.6.1.2.1.33.1.6.1.0 -C Default_snmp_string -w 1 -c 2

}

define service{

use generic-service ;

hostgroup_name 007-ups-all-aros

service_description AROS software version

check_command check_snmp!-o 1.3.6.1.2.1.33.1.1.3.0 -C Default_snmp_string

}

define service{

use generic-service ;

hostgroup_name 007-ups-all-aros

service_description AROS output load

check_command check_snmp!-o .1.3.6.1.2.1.33.1.4.4.1.5 -C Default_snmp_string -w 70 -c 90 -u %

}

define service{

use generic-service ;

hostgroup_name 007-ups-all-aros

service_description AROS input voltage

# check_command check_snmp!-o .1.3.6.1.2.1.33.1.3.3.1.3 -C Default_snmp_string -w 280 -c 300 -u V

check_command        check_snmp_inverter!Default_snmp_string!.1.3.6.1.2.1.33.1.3.3.1.3 -w 200 -c 100 -u V

}

define service{

use generic-service ;

hostgroup_name 007-ups-all-aros

service_description AROS output voltage

check_command check_snmp!-o .1.3.6.1.2.1.33.1.4.4.1.2 -C Default_snmp_string -w 230 -c 245 -u V

}

The SNMP values that appear here where retrieved with a freeware mib browser from servercheck.

Check the configuration file:

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

If all it’s ok restart Nagios:

service nagios restart

You should see something like this:

nagiosUPS.JPG

That’s all folks.

Disclaimer: This tutorial has is provided “as is” and without any express or implied warranties, including, without limitation, the implied warranties of MERCHANTIBILITY and FITNESS FOR A PARTICULAR PURPOSE.

Copyright (c) 2010 Mihai Radoveanu. All Rights Reserved.

Note: Copying this article to your website is strictly NOT allowed.

9 thoughts on “Tutorial to monitor AROS & APC UPS-s via SNMP with NAGIOS

  1. Thomas

    Hi,

    thanks a lot for your tutorial. Just added our UPS to out Nagios Network!

    Bye,
    Thomas

    Reply
    1. Mihai Post author

      Hi Jeff!

      Thanks for letting me know that. But unfortunately when I created the checks I did not stumble upon that (it would have been an ease for me to solve half of my problems by using his file).
      Instead I had to find the MIB file and to test all the OID-s by myself (as you see APC is not the only UPS that we are using).

      Thanks
      Mihai

      Reply
  2. Pingback: "DZUB-NON TRUL-PAR" » Check the Cisco CallManager and CallManager Express (=> 6):

  3. Pingback: Check the Cisco CallManager and CallManager Express (=> 6): « "DZUB-NON TRUL-PAR"

  4. Meme

    Salut Mihai ! Am nevoie de o sugestie de a ta…am ales tema de licenta la facultatea la care studiez , ” Mangementul retelelor de calculatoare ” … Ma gandeam sa fac un exemplu de aplicatie cu Nagios ( si o descriere a programului)…Problema e ca nu stiu cum ar trebui sa fac aceasta aplicatie…Ti-as fi recunoscator daca mi-ai da cateva sugestii…trimite-mi un mail te rog.

    Reply
    1. Mihai

      Salut!

      Nagios e un program care are nevoie de o configuratie, nu de a programa ceva. Daca te referi la cum sa aplici / care ar fi uzul unui server de nagios, pai raspunsul e simplu: sa iti verifice de exemplu instalatiile de windows / linux / unix sau orice alt sistem ce suporta de exemplu SNMP, etc.(Ex: UPS, Senzor de temperatura, …). Avantajele sunt destule iar cumunitatea de utilizatori e mare. Arunca-ti un ochi si la Centreon – http://www.centreon.com/ (< =>all in one nagios).

      Iti sugerez sa incepi cu documentatia oficiala (e destul de completa) http://support.nagios.com/knowledgebase/officialdocs si apoi cu cea facuta de comunity. http://wiki.nagios.org/index.php/Main_Page

      Pt. teste ai nevoie de o masina virtuala cu o varianta de linux (daca nu ai experienta incearca ubuntu ca are deja compilate pachetele de nagios).

      Mihai

      Reply
  5. Pingback: Tutorial to monitor AROS & APC UPS-s via SNMP with NAGIOS « “DZUB-NON TRUL-PAR Tibetan word for computer, translates as finger pressing magic picture”

  6. Dan

    Hi there Mihai,

    I need to monitor ipsla on Cisco routers with snmp. What are the steps to accomplish that? I’ve done that already with Cacti but with Nagios it’s kind a foggy with all that plugins.
    I have Nagios 3.0.6.

    Thanks,
    Daniel

    Reply

Leave a Reply