[prev in list] [next in list] [prev in thread] [next in thread] 

List:       nagios-users
Subject:    [Nagios-users] check_dell_bladechassis 1.0.0 PHP bug fix
From:       Mike Hanby <mhanby () uab ! edu>
Date:       2011-12-21 20:50:18
Message-ID: FB27F259B945A440951D7BA3EDBE18A30E37BD () UABEXMB1 ! ad ! uab ! edu
[Download RAW message or body]

Howdy,

I fixed an issue we had with check_dell_bladechassis.php on our OMD 5.x servers \
(PNP4Nagios Version 0.6.16) \
http://folk.uio.no/trondham/software/check_dell_bladechassis.html

The problem had to do with attempting to concat a variable (array element) that \
didn't yet exist, resulting in the following error when viewing the graphs in \
PNP4Nagios: ==================================================
PNP4Nagios Version 0.6.16
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]:
==================================================

The following patch fixes the issue on our systems.

--- 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;
     }


[Attachment #3 (text/html)]

<html xmlns:v="urn:schemas-microsoft-com:vml" \
xmlns:o="urn:schemas-microsoft-com:office:office" \
xmlns:w="urn:schemas-microsoft-com:office:word" \
xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" \
xmlns="http://www.w3.org/TR/REC-html40"> <head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-priority:99;
	color:purple;
	text-decoration:underline;}
span.EmailStyle17
	{mso-style-type:personal-compose;
	font-family:"Courier New";
	color:windowtext;}
.MsoChpDefault
	{mso-style-type:export-only;}
@page WordSection1
	{size:8.5in 11.0in;
	margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
	{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Courier \
New&quot;">Howdy,<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Courier \
New&quot;"><o:p>&nbsp;</o:p></span></p> <p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Courier New&quot;">I fixed an issue we had \
with check_dell_bladechassis.php on our OMD 5.x servers (PNP4Nagios Version \
0.6.16)<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Courier \
New&quot;">http://folk.uio.no/trondham/software/check_dell_bladechassis.html<o:p></o:p></span></p>
 <p class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Courier \
New&quot;"><o:p>&nbsp;</o:p></span></p> <p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Courier New&quot;">The problem had to do \
with attempting to concat a variable (array element) that didn't yet exist, resulting \
in the following error when viewing the graphs in PNP4Nagios:<o:p></o:p></span></p> \
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Courier \
New&quot;">==================================================<o:p></o:p></span></p> \
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Courier \
New&quot;">PNP4Nagios Version 0.6.16<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Courier New&quot;">Please check the \
documentation for information about the following error.<o:p></o:p></span></p> <p \
class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Courier \
New&quot;"><o:p>&nbsp;</o:p></span></p> <p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Courier New&quot;">Undefined offset: \
1<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Courier New&quot;">file \
[line]:<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Courier \
New&quot;"><o:p>&nbsp;</o:p></span></p> <p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Courier \
New&quot;">/opt/omd/sites/mysite/etc/pnp4nagios/templates/check_dell_bladechassis.php \
[44]:<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Courier \
New&quot;">==================================================<o:p></o:p></span></p> \
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Courier \
New&quot;"><o:p>&nbsp;</o:p></span></p> <p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Courier New&quot;">The following patch \
fixes the issue on our systems.<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Courier \
New&quot;"><o:p>&nbsp;</o:p></span></p> <p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Courier New&quot;">--- \
a/check_dell_bladechassis.php&nbsp;&nbsp; 2009-08-04 07:00:15.000000000 \
-0500<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Courier New&quot;">&#43;&#43;&#43; \
b/check_dell_bladechassis.php&nbsp;&nbsp; 2011-12-21 14:44:25.488132187 \
-0600<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Courier New&quot;">@@ -41,7 &#43;41,7 \
@@<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Courier New&quot;">&nbsp; <o:p> \
</o:p></span></p> <p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Courier \
New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $opt[$count] = &quot;--slope-mode \
--vertical-label \&quot;$vlabel\&quot; --title \&quot;$def_title: $title\&quot; \
&quot;;<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Courier New&quot;">&nbsp; <o:p> \
</o:p></span></p> <p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Courier \
New&quot;">-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $def[$count] .= \
&quot;DEF:var$i=$rrdfile:$DS[$i]:AVERAGE &quot; ;<o:p></o:p></span></p> <p \
class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Courier \
New&quot;">&#43;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $def[$count] = \
&quot;DEF:var$i=$rrdfile:$DS[$i]:AVERAGE &quot; ;<o:p></o:p></span></p> <p \
class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Courier \
New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $def[$count] .= \
&quot;AREA:var$i#$PWRcolor:\&quot;$NAME[$i]\&quot; &quot; ;<o:p></o:p></span></p> <p \
class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Courier \
New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $def[$count] .= \
&quot;LINE:var$i#000000: &quot; ;<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Courier New&quot;"><o:p></o:p></span></p> \
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Courier \
New&quot;">@@ -62,7 &#43;62,7 @@<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Courier New&quot;">&nbsp; <o:p> \
</o:p></span></p> <p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Courier \
New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $opt[$count] = &quot;-X0 --lower-limit 0 \
--slope-mode --vertical-label \&quot;$vlabel\&quot; --title \&quot;$def_title: \
$title\&quot; &quot;;<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Courier New&quot;">&nbsp; <o:p> \
</o:p></span></p> <p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Courier \
New&quot;">-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $def[$count] .= \
&quot;DEF:var$i=$rrdfile:$DS[$i]:AVERAGE &quot; ;<o:p></o:p></span></p> <p \
class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Courier \
New&quot;">&#43;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $def[$count] = \
&quot;DEF:var$i=$rrdfile:$DS[$i]:AVERAGE &quot; ;<o:p></o:p></span></p> <p \
class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Courier \
New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $def[$count] .= \
&quot;AREA:var$i#$AMPcolor:\&quot;$NAME[$i]\&quot; &quot; ;<o:p></o:p></span></p> <p \
class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Courier \
New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $def[$count] .= \
&quot;LINE:var$i#000000: &quot; ;<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Courier New&quot;"><o:p></o:p></span></p> \
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Courier \
New&quot;">@@ -75,6 &#43;75,7 @@<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp; \
if(preg_match('/^volt_/',$NAME[$i])){<o:p></o:p></span></p> <p \
class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Courier \
New&quot;">&nbsp;&nbsp;&nbsp;&nbsp; if ($visited_volt == 0) {<o:p></o:p></span></p> \
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Courier \
New&quot;">&nbsp;&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp;&nbsp;&#43;&#43;$count;<o:p></o:p></span></p> <p \
class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Courier \
New&quot;">&#43;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $def[$count] = \
'';<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp;&nbsp;$visited_volt = 1;<o:p></o:p></span></p> <p \
class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Courier \
New&quot;">&nbsp;&nbsp;&nbsp;&nbsp; }<o:p></o:p></span></p> <p \
class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Courier \
New&quot;">&nbsp;&nbsp;&nbsp;&nbsp; <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Courier \
New&quot;">@@ -87,6 &#43;88,7 @@<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Courier New&quot;">&nbsp; <o:p> \
</o:p></span></p> <p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Courier \
New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $def[$count] .= \
&quot;DEF:var$i=$rrdfile:$DS[$i]:AVERAGE &quot; ;<o:p></o:p></span></p> <p \
class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Courier \
New&quot;">&nbsp;&nbsp;&nbsp;&nbsp; $def[$count] .= \
&quot;LINE:var$i#&quot;.$colors[$v&#43;&#43;].&quot;:\&quot;$NAME[$i]\&quot; &quot; \
;<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Courier \
New&quot;">&#43;<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp; \
$def[$count] .= &quot;GPRINT:var$i:LAST:\&quot;%3.2lf $UNIT[$i] last \&quot; \
&quot;;<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp; \
$def[$count] .= &quot;GPRINT:var$i:MAX:\&quot;%3.2lf $UNIT[$i] max \&quot; \
&quot;;<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp; \
$def[$count] .= &quot;GPRINT:var$i:AVERAGE:\&quot;%3.2lf $UNIT[$i] avg \\n\&quot; \
&quot;;<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Courier New&quot;">@@ -96,6 &#43;98,7 \
@@<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp; \
if(preg_match('/^amp_/',$NAME[$i])){<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp; \
if ($visited_amp == 0) {<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp;&nbsp;&#43;&#43;$count;<o:p></o:p></span></p> <p \
class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Courier \
New&quot;">&#43;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $def[$count] = \
'';<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp;&nbsp;$visited_amp = 1;<o:p></o:p></span></p> <p \
class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Courier \
New&quot;">&nbsp;&nbsp;&nbsp;&nbsp; }<o:p></o:p></span></p> </div>
</body>
</html>


[Attachment #4 (--===============1761215874232791295==)]
------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev

_______________________________________________
Nagios-users mailing list
Nagios-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic