3 # PNP4Nagios template for check_openmanage
4 # Author: Trond Hasle Amundsen
5 # Contact: t.h.amundsen@usit.uio.no
6 # Website: http://folk.uio.no/trondham/software/check_openmanage.html
11 # Copyright (C) 2008-2011 Trond H. Amundsen
13 # This program is free software: you can redistribute it and/or modify
14 # it under the terms of the GNU General Public License as published by
15 # the Free Software Foundation, either version 3 of the License, or
16 # (at your option) any later version.
18 # This program is distributed in the hope that it will be useful, but
19 # WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 # General Public License for more details.
23 # You should have received a copy of the GNU General Public License
24 # along with this program. If not, see <http://www.gnu.org/licenses/>.
26 # Array with different colors
27 $colors = array("0022ff", "22ff22", "ff0000", "00aaaa", "ff00ff",
28 "ffa500", "cc0000", "0000cc", "0080C0", "8080C0",
29 "FF0080", "800080", "688e23", "408080", "808000",
30 "000000", "00FF00", "0080FF", "FF8000", "800000",
33 # Color for power usage in watts
37 $count = 0; # general counter
38 $f = 0; # fan probe counter
39 $t = 0; # temp probe counter
40 $a = 0; # amp probe counter
41 $v = 0; # volt probe counter
42 $e = 0; # enclosure counter
54 $def_title = 'Dell OpenManage';
56 # Loop through the performance data
60 if (preg_match('/^T/', $NAME[$i])) {
61 if ($visited_temp == 0) {
67 switch ($VAL['UNIT']) {
69 $unit_long = "Fahrenheit";
73 $unit_long = "Kelvin";
77 $unit_long = "Rankine";
81 $unit_long = "Celsius";
86 $NAME[$i] = preg_replace('/^T(\d+)_(.+)/', '$2', $NAME[$i]);
87 $NAME[$i] = preg_replace('/_/', ' ', $NAME[$i]);
90 $NAME[$i] = preg_replace('/^T(\d+)$/', 'Probe $1', $NAME[$i]);
92 $ds_name[$count] = "Chassis Temperatures";
97 if ($WARN[$i] != "") {
98 $warnThresh = $WARN[$i];
100 if ($CRIT[$i] != "") {
101 $critThresh = $CRIT[$i];
104 $opt[$count] = "--slope-mode --vertical-label \"$unit_long\" --title \"$def_title: Chassis Temperatures\" ";
105 if(isset($def[$count])){
106 $def[$count] .= "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ;
109 $def[$count] = "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ;
111 $def[$count] .= "LINE:var$i#".$colors[$t++].":\"$NAME[$i]\" " ;
112 $def[$count] .= "GPRINT:var$i:LAST:\"%6.0lf $unit_short last \" ";
113 $def[$count] .= "GPRINT:var$i:MAX:\"%6.0lf $unit_short max \" ";
114 $def[$count] .= "GPRINT:var$i:AVERAGE:\"%6.2lf $unit_short avg \\n\" ";
118 if (preg_match('/^W/', $NAME[$i])) {
121 $NAME[$i] = preg_replace('/^W(\d+)_(.+)/', '$2', $NAME[$i]);
122 $NAME[$i] = preg_replace('/_/', ' ', $NAME[$i]);
125 $NAME[$i] = preg_replace('/^W(\d+)$/', 'Probe $1', $NAME[$i]);
128 $ds_name[$count] = "Power Consumption";
131 $title = $ds_name[$count];
133 $opt[$count] = "--slope-mode --vertical-label \"$vlabel\" --title \"$def_title: $title\" ";
135 if(isset($def[$count])){
136 $def[$count] .= "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ;
139 $def[$count] = "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ;
142 $def[$count] .= "VDEF:tot$i=var$i,TOTAL ";
143 $def[$count] .= "CDEF:kwh$i=var$i,POP,tot$i,1000,/,60,/,60,/ ";
144 $def[$count] .= "CDEF:btu$i=kwh$i,3412.3,* ";
146 $def[$count] .= "AREA:var$i#$PWRcolor:\"$NAME[$i]\" " ;
147 $def[$count] .= "GPRINT:var$i:LAST:\"%6.0lf W last \" ";
148 $def[$count] .= "GPRINT:var$i:MAX:\"%6.0lf W max \" ";
149 $def[$count] .= "GPRINT:var$i:AVERAGE:\"%6.2lf W avg \l\" ";
151 $def[$count] .= "COMMENT:\" \l\" ";
153 $def[$count] .= "COMMENT:\" Total power used in time period\:\" ";
154 $def[$count] .= "GPRINT:kwh$i:AVERAGE:\"%10.2lf kWh\l\" ";
156 $def[$count] .= "COMMENT:\" \" ";
157 $def[$count] .= "GPRINT:btu$i:AVERAGE:\"%10.2lf BTU\l\" ";
161 if (preg_match('/^A/', $NAME[$i])) {
164 $NAME[$i] = preg_replace('/^A(\d+)_(.+)/', '$2', $NAME[$i]);
165 $NAME[$i] = preg_replace('/_/', ' ', $NAME[$i]);
168 $NAME[$i] = preg_replace('/^A(\d+)$/', 'Probe $1', $NAME[$i]);
170 if ($visited_amp == 0) {
174 $ds_name[$count] = "Amperage Probes";
177 $title = $ds_name[$count];
179 $opt[$count] = "-X0 --lower-limit 0 --slope-mode --vertical-label \"$vlabel\" --title \"$def_title: $title\" ";
180 if(isset($def[$count])){
181 $def[$count] .= "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE ";
184 $def[$count] = "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE ";
186 $def[$count] .= "AREA:var$i#".$colors[$a++].":\"$NAME[$i]\":STACK ";
187 $def[$count] .= "GPRINT:var$i:LAST:\"%4.1lf A last \" ";
188 $def[$count] .= "GPRINT:var$i:MAX:\"%4.1lf A max \" ";
189 $def[$count] .= "GPRINT:var$i:AVERAGE:\"%4.3lf A avg \\n\" ";
194 if (preg_match('/^V/', $NAME[$i])) {
197 $NAME[$i] = preg_replace('/^V(\d+)_(.+)/', '$2', $NAME[$i]);
198 $NAME[$i] = preg_replace('/_/', ' ', $NAME[$i]);
201 $NAME[$i] = preg_replace('/^V(\d+)$/', 'Probe $1', $NAME[$i]);
203 if ($visited_volt == 0) {
207 $ds_name[$count] = "Voltage Probes";
210 $title = $ds_name[$count];
212 $opt[$count] = "--slope-mode --vertical-label \"$vlabel\" --title \"$def_title: $title\" ";
213 if(isset($def[$count])){
214 $def[$count] .= "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ;
217 $def[$count] = "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ;
219 $def[$count] .= "LINE:var$i#".$colors[$v++].":\"$NAME[$i]\" " ;
220 $def[$count] .= "GPRINT:var$i:LAST:\"%4.2lf A last \" ";
221 $def[$count] .= "GPRINT:var$i:MAX:\"%4.2lf A max \" ";
222 $def[$count] .= "GPRINT:var$i:AVERAGE:\"%4.4lf A avg \\n\" ";
226 if (preg_match('/^F/', $NAME[$i])) {
227 if ($visited_fan == 0) {
233 $NAME[$i] = preg_replace('/^F(\d+)_(.+)/', '$2', $NAME[$i]);
234 $NAME[$i] = preg_replace('/_/', ' ', $NAME[$i]);
237 $NAME[$i] = preg_replace('/^F(\d+)$/', 'Probe $1', $NAME[$i]);
239 $ds_name[$count] = "Fan Probes";
241 $opt[$count] = "-X0 --slope-mode --vertical-label \"RPMs\" --title \"$def_title: Fan Speeds\" ";
242 if(isset($def[$count])){
243 $def[$count] .= "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ;
246 $def[$count] = "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ;
248 $def[$count] .= "LINE:var$i#".$colors[$f++].":\"$NAME[$i]\" " ;
249 $def[$count] .= "GPRINT:var$i:LAST:\"%6.0lf RPM last \" ";
250 $def[$count] .= "GPRINT:var$i:MAX:\"%6.0lf RPM max \" ";
251 $def[$count] .= "GPRINT:var$i:AVERAGE:\"%6.2lf RPM avg \\n\" ";
254 # ENCLOSURE TEMPERATURES (Celsius)
255 if (preg_match('/^E(?P<encl>.+?)_t(emp_)?(?P<probe>\d+)/', $NAME[$i], $matches)) {
257 $this_id = $matches['encl'];
258 $probe_index = $matches['probe'];
260 if ($enclosure_id != $this_id) {
263 $enclosure_id = $this_id;
267 $NAME[$i] = "Probe $probe_index";
269 $ds_name[$count] = "Enclosure $enclosure_id Temperatures";
274 if ($WARN[$i] != "") {
275 $warnThresh = $WARN[$i];
277 if ($CRIT[$i] != "") {
278 $critThresh = $CRIT[$i];
281 $opt[$count] = "--slope-mode --vertical-label \"Celsius\" --title \"$def_title: Enclosure $enclosure_id Temperatures\" ";
283 if(isset($def[$count])){
284 $def[$count] .= "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ;
287 $def[$count] = "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ;
289 $def[$count] .= "LINE:var$i#".$colors[$e++].":\"$NAME[$i]\" " ;
290 $def[$count] .= "GPRINT:var$i:LAST:\"%6.0lf °C last \" ";
291 $def[$count] .= "GPRINT:var$i:MAX:\"%6.0lf °C max \" ";
292 $def[$count] .= "GPRINT:var$i:AVERAGE:\"%6.2lf °C avg \\n\" ";