]> git.uio.no Git - check_openmanage.git/blame - check_openmanage.php
bugfix for certain amperage probes (e.g. PE R920)
[check_openmanage.git] / check_openmanage.php
CommitLineData
7e2aee73 1<?php
7e2aee73 2#
0a317f92
THA
3# PNP4Nagios template for check_openmanage
4#
56821ab5 5# Author: Trond Hasle Amundsen
6# Contact: t.h.amundsen@usit.uio.no
e1283fe3 7# Website: http://folk.uio.no/trondham/software/check_openmanage.html
0a317f92
THA
8# Date: ___DATE___
9# Version: ___VERSION___
c27a83d9 10#
0a317f92 11# Copyright (C) 2008-2012 Trond Hasle Amundsen
c27a83d9 12#
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.
17#
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.
22#
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/>.
7e2aee73 25
c72f3183 26# Array with different colors
7e2aee73 27$colors = array("0022ff", "22ff22", "ff0000", "00aaaa", "ff00ff",
e1283fe3 28 "ffa500", "cc0000", "0000cc", "0080C0", "8080C0",
29 "FF0080", "800080", "688e23", "408080", "808000",
30 "000000", "00FF00", "0080FF", "FF8000", "800000",
31 "FB31FB");
7e2aee73 32
c72f3183 33# Counters
c72f3183 34$f = 0; # fan probe counter
35$t = 0; # temp probe counter
36$a = 0; # amp probe counter
596e2160 37$v = 0; # volt probe counter
c72f3183 38$e = 0; # enclosure counter
7e2aee73 39
c72f3183 40# Flags
596e2160 41$visited_amp = 0;
57bd16a9 42
43# IDs
44$id_temp1 = 1;
45$id_temp2 = 2;
46$id_watt = 3;
47$id_amp = 4;
48$id_volt = 5;
49$id_fan = 6;
50$id_enc = 7;
7e2aee73 51
c72f3183 52# Enclosure id
7e2aee73 53$enclosure_id = '';
54
c72f3183 55# Default title
56$def_title = 'Dell OpenManage';
57
d4065fda 58# Temperature unit
6332d1ec 59if (!defined('tempunit_defined')) {
60 define('tempunit_defined', 1);
61
62 function tempunit($arg)
63 {
64 $unit = 'unknown';
65 $vlabel = 'unknown';
66
67 switch ($arg) {
68 default:
69 $vlabel = "Celsius";
518d3d2b 70 $unit = "\xc2\xb0C";
6332d1ec 71 break;
72 case "F":
73 $vlabel = "Fahrenheit";
518d3d2b 74 $unit = "\xc2\xb0F";
6332d1ec 75 break;
76 case "K":
77 $vlabel = "Kelvin";
78 $unit = "K";
79 break;
80 case "R":
81 $vlabel = "Rankine";
518d3d2b 82 $unit = "\xc2\xb0R";
6332d1ec 83 break;
84 }
85 return array($unit, $vlabel);
d4065fda 86 }
d4065fda 87}
88
15c5ae94 89
6332d1ec 90# Determine if we're running in legacy mode
91$legacy = "no";
92foreach ($this->DS as $KEY=>$VAL) {
93 if (preg_match('/^(pwr_mon_|fan_|temp_|enclosure_|p\d+|f\d+|t\d+|e.+?t\d+)/', $VAL['LABEL'])) {
94 $legacy = "yes";
95 break;
96 }
97}
57bd16a9 98
6332d1ec 99#------------------------------------------------------
100# MAIN LOOP
101#------------------------------------------------------
102if ($legacy == "yes") { # --legacy--
103
104 $count = 0; # general counter
105 $PWRcolor = "66FF00";
106
107 # Flags
108 $visited_fan = 0;
109 $visited_temp = 0;
110 $visited_pwr = 0;
111
112 # Loop through the performance data
113 foreach ($this->DS as $KEY=>$VAL) {
114
115 # AMPERAGE PROBE
116 if(preg_match('/^pwr_mon_/', $VAL['NAME']) || preg_match('/^p\d+[aw]$/', $VAL['NAME'])) {
117
118 # Watt
119 if (preg_match('/system/', $VAL['NAME']) || preg_match('/^p\d+w$/', $VAL['NAME'])) {
120
121 # Long label
122 $VAL['NAME'] = preg_replace('/^pwr_mon_\d+_/', '', $VAL['NAME']);
123 $VAL['NAME'] = preg_replace('/_/', ' ', $VAL['NAME']);
124
125 # Short label
126 $VAL['NAME'] = preg_replace('/^p(\d+)w$/', 'Power Probe $1', $VAL['NAME']);
127
128 ++$count;
129 $ds_name[$count] = "Power Consumption";
130 $vlabel = "Watt";
131
132 $title = $ds_name[$count];
133
134 $opt[$count] = "--slope-mode --vertical-label \"$vlabel\" --title \"$def_title: $title\" ";
135
136 if(isset($def[$count])){
137 $def[$count] .= rrd::def("var".$KEY, $VAL['RRDFILE'], $VAL['DS'], "AVERAGE");
138 }
139 else {
140 $def[$count] = rrd::def("var".$KEY, $VAL['RRDFILE'], $VAL['DS'], "AVERAGE");
141 }
142 $def[$count] .= rrd::area("var$KEY", "#".$PWRcolor, $VAL['NAME']);
143 $def[$count] .= rrd::line1("var$KEY","#000000");
144 $def[$count] .= rrd::gprint("var$KEY",array("LAST", "MAX", "AVERAGE"), "%6.0lf W");
145 }
146 # Ampere
147 elseif (preg_match('/current/', $VAL['NAME']) || preg_match('/^p\d+a$/', $VAL['NAME'])) {
148
149 # Long label
150 $VAL['NAME'] = preg_replace('/^pwr_mon_\d+_/', '', $VAL['NAME']);
151 $VAL['NAME'] = preg_replace('/_/', ' ', $VAL['NAME']);
152 $VAL['NAME'] = preg_replace('/ current \d+$/', '', $VAL['NAME']);
153 $VAL['NAME'] = preg_replace('/ps/', 'PowerSupply', $VAL['NAME']);
154
155 # Short label
156 $VAL['NAME'] = preg_replace('/^p(\d+)a$/', 'Amperage Probe $1', $VAL['NAME']);
157
158 if ($visited_pwr == 0) {
159 ++$count;
160 $visited_pwr = 1;
161 }
162 $ds_name[$count] = "Amperage Probes";
163 $vlabel = "Ampere";
164
165 $title = $ds_name[$count];
166
167 $opt[$count] = "-X0 --lower-limit 0 --slope-mode --vertical-label \"$vlabel\" --title \"$def_title: $title\" ";
168 if(isset($def[$count])){
169 $def[$count] .= rrd::def("var$KEY",$VAL['RRDFILE'],$VAL['DS'],"AVERAGE") ;
170 }
171 else {
172 $def[$count] = rrd::def("var$KEY",$VAL['RRDFILE'],$VAL['DS'],"AVERAGE") ;
173 }
174 $def[$count] .= rrd::line1("var$KEY", "#".$colors[$a], $VAL['NAME']) ;
175 $def[$count] .= rrd::area("var$KEY","#".$colors[$a++]."20") ;
176 $def[$count] .= rrd::gprint("var$KEY", array("LAST", "MAX", "AVERAGE"),"%4.2lf A") ;
177 }
57bd16a9 178 }
596e2160 179
6332d1ec 180 # FANS (RPMs)
181 if(preg_match('/^fan_/', $VAL['NAME']) || preg_match('/^f\d+$/', $VAL['NAME'])){
182 if ($visited_fan == 0) {
183 ++$count;
184 $visited_fan = 1;
185 }
186
187 # Long label
188 $VAL['NAME'] = preg_replace('/^fan_\d+_/', '', $VAL['NAME']);
189 $VAL['NAME'] = preg_replace('/_rpm$/', '', $VAL['NAME']);
190 $VAL['NAME'] = preg_replace('/_/', ' ', $VAL['NAME']);
191
192 # Short label
193 $VAL['NAME'] = preg_replace('/^f(\d+)$/', 'Fan Probe $1', $VAL['NAME']);
194
195 $ds_name[$count] = "Fan Speed";
196
197 $opt[$count] = "-X0 --slope-mode --vertical-label \"RPMs\" --title \"$def_title: Fan Speeds\" ";
198 if(isset($def[$count])){
199 $def[$count] .= rrd::def("var$KEY", $VAL['RRDFILE'], $VAL['DS'], "AVERAGE") ;
200 }
201 else {
202 $def[$count] = rrd::def("var$KEY",$VAL['RRDFILE'],$VAL['DS'],"AVERAGE");
203 }
204 $def[$count] .= rrd::line1("var$KEY", "#".$colors[$f++],$VAL['NAME']);
205 $def[$count] .= rrd::gprint("var$KEY", array("LAST", "MAX", "AVERAGE"),"%6.0lf RPM");
57bd16a9 206 }
6332d1ec 207
208 # TEMPERATURES (Celsius)
209 if(preg_match('/^temp_/', $VAL['NAME']) || preg_match('/^t\d+$/', $VAL['NAME'])){
210 if ($visited_temp == 0) {
211 ++$count;
212 $visited_temp = 1;
213 }
214
215 # Long label
216 $VAL['NAME'] = preg_replace('/^temp_\d+_/', '', $VAL['NAME']);
217 $VAL['NAME'] = preg_replace('/_/', ' ', $VAL['NAME']);
218
219 # Short label
220 $VAL['NAME'] = preg_replace('/^t(\d+)$/', 'Temperature Probe $1', $VAL['NAME']);
221
222 $ds_name[$count] = "Chassis Temperatures";
223
224 $warnThresh = "INF";
225 $critThresh = "INF";
226
227 if ($VAL['WARN'] != "") {
228 $warnThresh = $VAL['WARN'];
229 }
230 if ($VAL['CRIT'] != "") {
231 $critThresh = $VAL['CRIT'];
232 }
233
234 $opt[$count] = "--slope-mode --vertical-label \"Celsius\" --title \"$def_title: Chassis Temperatures\" ";
235 if(isset($def[$count])){
236 $def[$count] .= rrd::def("var$KEY",$VAL['RRDFILE'],$VAL['DS'],"AVERAGE") ;
237 }
238 else {
239 $def[$count] = rrd::def("var$KEY", $VAL['RRDFILE'],$VAL['DS'],"AVERAGE") ;
240 }
241 $def[$count] .= rrd::line1("var$KEY", "#".$colors[$t++], $VAL['NAME']);
242 $def[$count] .= rrd::gprint("var$KEY",array("LAST", "MAX", "AVERAGE"),"%6.0lf C");
7e2aee73 243 }
6332d1ec 244
245 # ENCLOSURE TEMPERATURES (Celsius)
246 if(preg_match('/^enclosure_(?P<id>.+?)_temp_\d+$/', $VAL['NAME'], $matches)
247 || preg_match('/^e(?P<id>.+?)t\d+$/', $VAL['NAME'], $matches)) {
248 $this_id = $matches['id'];
249
250 if ($enclosure_id != $this_id) {
251 $e = 0;
252 ++$count;
253 $enclosure_id = $this_id;
254 }
255
256 # Long label
257 $VAL['NAME'] = preg_replace('/^enclosure_.+?_temp_(\d+)$/', 'Probe $1', $VAL['NAME']);
258
259 # Short label
260 $VAL['NAME'] = preg_replace('/^e.+?t(\d+)$/', 'Probe $1', $VAL['NAME']);
261
262 $ds_name[$count] = "Enclosure $enclosure_id Temperatures";
263
264 $warnThresh = "INF";
265 $critThresh = "INF";
266
267 if ($VAL['WARN'] != "") {
268 $warnThresh = $VAL['WARN'];
269 }
270 if ($VAL['CRIT'] != "") {
271 $critThresh = $VAL['CRIT'];
272 }
273
274 $opt[$count] = "--slope-mode --vertical-label \"Celsius\" --title \"$def_title: Enclosure $enclosure_id Temperatures\" ";
275
276 if(isset($def[$count])){
277 $def[$count] .= rrd::def("var$KEY", $VAL['RRDFILE'],$VAL['DS'],"AVERAGE") ;
278 }
279 else {
280 $def[$count] = rrd::def("var$KEY",$VAL['RRDFILE'],$VAL['DS'],"AVERAGE") ;
281 }
282 $def[$count] .= rrd::line1("var$KEY","#".$colors[$e++],$VAL['NAME']) ;
283 $def[$count] .= rrd::gprint("var$KEY", array("LAST", "MAX", "AVERAGE"),"%6.0lf C");
7e2aee73 284 }
57bd16a9 285 }
6332d1ec 286}
287else { # --new--
288
289 # Loop through the performance data
290 foreach ($this->DS as $KEY=>$VAL) {
291
292 $label = $VAL['LABEL'];
293
294 # TEMPERATURES (AMBIENT)
295 if (preg_match('/^T/', $label) && preg_match('/Ambient/', $label)) {
296
297 # Temperature unit and vertical label
298 list ($unit, $vlabel) = tempunit($VAL['UNIT']);
299
300 # Long label
301 $label = preg_replace('/^T(\d+)_(.+)/', '$2', $label);
302 $label = preg_replace('/_/', ' ', $label);
303
304 # Short label
305 $label = preg_replace('/^T(\d+)$/', 'Probe $1', $label);
306
307 $ds_name[$id_temp1] = "Temperatures";
308
309 $opt[$id_temp1] = "--slope-mode --vertical-label \"$vlabel\" --title \"$def_title: Ambient Temperature\" ";
310 if(isset($def[$id_temp1])){
311 $def[$id_temp1] .= rrd::def("var$KEY",$VAL['RRDFILE'],$VAL['DS'],"AVERAGE") ;
312 }
313 else {
314 $def[$id_temp1] = rrd::def("var$KEY", $VAL['RRDFILE'],$VAL['DS'],"AVERAGE") ;
315 }
316
317 # fancy graphing
318 $def[$id_temp1] .= rrd::gradient("var$KEY","#114480", "#1144dc", $label, 10, "50%");
319 $def[$id_temp1] .= rrd::gprint("var$KEY",array("LAST", "MAX", "AVERAGE"),"%5.1lf $unit");
320
321 # insert extra vertical space if we have thresholds
322 if ($VAL['WARN'] != "" || $VAL['CRIT'] != "") {
323 $def[$id_temp1] .= "COMMENT:\\s ";
324 }
325
326 # warning threshold
327 if ($VAL['WARN'] != "") {
328 $warnThresh = $VAL['WARN'];
329 $def[$id_temp1] .= rrd::cdef("warn$KEY", "var$KEY,$warnThresh,GT,var$KEY,UNKN,IF");
330 $def[$id_temp1] .= rrd::gradient("warn$KEY","#c4c400", "#ffff00","Above Upper Warning Threshold\: $warnThresh $unit\\l", 10, "50%");
331 }
332
333 # critical threshold
334 if ($VAL['CRIT'] != "") {
335 $critThresh = $VAL['CRIT'];
336 $def[$id_temp1] .= rrd::cdef("crit$KEY", "var$KEY,$critThresh,GT,var$KEY,UNKN,IF");
337 $def[$id_temp1] .= rrd::gradient("crit$KEY","#800000", "#dc0000","Above Upper Critical Threshold\: $critThresh $unit\\l", 10, "50%");
338 }
339 }
57bd16a9 340
6332d1ec 341 # TEMPERATURES
342 if (preg_match('/^T/', $label) && !preg_match('/Ambient/', $label)) {
57bd16a9 343
6332d1ec 344 # Temperature unit and vertical label
345 list ($unit, $vlabel) = tempunit($VAL['UNIT']);
57bd16a9 346
6332d1ec 347 # Long label
348 $label = preg_replace('/^T(\d+)_(.+)/', '$2', $label);
349 $label = preg_replace('/_/', ' ', $label);
e1283fe3 350
6332d1ec 351 # Short label
352 $label = preg_replace('/^T(\d+)$/', 'Probe $1', $label);
57bd16a9 353
6332d1ec 354 $ds_name[$id_temp2] = "Temperatures";
57bd16a9 355
6332d1ec 356 $opt[$id_temp2] = "--slope-mode --vertical-label \"$vlabel\" --title \"$def_title: Chassis Temperatures\" ";
357 if (isset($def[$id_temp2])) {
358 $def[$id_temp2] .= rrd::def("var$KEY", $VAL['RRDFILE'],$VAL['DS'],"AVERAGE") ;
359 }
360 else {
361 $def[$id_temp2] = rrd::def("var$KEY",$VAL['RRDFILE'],$VAL['DS'],"AVERAGE") ;
362 }
363 $def[$id_temp2] .= rrd::line1("var$KEY", "#".$colors[$t++], rrd::cut($label,20) );
364 $def[$id_temp2] .= rrd::gprint("var$KEY", array("LAST", "MAX", "AVERAGE"), "%4.1lf $unit");
596e2160 365 }
596e2160 366
6332d1ec 367 # WATTAGE PROBE
368 if (preg_match('/^W/', $label)) {
596e2160 369
6332d1ec 370 # Long label
371 $label = preg_replace('/^W(\d+)_(.+)/', '$2', $label);
372 $label = preg_replace('/_/', ' ', $label);
e1283fe3 373
6332d1ec 374 # Short label
375 $label = preg_replace('/^W(\d+)$/', 'Probe $1', $label);
e1283fe3 376
6332d1ec 377 $ds_name[$id_watt] = "Power Consumption";
378 $vlabel = "Watt";
596e2160 379
6332d1ec 380 $title = $ds_name[$id_watt];
596e2160 381
6332d1ec 382 $opt[$id_watt] = "--slope-mode --vertical-label \"$vlabel\" --title \"$def_title: $title\" ";
e1283fe3 383
6332d1ec 384 if(isset($def[$id_watt])){
385 $def[$id_watt] .= rrd::def("var$KEY",$VAL['RRDFILE'], $VAL['DS'], "AVERAGE") ;
386 }
387 else {
388 $def[$id_watt] = rrd::def("var$KEY",$VAL['RRDFILE'],$VAL['DS'],"AVERAGE") ;
389 }
c27a83d9 390
6332d1ec 391 # calculate kWh and BTU
392 $def[$id_watt] .= "VDEF:tot$KEY=var$KEY,TOTAL ";
393 # rrd:vdef is broken in pnp4nagios 0.6.13 # $def[$id_watt] .= rrd::vdef("tot$KEY","var$KEY,TOTAL");
394 $def[$id_watt] .= rrd::cdef("kwh$KEY","var$KEY,POP,tot$KEY,1000,/,60,/,60,/");
395 $def[$id_watt] .= rrd::cdef("btu$KEY","kwh$KEY,3412.3,*");
596e2160 396
6332d1ec 397 # fancy graphing
398 $def[$id_watt] .= rrd::gradient("var$KEY","#800000","#dc0000","$label", 10, "50%");
596e2160 399
6332d1ec 400 # print avg, max and min
401 $def[$id_watt] .= rrd::gprint("var$KEY", array("LAST", "MAX", "AVERAGE"),"%6.0lf W");
57bd16a9 402
6332d1ec 403 # print kWh and BTU for time period
404 $def[$id_watt] .= rrd::comment("\\s");
405 $def[$id_watt] .= rrd::comment(" Total power used in time period\:");
406 $def[$id_watt] .= rrd::gprint("kwh$KEY","AVERAGE","%10.2lf kWh\l");
407 $def[$id_watt] .= rrd::comment(" ");
408 $def[$id_watt] .= rrd::gprint("btu$KEY","AVERAGE","%10.2lf BTU\l");
596e2160 409 }
57bd16a9 410
6332d1ec 411 # AMPERAGE PROBE
1c34273a 412 if (preg_match('/^A/', $label) && preg_match('/Current/', $label)) {
6332d1ec 413
414 $first = 0;
415 if ($visited_amp == 0) {
416 $first = 1;
417 $visited_amp = 1;
418 }
419
420 # Long label
421 $label = preg_replace('/^A(\d+)_(.+)/', '$2', $label);
422 $label = preg_replace('/_/', ' ', $label);
423
424 # Short label
425 $label = preg_replace('/^A(\d+)$/', 'Probe $1', $label);
426
427 $ds_name[$id_amp] = "Amperage Probes";
428 $vlabel = "Ampere";
429
430 $title = $ds_name[$id_amp];
431
432 $opt[$id_amp] = "-X0 --lower-limit 0 --slope-mode --vertical-label \"$vlabel\" --title \"$def_title: $title\" ";
433 if(isset($def[$id_amp])){
434 $def[$id_amp] .= rrd::def("var$KEY",$VAL['RRDFILE'], $VAL['DS'], "AVERAGE");
435 }
436 else {
437 $def[$id_amp] = rrd::def("var$KEY",$VAL['RRDFILE'], $VAL['DS'], "AVERAGE");
438 }
439
440 $space = strlen($label) < 16 ? str_repeat(' ', 16 - strlen($label)) : ' ';
441
442 $def[$id_amp] .= rrd::cdef("tier$KEY", "var$KEY,10,/");
443 $def[$id_amp] .= "AREA:tier$KEY#".$colors[$a]."b7::STACK ";
444 $def[$id_amp] .= "AREA:tier$KEY#".$colors[$a]."bf::STACK ";
445 $def[$id_amp] .= "AREA:tier$KEY#".$colors[$a]."c7::STACK ";
446 $def[$id_amp] .= "AREA:tier$KEY#".$colors[$a]."cf::STACK ";
447 $def[$id_amp] .= "AREA:tier$KEY#".$colors[$a]."d7::STACK ";
448 $def[$id_amp] .= "AREA:tier$KEY#".$colors[$a]."df::STACK ";
449 $def[$id_amp] .= "AREA:tier$KEY#".$colors[$a]."e7::STACK ";
450 $def[$id_amp] .= "AREA:tier$KEY#".$colors[$a]."ef::STACK ";
451 $def[$id_amp] .= "AREA:tier$KEY#".$colors[$a]."f7::STACK ";
452 $def[$id_amp] .= "AREA:tier$KEY#".$colors[$a]."ff:\"$label$space\":STACK ";
453 $a++;
454
455 if ($first) {
456 $def[$id_amp] .= rrd::cdef("sum$KEY", "var$KEY,0,+");
457 }
458 else {
459 $def[$id_amp] .= rrd::cdef("sum$KEY", "sum".($KEY-1).",var$KEY,+");
460 }
461 $def[$id_amp] .= rrd::line1("sum$KEY", "#555555");
51ba1d66 462 $def[$id_amp] .= rrd::gprint("var$KEY", array("LAST", "MAX", "AVERAGE"),"%6.1lf A") ;
57bd16a9 463 }
596e2160 464
6332d1ec 465 # VOLTAGE PROBE
466 if (preg_match('/^V/', $label)) {
e1283fe3 467
6332d1ec 468 # Long label
469 $label = preg_replace('/^V(\d+)_(.+)/', '$2', $label);
470 $label = preg_replace('/_/', ' ', $label);
e1283fe3 471
6332d1ec 472 # Short label
473 $label = preg_replace('/^V(\d+)$/', 'Probe $1', $label);
596e2160 474
6332d1ec 475 $ds_name[$id_volt] = "Voltage Probes";
476 $vlabel = "Volts";
477
478 $title = $ds_name[$id_volt];
479
480 $opt[$id_volt] = "--slope-mode --vertical-label \"$vlabel\" --title \"$def_title: $title\" ";
481 if(isset($def[$id_volt])){
482 $def[$id_volt] .= rrd::def("var$KEY", $VAL['RRDFILE'], $VAL['DS'],"AVERAGE");
483 }
484 else {
485 $def[$id_volt] = rrd::def("var$KEY",$VAL['RRDFILE'],$VAL['DS'],"AVERAGE");
486 }
487 $def[$id_volt] .= rrd::line1("var$KEY", "#".$colors[$v++], rrd::cut($label,18) ) ;
30bfee9f 488 $def[$id_volt] .= rrd::gprint("var$KEY", array("LAST", "MAX", "AVERAGE"),"%8.2lf V");
e1283fe3 489 }
490
6332d1ec 491 # FANS (RPMs)
492 if (preg_match('/^F/', $label)) {
596e2160 493
6332d1ec 494 # Long label
495 $label = preg_replace('/^F(\d+)_(.+)/', '$2', $label);
496 $label = preg_replace('/_/', ' ', $label);
596e2160 497
6332d1ec 498 # Short label
499 $label = preg_replace('/^F(\d+)$/', 'Probe $1', $label);
596e2160 500
6332d1ec 501 $ds_name[$id_fan] = "Fan Probes";
596e2160 502
6332d1ec 503 $opt[$id_fan] = "-X0 --slope-mode --vertical-label \"RPMs\" --title \"$def_title: Fan Speeds\" ";
504 if(isset($def[$id_fan])){
505 $def[$id_fan] .= rrd::def("var$KEY",$VAL['RRDFILE'],$VAL['DS'], "AVERAGE") ;
506 }
507 else {
508 $def[$id_fan] = rrd::def("var$KEY",$VAL['RRDFILE'],$VAL['DS'], "AVERAGE") ;
509 }
510 $def[$id_fan] .= rrd::line1("var$KEY", "#".$colors[$f++], rrd::cut($label,18) ) ;
511 $def[$id_fan] .= rrd::gprint("var$KEY", array("LAST", "MAX", "AVERAGE"), "%6.0lf RPM");
7e2aee73 512 }
56821ab5 513
6332d1ec 514 # ENCLOSURE TEMPERATURES (Celsius)
515 if (preg_match('/^E(?P<encl>.+?)_t(emp_)?(?P<probe>\d+)/', $label, $matches)) {
c27a83d9 516
8d1e6322 517 # Temperature unit and vertical label
518 list ($unit, $vlabel) = tempunit($VAL['UNIT']);
519
6332d1ec 520 $this_id = $matches['encl'];
521 $probe_index = $matches['probe'];
e1283fe3 522
6332d1ec 523 if ($enclosure_id != $this_id) {
524 $e = 0;
525 $id_enc++;
526 $enclosure_id = $this_id;
527 }
e1283fe3 528
6332d1ec 529 # Label
530 $label = "Probe $probe_index";
e1283fe3 531
6332d1ec 532 $ds_name[$id_enc] = "Enclosure $enclosure_id Temperatures";
e1283fe3 533
8d1e6322 534 $opt[$id_enc] = "--slope-mode --vertical-label \"$vlabel\" --title \"$def_title: Enclosure $enclosure_id Temperatures\" ";
e1283fe3 535
6332d1ec 536 if(isset($def[$id_enc])){
537 $def[$id_enc] .= rrd::def("var$KEY", $VAL['RRDFILE'],$VAL['DS'], "AVERAGE") ;
538 }
539 else {
540 $def[$id_enc] = rrd::def("var$KEY", $VAL['RRDFILE'],$VAL['DS'], "AVERAGE") ;
541 }
542 $def[$id_enc] .= rrd::line1("var$KEY", "#".$colors[$e++], rrd::cut($label, 14) );
8d1e6322 543 $def[$id_enc] .= rrd::gprint("var$KEY", array("LAST", "MAX", "AVERAGE"),"%6.1lf $unit");
e1283fe3 544 }
e1283fe3 545 }
7e2aee73 546}
6332d1ec 547
7e2aee73 548?>