]> git.uio.no Git - check_openmanage.git/blame - check_openmanage.php
jau
[check_openmanage.git] / check_openmanage.php
CommitLineData
7e2aee73 1<?php
7e2aee73 2#
56821ab5 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
7# Date: 2009-08-25
7e2aee73 8
c72f3183 9# Array with different colors
7e2aee73 10$colors = array("0022ff", "22ff22", "ff0000", "00aaaa", "ff00ff",
56821ab5 11 "ffa500", "cc0000", "0000cc", "0080C0", "8080C0",
12 "FF0080", "800080", "688e23", "408080", "808000",
13 "000000", "00FF00", "0080FF", "FF8000", "800000",
14 "FB31FB");
7e2aee73 15
c72f3183 16# Color for power usage in watts
17$PWRcolor = "66FF00";
7e2aee73 18
c72f3183 19# Counters
20$count = 0; # general counter
21$f = 0; # fan probe counter
22$t = 0; # temp probe counter
23$a = 0; # amp probe counter
24$e = 0; # enclosure counter
7e2aee73 25
c72f3183 26# Flags
7e2aee73 27$visited_fan = 0;
28$visited_temp = 0;
29$visited_pwr = 0;
30
c72f3183 31# Enclosure id
7e2aee73 32$enclosure_id = '';
33
c72f3183 34# Default title
35$def_title = 'Dell OpenManage';
36
37# Loop through the performance data
7e2aee73 38foreach ($DS as $i) {
7e2aee73 39
56821ab5 40 # AMPERAGE PROBE (Watts)
41 if(preg_match('/^pwr_mon_/',$NAME[$i]) && $UNIT[$i] == 'W') {
42 $NAME[$i] = preg_replace('/^pwr_mon_\d+_/', '', $NAME[$i]);
43 $NAME[$i] = preg_replace('/_/', ' ', $NAME[$i]);
44
45 ++$count;
46 $ds_name[$count] = "Power Consumption";
47 $vlabel = "Watt";
48
49 $title = $ds_name[$count];
50
51 $opt[$count] = "--slope-mode --vertical-label \"$vlabel\" --title \"$def_title: $title\" ";
52
53 $def[$count] = "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ;
54 $def[$count] .= "AREA:var$i#$PWRcolor:\"$NAME[$i]\" " ;
55 $def[$count] .= "LINE:var$i#000000: " ;
56 $def[$count] .= "GPRINT:var$i:LAST:\"%6.0lf $UNIT[$i] last \" ";
57 $def[$count] .= "GPRINT:var$i:MAX:\"%6.0lf $UNIT[$i] max \" ";
58 $def[$count] .= "GPRINT:var$i:AVERAGE:\"%6.2lf $UNIT[$i] avg \\n\" ";
7e2aee73 59 }
56821ab5 60
61 # AMPERAGE PROBES (Ampere)
62 if(preg_match('/^pwr_mon_/',$NAME[$i]) && $UNIT[$i] == 'A') {
63 $NAME[$i] = preg_replace('/^pwr_mon_\d+_/', '', $NAME[$i]);
64 $NAME[$i] = preg_replace('/_/', ' ', $NAME[$i]);
65 $NAME[$i] = preg_replace('/ current \d+$/', '', $NAME[$i]);
66 $NAME[$i] = preg_replace('/ps/', 'PowerSupply', $NAME[$i]);
67
68 if ($visited_pwr == 0) {
69 ++$count;
70 $visited_pwr = 1;
71 }
72 $ds_name[$count] = "Amperage Probes";
73 $vlabel = "Ampere";
74
75 $title = $ds_name[$count];
76
77 $opt[$count] = "-X0 --lower-limit 0 --slope-mode --vertical-label \"$vlabel\" --title \"$def_title: $title\" ";
78 if(isset($def[$count])){
79 $def[$count] .= "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ;
80 }else{
81 $def[$count] = "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ;
82 }
83 $def[$count] .= "LINE:var$i#".$colors[$a].":\"$NAME[$i]\" " ;
84 $def[$count] .= "AREA:var$i#".$colors[$a++]."20: " ;
85 $def[$count] .= "GPRINT:var$i:LAST:\"%4.2lf $UNIT[$i] last \" ";
86 $def[$count] .= "GPRINT:var$i:MAX:\"%4.2lf $UNIT[$i] max \" ";
87 $def[$count] .= "GPRINT:var$i:AVERAGE:\"%4.4lf $UNIT[$i] avg \\n\" ";
7e2aee73 88 }
7e2aee73 89
56821ab5 90 # FANS (RPMs)
91 if(preg_match('/^fan_/',$NAME[$i])){
92 if ($visited_fan == 0) {
93 ++$count;
94 $visited_fan = 1;
95 }
96
97 $NAME[$i] = preg_replace('/^fan_\d+_/', '', $NAME[$i]);
98 $NAME[$i] = preg_replace('/_rpm$/', '', $NAME[$i]);
99 $NAME[$i] = preg_replace('/_/', ' ', $NAME[$i]);
100
101 $ds_name[$count] = "Fan Speed";
102
103 $opt[$count] = "-X0 --slope-mode --vertical-label \"RPMs\" --title \"$def_title: Fan Speeds\" ";
104 if(isset($def[$count])){
105 $def[$count] .= "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ;
106 }else{
107 $def[$count] = "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ;
108 }
109 $def[$count] .= "LINE:var$i#".$colors[$f++].":\"$NAME[$i]\" " ;
110 $def[$count] .= "GPRINT:var$i:LAST:\"%6.0lf RPM last \" ";
111 $def[$count] .= "GPRINT:var$i:MAX:\"%6.0lf RPM max \" ";
112 $def[$count] .= "GPRINT:var$i:AVERAGE:\"%6.2lf RPM avg \\n\" ";
7e2aee73 113 }
56821ab5 114
115 # TEMPERATURES (Celcius)
116 if(preg_match('/^temp_/',$NAME[$i])){
117 if ($visited_temp == 0) {
118 ++$count;
119 $visited_temp = 1;
120 }
121 $NAME[$i] = preg_replace('/^temp_\d+_/', '', $NAME[$i]);
122 $NAME[$i] = preg_replace('/_/', ' ', $NAME[$i]);
123
124 $ds_name[$count] = "Chassis Temperatures";
125
126 $warnThresh = "INF";
127 $critThresh = "INF";
128
129 if ($WARN[$i] != "") {
130 $warnThresh = $WARN[$i];
131 }
132 if ($CRIT[$i] != "") {
133 $critThresh = $CRIT[$i];
134 }
135
136 $opt[$count] = "--slope-mode --vertical-label \"Celcius\" --title \"$def_title: Chassis Temperatures\" ";
137 if(isset($def[$count])){
138 $def[$count] .= "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ;
139 }else{
140 $def[$count] = "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ;
141 }
142 $def[$count] .= "LINE:var$i#".$colors[$t++].":\"$NAME[$i]\" " ;
143
144 $def[$count] .= "GPRINT:var$i:LAST:\"%6.0lf $UNIT[$i] last \" ";
145 $def[$count] .= "GPRINT:var$i:MAX:\"%6.0lf $UNIT[$i] max \" ";
146 $def[$count] .= "GPRINT:var$i:AVERAGE:\"%6.2lf $UNIT[$i] avg \\n\" ";
7e2aee73 147 }
56821ab5 148
149 # ENCLOSURE TEMPERATURES (Celcius)
150 if(preg_match('/^enclosure_(?<id>.+?)_temp_\d+$/', $NAME[$i], $matches)){
151 $this_id = $matches['id'];
152
153 if ($enclosure_id != $this_id) {
154 $e = 0;
155 ++$count;
156 $enclosure_id = $this_id;
157 }
158 $NAME[$i] = preg_replace('/^enclosure_.+?_temp_(\d+)$/', 'Probe $1', $NAME[$i]);
159
160 $ds_name[$count] = "Enclosure $enclosure_id Temperatures";
161
162 $warnThresh = "INF";
163 $critThresh = "INF";
164
165 if ($WARN[$i] != "") {
166 $warnThresh = $WARN[$i];
167 }
168 if ($CRIT[$i] != "") {
169 $critThresh = $CRIT[$i];
170 }
171
172 $opt[$count] = "--slope-mode --vertical-label \"Celcius\" --title \"$def_title: Enclosure $enclosure_id Temperatures\" ";
173
174 if(isset($def[$count])){
175 $def[$count] .= "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ;
176 }else{
177 $def[$count] = "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ;
178 }
179 $def[$count] .= "LINE:var$i#".$colors[$e++].":\"$NAME[$i]\" " ;
180
181 $def[$count] .= "GPRINT:var$i:LAST:\"%6.0lf $UNIT[$i] last \" ";
182 $def[$count] .= "GPRINT:var$i:MAX:\"%6.0lf $UNIT[$i] max \" ";
183 $def[$count] .= "GPRINT:var$i:AVERAGE:\"%6.2lf $UNIT[$i] avg \\n\" ";
7e2aee73 184 }
56821ab5 185
7e2aee73 186}
187?>