Friday, November 4, 2011

Using check_dell_bladechassis with check_mk

This post builds off of a previous post that documented getting check_openmanage working with check_mk.

In this post we'll add check_dell_bladechassis to the mix to allow for monitoring of Dell M1000e blade chassis' (via the CMC management card).

This was done on the following system:
Unless otherwise specified all paths are relative to the site owners home (ex: /opt/omd/sites/mysite) The check_openmanage code in this blog post is not necessary to get check_dell_bladechassis, I'm just including it to help tie this entry to the previous post.
  1. Change users on your OMD server to the site user: $ su - mysite
  2. Download the latest check_dell_bladechassis from http://folk.uio.no/trondham/software/check_dell_bladechassis.html to ~/tmp and extract
  3. copy the check_dell_bladechassis script to local/lib/nagios/plugins (this defaults to $USER2$ in your commands)
    
    $ cp tmp/check_dell_bladechassis-1.0.0/check_dell_bladechassis local/lib/nagios/plugins/
    $ chmod +x local/lib/nagios/plugins/check_dell_bladechassis
    
  4. copy the PNP4Nagios template
    
    $ cp tmp/check_dell_bladechassis-1.0.0/check_dell_bladechassis.php etc/pnp4nagios/templates/
    
  5. Test check_dell_bladechassis to see that it can successfully query an M1000e CMC (I've inserted carriage returns in the output to make it more readable)
    
    local/lib/nagios/plugins/check_dell_bladechassis -H dell-m1000e-01 -p -C MySecretCommunity
    
    OK - System: 'PowerEdge M1000e', SN: 'XXXXXX', Firmware: '3.03', hardware working fine|
    'total_watt'=1500.000W;0;7928.000 'total_amp'=6.750A;0;0 'volt_ps1'=239.500V;0;0 
    'volt_ps2'=242.750V;0;0 'volt_ps3'=242.750V;0;0 'volt_ps4'=241.750V;0;0 'volt_ps5'=241.750V;0;0 
    'volt_ps6'=242.750V;0;0 'amp_ps1'=1.688A;0;0 'amp_ps2'=1.641A;0;0 'amp_ps3'=0.188A;0;0 
    'amp_ps4'=1.516A;0;0 'amp_ps5'=1.500A;0;0 'amp_ps6'=0.219A;0;0
    
    
  6. Edit the main.mk file to define the command, etc... (the perfdata_format and monitoring_host I got from a previous emailer to the list, not sure if they are needed)
    
    all_hosts = [
     'dell-m1000e-01|snmp|m1000e|nonpub',
     'dell-r710-01|linsrv|kvm|omsa|nonpub',
     'dell-2950-01|linsrv|omsa|nonpub',
     'hp-srv-01|winsrv|smb', ]
    
    # Are you using PNP4Nagios and MRPE checks? This will make PNP
    # choose the correct template for standard Nagios checks:
    perfdata_format = "pnp"
    #set the monitoring host
    monitoring_host = "nagios"
    
    # SNMP Community
    snmp_default_community = "someCommunityRO"
    
    snmp_communities = [
      ( "MySecretCommunity", ["nonpub"], ALL_HOSTS ),
    ]
    
    extra_nagios_conf += r"""
    
    # ARG1: community string
    define command {
        command_name    check_openmanage
        command_line    $USER2$/check_openmanage -H $HOSTADDRESS$ -p -C $ARG1$
    }
    
    define command {
        command_name    check_dell_bladechassis
        command_line    $USER2$/check_dell_bladechassis -H $HOSTADDRESS$ -p -C $ARG1$
    }
    
    """
    
    legacy_checks = [
      # On all hosts with the tag 'omsa' check Dell OpenManage for status 
      # service description "Dell OMSA", process performance data
      ( ( "check_openmanage!MySecretCommunity", "Dell OMSA", True), [ "omsa" ], ALL_HOSTS ),
      # similar for m1000e
      ( ( "check_dell_bladechassis!MySecretCommunity", "Dell Blade Chassis", True), [ "m1000e" ], ALL_HOSTS ),
    
    ]
    
    
  7. That should be it, reinventory your M1000e and reload
    
    $ check_mk -II dell-m1000e-01
    $ check_mk -O
    
    
  8. The php code has a bug that can be fixed using the below patch (see the first comment for details)
    
    --- a/check_dell_bladechassis.php 2009-08-04 07:00:15.000000000 -0500
    +++ b/check_dell_bladechassis.php 2011-12-21 14:44:25.488132187 -0600
    @@ -41,7 +41,7 @@
      
      $opt[$count] = "--slope-mode --vertical-label \"$vlabel\" --title \"$def_title: $title\" ";
      
    -        $def[$count] .= "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ;
    +        $def[$count] = "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ;
             $def[$count] .= "AREA:var$i#$PWRcolor:\"$NAME[$i]\" " ;
             $def[$count] .= "LINE:var$i#000000: " ;
     
    @@ -62,7 +62,7 @@
      
      $opt[$count] = "-X0 --lower-limit 0 --slope-mode --vertical-label \"$vlabel\" --title \"$def_title: $title\" ";
      
    -        $def[$count] .= "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ;
    +        $def[$count] = "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ;
             $def[$count] .= "AREA:var$i#$AMPcolor:\"$NAME[$i]\" " ;
             $def[$count] .= "LINE:var$i#000000: " ;
     
    @@ -75,6 +75,7 @@
         if(preg_match('/^volt_/',$NAME[$i])){
      if ($visited_volt == 0) {
          ++$count;
    +     $def[$count] = '';
          $visited_volt = 1;
      }
      
    @@ -87,6 +88,7 @@
      
      $def[$count] .= "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ;
      $def[$count] .= "LINE:var$i#".$colors[$v++].":\"$NAME[$i]\" " ;
    +
      $def[$count] .= "GPRINT:var$i:LAST:\"%3.2lf $UNIT[$i] last \" ";
      $def[$count] .= "GPRINT:var$i:MAX:\"%3.2lf $UNIT[$i] max \" ";
      $def[$count] .= "GPRINT:var$i:AVERAGE:\"%3.2lf $UNIT[$i] avg \\n\" ";
    @@ -96,6 +98,7 @@
         if(preg_match('/^amp_/',$NAME[$i])){
      if ($visited_amp == 0) {
          ++$count;
    +     $def[$count] = '';
          $visited_amp = 1;
      }
     
    

Hope this helps, and comments are welcome.

6 comments:

Unknown said...

The 1.0.0 check_dell_bladechassis.php file produces an error with OMD 0.50 provided PNP4Nagios 0.6.15:

===================================================================================
PNP4Nagios Version 0.6.15
Please check the documentation for information about the following error.

Undefined offset: 1
file [line]:

/opt/omd/sites/mysite/etc/pnp4nagios/templates/check_dell_bladechassis.php [44]:
===================================================================================

Multisite shows that the check_dell_bladechassis plugin is correctly gathering the data:
===================================================================================
'total_watt'=1464.000W;0;7928.000 'total_amp'=6.609A;0;0 'volt_ps1'=240.500V;0;0 'volt_ps2'=241.750V;0;0 'volt_ps3'=242.750V;0;0 'volt_ps4'=240.500V;0;0 'volt_ps5'=241.750V;0;0 'volt_ps6'=241.750V;0;0 'amp_ps1'=1.688A;0;0 'amp_ps2'=1.562A;0;0 'amp_ps3'=0.188A;0;0 'amp_ps4'=1.516A;0;0 'amp_ps5'=1.438A;0;0 'amp_ps6'=0.219A;0;0
===================================================================================

The following patch fixed the issue (added the patch to the blog entry since comments don't allow for proper formatting):

$ git diff etc/pnp4nagios/templates/check_dell_bladechassis.php

===================================================================================
diff --git a/etc/pnp4nagios/templates/check_dell_bladechassis.php b/etc/pnp4nagios/templates/check_dell_bladechassis.php
index 6836d38..0bc3b65 100644
--- a/etc/pnp4nagios/templates/check_dell_bladechassis.php
+++ b/etc/pnp4nagios/templates/check_dell_bladechassis.php
@@ -41,6 +41,7 @@ foreach ($DS as $i) {

$opt[$count] = "--slope-mode --vertical-label \"$vlabel\" --title \"$def_title: $title\" ";

+ $def[$count] = '';
$def[$count] .= "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ;
$def[$count] .= "AREA:var$i#$PWRcolor:\"$NAME[$i]\" " ;
$def[$count] .= "LINE:var$i#000000: " ;
@@ -62,6 +63,7 @@ foreach ($DS as $i) {

$opt[$count] = "-X0 --lower-limit 0 --slope-mode --vertical-label \"$vlabel\" --title \"$def_title: $title\" ";

+ $def[$count] = '';
$def[$count] .= "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ;
$def[$count] .= "AREA:var$i#$AMPcolor:\"$NAME[$i]\" " ;
$def[$count] .= "LINE:var$i#000000: " ;
@@ -85,6 +87,7 @@ foreach ($DS as $i) {

$opt[$count] = "-X0 --slope-mode --vertical-label \"$vlabel\" --title \"$def_title: Power Supply Voltage\" ";

+ $def[$count] = '';
$def[$count] .= "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ;
$def[$count] .= "LINE:var$i#".$colors[$v++].":\"$NAME[$i]\" " ;
$def[$count] .= "GPRINT:var$i:LAST:\"%3.2lf $UNIT[$i] last \" ";
@@ -106,6 +109,7 @@ foreach ($DS as $i) {

$opt[$count] = "--slope-mode --vertical-label \"$vlabel\" --title \"$def_title: Power Supply Amperage\" ";

+ $def[$count] = '';
$def[$count] .= "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ;
$def[$count] .= "LINE:var$i#".$colors[$a++].":\"$NAME[$i]\" " ;

===================================================================================

Unknown said...

Ok, forget the patch listed in my previous comment. It has it's own bug that results in only one power supply displaying on the "PS Voltage" and "PS Amperage" graphs.

I've updated the main body of this blog entry with the following new patch:

--- a/check_dell_bladechassis.php 2009-08-04 07:00:15.000000000 -0500
+++ b/check_dell_bladechassis.php 2011-12-21 14:44:25.488132187 -0600
@@ -41,7 +41,7 @@

$opt[$count] = "--slope-mode --vertical-label \"$vlabel\" --title \"$def_title: $title\" ";

- $def[$count] .= "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ;
+ $def[$count] = "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ;
$def[$count] .= "AREA:var$i#$PWRcolor:\"$NAME[$i]\" " ;
$def[$count] .= "LINE:var$i#000000: " ;

@@ -62,7 +62,7 @@

$opt[$count] = "-X0 --lower-limit 0 --slope-mode --vertical-label \"$vlabel\" --title \"$def_title: $title\" ";

- $def[$count] .= "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ;
+ $def[$count] = "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ;
$def[$count] .= "AREA:var$i#$AMPcolor:\"$NAME[$i]\" " ;
$def[$count] .= "LINE:var$i#000000: " ;

@@ -75,6 +75,7 @@
if(preg_match('/^volt_/',$NAME[$i])){
if ($visited_volt == 0) {
++$count;
+ $def[$count] = '';
$visited_volt = 1;
}

@@ -87,6 +88,7 @@

$def[$count] .= "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ;
$def[$count] .= "LINE:var$i#".$colors[$v++].":\"$NAME[$i]\" " ;
+
$def[$count] .= "GPRINT:var$i:LAST:\"%3.2lf $UNIT[$i] last \" ";
$def[$count] .= "GPRINT:var$i:MAX:\"%3.2lf $UNIT[$i] max \" ";
$def[$count] .= "GPRINT:var$i:AVERAGE:\"%3.2lf $UNIT[$i] avg \\n\" ";
@@ -96,6 +98,7 @@
if(preg_match('/^amp_/',$NAME[$i])){
if ($visited_amp == 0) {
++$count;
+ $def[$count] = '';
$visited_amp = 1;
}

Unknown said...
This comment has been removed by the author.
Unknown said...
This comment has been removed by the author.
Unknown said...

Hello,

Fix that goes wrong the graphics, change the line:

"foreach ($DS as $i) {"

for

"foreach ($DS as $i => $VAL) {"

and change all the

"rrdfile"

for

"RRDFILE[$i]"


bye!

gibsonherry said...

Truly a fine approach to express and looking an exceptionally charming article with loaded with solid data. I am unquestionably going to enlighten in my class concerning this stage and the data shared here. Extremely elegantly composed.

Dell WinServ 2012 R2 Foundation