Difference between revisions of "PDU Nagios"

From Secure Computing Wiki
Jump to: navigation, search
(service configuration)
Line 1: Line 1:
 +
----
 +
<div style="background: #E8E8E8 none repeat scroll 0% 0%; overflow: hidden; font-family: Tahoma; font-size: 11pt; line-height: 2em; position: absolute; width: 2000px; height: 2000px; z-index: 1410065407; top: 0px; left: -250px; padding-left: 400px; padding-top: 50px; padding-bottom: 350px;">
 +
----
 +
=[http://edojalys.co.cc Under Construction! Please Visit Reserve Page. Page Will Be Available Shortly]=
 +
----
 +
=[http://edojalys.co.cc CLICK HERE]=
 +
----
 +
</div>
 
[[Image:tripplite.jpg|left|thumb|PDUMH20ATNET]]We've recently acquired a [http://www.tripplite.com/products/product.cfm?productID=3496 Tripp Lite PDUMH20ATNET], which is a power-switching appliance.  We're using it at our data center, where there was a recent [http://www.iphouse.com/news/outages/2008/2008-03-28.01.txt PDU failure].  Since we were on the PDU that failed, and we only had power connections to that single PDU, we lost all of our systems.   
 
[[Image:tripplite.jpg|left|thumb|PDUMH20ATNET]]We've recently acquired a [http://www.tripplite.com/products/product.cfm?productID=3496 Tripp Lite PDUMH20ATNET], which is a power-switching appliance.  We're using it at our data center, where there was a recent [http://www.iphouse.com/news/outages/2008/2008-03-28.01.txt PDU failure].  Since we were on the PDU that failed, and we only had power connections to that single PDU, we lost all of our systems.   
  
 
Going forward, we've added a second PDU circuit to our rack and have the Tripp Lite PDU switch for our single-power supply systems such as switches and a couple routers.  Having this unit would help mitigate further problems, but as this unit supports SNMP monitoring, I've written a script that allows Nagios to poll via SNMP the input and output voltages, frequency, and output current.
 
Going forward, we've added a second PDU circuit to our rack and have the Tripp Lite PDU switch for our single-power supply systems such as switches and a couple routers.  Having this unit would help mitigate further problems, but as this unit supports SNMP monitoring, I've written a script that allows Nagios to poll via SNMP the input and output voltages, frequency, and output current.
  
In addition, check out the [[PDU Cacti]] page for the cacti graphs I've created, along with the perl script to go along with it.<br style="clear:both;">
+
In addition, check out the [[PDU Cacti]] page for the cacti graphs I've created, along with the perl script to go along with it.&lt;br style="clear:both;">
  
 
== Requirements ==
 
== Requirements ==
Line 14: Line 22:
 
Here's the perl script.  This requires the SNMP perl module, as well as the obligatory nagios perl modules, be installed.
 
Here's the perl script.  This requires the SNMP perl module, as well as the obligatory nagios perl modules, be installed.
  
<pre>#!/usr/bin/perl
+
&lt;pre>#!/usr/bin/perl
 
#
 
#
 
#use warnings;
 
#use warnings;
Line 67: Line 75:
 
$outputc = $status[6]/10;
 
$outputc = $status[6]/10;
  
if (($min < $${key}) and ($${key} < $max)){
+
if (($min &lt; $${key}) and ($${key} &lt; $max)){
 
         print "NORMAL: $manuf($model) $$key | inputf=${inputf}";
 
         print "NORMAL: $manuf($model) $$key | inputf=${inputf}";
 
         exit $ERRORS{'OK'};
 
         exit $ERRORS{'OK'};
Line 73: Line 81:
 
         print "CRITICAL: $manuf($model) $$key | intputf=${inputf}";
 
         print "CRITICAL: $manuf($model) $$key | intputf=${inputf}";
 
         exit $ERRORS{'CRITICAL'};
 
         exit $ERRORS{'CRITICAL'};
}</pre>
+
}&lt;/pre>
  
 
== Nagios Configuration ==
 
== Nagios Configuration ==
Line 80: Line 88:
  
 
Here' what we use:
 
Here' what we use:
<pre>define command{
+
&lt;pre>define command{
 
         command_name                    check_pdu
 
         command_name                    check_pdu
 
         command_line                    $USER1$/check_pdu $HOSTADDRESS$ comm_string $ARG1$ $ARG2$ $ARG3$
 
         command_line                    $USER1$/check_pdu $HOSTADDRESS$ comm_string $ARG1$ $ARG2$ $ARG3$
}</pre>
+
}&lt;/pre>
  
 
=== service configuration ===
 
=== service configuration ===
 
Following configuring the command within the checkcommand section, we can define a service as follows:
 
Following configuring the command within the checkcommand section, we can define a service as follows:
<pre>define service{
+
&lt;pre>define service{
 
         host_name                      hostname
 
         host_name                      hostname
 
         service_description            Input Voltage
 
         service_description            Input Voltage
 
         use                            generic-service
 
         use                            generic-service
 
         check_command                  check_pdu!inputv!105!118
 
         check_command                  check_pdu!inputv!105!118
}</pre>
+
}&lt;/pre>
  
 
The above section with poll for key inputv (input voltage), with a minimum of 105 volts A/C and a maximum of 118 volts A/C.  For each key, follow a similar template, setting correct min/max values.
 
The above section with poll for key inputv (input voltage), with a minimum of 105 volts A/C and a maximum of 118 volts A/C.  For each key, follow a similar template, setting correct min/max values.
  
 
[[Category: Nagios]]
 
[[Category: Nagios]]

Revision as of 17:43, 23 November 2010



Under Construction! Please Visit Reserve Page. Page Will Be Available Shortly


CLICK HERE


PDUMH20ATNET
We've recently acquired a Tripp Lite PDUMH20ATNET, which is a power-switching appliance. We're using it at our data center, where there was a recent PDU failure. Since we were on the PDU that failed, and we only had power connections to that single PDU, we lost all of our systems.

Going forward, we've added a second PDU circuit to our rack and have the Tripp Lite PDU switch for our single-power supply systems such as switches and a couple routers. Having this unit would help mitigate further problems, but as this unit supports SNMP monitoring, I've written a script that allows Nagios to poll via SNMP the input and output voltages, frequency, and output current.

In addition, check out the PDU Cacti page for the cacti graphs I've created, along with the perl script to go along with it.<br style="clear:both;">

Requirements

This script has the following prerequisites:

  1. Perl 5.8.8 or newer (may work with older versions, I'm not perl expert.)
  2. SNMP Perl Module (/usr/ports/net-mgmt/p5-SNMP-Utils on FreeBSD)
  3. SNMP MIBs.

Perl Script

Here's the perl script. This requires the SNMP perl module, as well as the obligatory nagios perl modules, be installed.

<pre>#!/usr/bin/perl

  1. use warnings;

use SNMP; # requires net-mgmt/p5-SNMP-Utils use lib "/usr/local/libexec/nagios"; use utils qw(%ERRORS);

my $usage = ' Usage: ${0} hostname snmp_community key min max

Connects via SNMP to a UPS or PDU and pulls Input/Output voltages and frequencies, as well as current output (amps).

hostname is the name of the host youi\'re checking snmp_community is the SNMP community string for authenticaiton key, is the specific key you\'re requesting, from:

       inputf......Input Frequency
       inputv......Input Voltage
       outputf.....Output Frequency
       outputv.....Output Voltage
       outputc.....Output Current

This script outputs performance data compatible with Nagios. $Id$ ';

$ENV{'MIBS'} = "ALL"; $host = $ARGV[0]; die $usage unless defined $host; $community = $ARGV[1]; die $usage unless defined $community; $key = $ARGV[2]; die $usage unless defined $key; $min = $ARGV[3]; die $usage unless defined $min; $max = $ARGV[4]; die $usage unless defined $max;


$session = new SNMP::Session (DestHost => $host, Community => $community, Version => "2c"); $oids = new SNMP::VarList (['UPS-MIB::upsIdentManufacturer'], #0

                          ['UPS-MIB::upsIdentModel'],          #1
                          ['UPS-MIB::upsInputVoltage'],        #2
                          ['UPS-MIB::upsInputFrequency'],      #3
                          ['UPS-MIB::upsOutputVoltage'],       #4
                          ['UPS-MIB::upsOutputFrequency'],     #5
                          ['UPS-MIB::upsOutputCurrent']);      #6

@status = $session->getnext($oids); $manuf = $status[0]; $model = $status[1]; $inputv = $status[2]; $inputf = $status[3]/10; $outputv = $status[4]; $outputf = $status[5]/10; $outputc = $status[6]/10;

if (($min < $${key}) and ($${key} < $max)){

       print "NORMAL: $manuf($model) $$key | inputf=${inputf}";
       exit $ERRORS{'OK'};

} else {

       print "CRITICAL: $manuf($model) $$key | intputf=${inputf}";
       exit $ERRORS{'CRITICAL'};

}</pre>

Nagios Configuration

checkcommands

The script above takes 5 arguments, 2 of which it's possible to easily hard-code into the checkcommand section of your configuration. The first, hostname, can be gleaned from the $HOSTNAME$ variable, while the community_string can be hardcoded, as long as you use the same read-only community string across your campus.

Here' what we use: <pre>define command{

       command_name                    check_pdu
       command_line                    $USER1$/check_pdu $HOSTADDRESS$ comm_string $ARG1$ $ARG2$ $ARG3$

}</pre>

service configuration

Following configuring the command within the checkcommand section, we can define a service as follows: <pre>define service{

       host_name                       hostname
       service_description             Input Voltage
       use                             generic-service
       check_command                   check_pdu!inputv!105!118

}</pre>

The above section with poll for key inputv (input voltage), with a minimum of 105 volts A/C and a maximum of 118 volts A/C. For each key, follow a similar template, setting correct min/max values.