]>
Commit | Line | Data |
---|---|---|
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 | |
e1283fe3 | 6 | # Website: http://folk.uio.no/trondham/software/check_openmanage.html |
7 | # Date: 2010-03-16 | |
7e2aee73 | 8 | |
c72f3183 | 9 | # Array with different colors |
7e2aee73 | 10 | $colors = array("0022ff", "22ff22", "ff0000", "00aaaa", "ff00ff", |
e1283fe3 | 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 | |
596e2160 | 24 | $v = 0; # volt probe counter |
c72f3183 | 25 | $e = 0; # enclosure counter |
7e2aee73 | 26 | |
c72f3183 | 27 | # Flags |
7e2aee73 | 28 | $visited_fan = 0; |
29 | $visited_temp = 0; | |
596e2160 | 30 | $visited_amp = 0; |
0f49e9a3 | 31 | $visited_volt = 0; |
7e2aee73 | 32 | |
c72f3183 | 33 | # Enclosure id |
7e2aee73 | 34 | $enclosure_id = ''; |
35 | ||
c72f3183 | 36 | # Default title |
37 | $def_title = 'Dell OpenManage'; | |
38 | ||
39 | # Loop through the performance data | |
7e2aee73 | 40 | foreach ($DS as $i) { |
7e2aee73 | 41 | |
596e2160 | 42 | # TEMPERATURES (Celsius) |
43 | if (preg_match('/^T/', $NAME[$i])) { | |
44 | if ($visited_temp == 0) { | |
45 | ++$count; | |
46 | $visited_temp = 1; | |
47 | } | |
e1283fe3 | 48 | |
596e2160 | 49 | # Long label |
0f49e9a3 | 50 | $NAME[$i] = preg_replace('/^T(\d+)_(.+)/', 'Probe $1 [$2]', $NAME[$i]); |
596e2160 | 51 | $NAME[$i] = preg_replace('/_/', ' ', $NAME[$i]); |
e1283fe3 | 52 | |
596e2160 | 53 | # Short label |
0f49e9a3 | 54 | $NAME[$i] = preg_replace('/^T(\d+)$/', 'Probe $1', $NAME[$i]); |
e1283fe3 | 55 | |
596e2160 | 56 | $ds_name[$count] = "Chassis Temperatures"; |
57 | ||
58 | $warnThresh = "INF"; | |
59 | $critThresh = "INF"; | |
60 | ||
61 | if ($WARN[$i] != "") { | |
62 | $warnThresh = $WARN[$i]; | |
7e2aee73 | 63 | } |
596e2160 | 64 | if ($CRIT[$i] != "") { |
65 | $critThresh = $CRIT[$i]; | |
7e2aee73 | 66 | } |
e1283fe3 | 67 | |
596e2160 | 68 | $opt[$count] = "--slope-mode --vertical-label \"Celsius\" --title \"$def_title: Chassis Temperatures\" "; |
69 | if(isset($def[$count])){ | |
70 | $def[$count] .= "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ; | |
71 | } | |
72 | else { | |
73 | $def[$count] = "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ; | |
74 | } | |
75 | $def[$count] .= "LINE:var$i#".$colors[$t++].":\"$NAME[$i]\" " ; | |
76 | $def[$count] .= "GPRINT:var$i:LAST:\"%6.0lf C last \" "; | |
77 | $def[$count] .= "GPRINT:var$i:MAX:\"%6.0lf C max \" "; | |
78 | $def[$count] .= "GPRINT:var$i:AVERAGE:\"%6.2lf C avg \\n\" "; | |
79 | } | |
80 | ||
81 | # WATTAGE PROBE | |
82 | if (preg_match('/^W/', $NAME[$i])) { | |
83 | ||
e1283fe3 | 84 | # Long label |
0f49e9a3 | 85 | $NAME[$i] = preg_replace('/^W(\d+)_(.+)/', 'Probe $1 [$2]', $NAME[$i]); |
e1283fe3 | 86 | $NAME[$i] = preg_replace('/_/', ' ', $NAME[$i]); |
87 | ||
88 | # Short label | |
0f49e9a3 | 89 | $NAME[$i] = preg_replace('/^W(\d+)$/', 'Probe $1', $NAME[$i]); |
e1283fe3 | 90 | |
596e2160 | 91 | ++$count; |
92 | $ds_name[$count] = "Power Consumption"; | |
93 | $vlabel = "Watt"; | |
94 | ||
95 | $title = $ds_name[$count]; | |
96 | ||
97 | $opt[$count] = "--slope-mode --vertical-label \"$vlabel\" --title \"$def_title: $title\" "; | |
e1283fe3 | 98 | |
e1283fe3 | 99 | if(isset($def[$count])){ |
100 | $def[$count] .= "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ; | |
7e2aee73 | 101 | } |
e1283fe3 | 102 | else { |
103 | $def[$count] = "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ; | |
7e2aee73 | 104 | } |
596e2160 | 105 | $def[$count] .= "AREA:var$i#$PWRcolor:\"$NAME[$i]\" " ; |
106 | $def[$count] .= "LINE:var$i#000000: " ; | |
107 | $def[$count] .= "GPRINT:var$i:LAST:\"%6.0lf W last \" "; | |
108 | $def[$count] .= "GPRINT:var$i:MAX:\"%6.0lf W max \" "; | |
109 | $def[$count] .= "GPRINT:var$i:AVERAGE:\"%6.2lf W avg \\n\" "; | |
e1283fe3 | 110 | } |
596e2160 | 111 | |
112 | # AMPERAGE PROBE | |
113 | if (preg_match('/^A/', $NAME[$i])) { | |
114 | ||
115 | # Long label | |
0f49e9a3 | 116 | $NAME[$i] = preg_replace('/^A(\d+)_(.+)/', 'Probe $1 [$2]', $NAME[$i]); |
596e2160 | 117 | $NAME[$i] = preg_replace('/_/', ' ', $NAME[$i]); |
118 | ||
119 | # Short label | |
0f49e9a3 | 120 | $NAME[$i] = preg_replace('/^A(\d+)$/', 'Probe $1', $NAME[$i]); |
596e2160 | 121 | |
122 | if ($visited_amp == 0) { | |
e1283fe3 | 123 | ++$count; |
596e2160 | 124 | $visited_amp = 1; |
e1283fe3 | 125 | } |
596e2160 | 126 | $ds_name[$count] = "Amperage Probes"; |
127 | $vlabel = "Ampere"; | |
128 | ||
129 | $title = $ds_name[$count]; | |
130 | ||
131 | $opt[$count] = "-X0 --lower-limit 0 --slope-mode --vertical-label \"$vlabel\" --title \"$def_title: $title\" "; | |
132 | if(isset($def[$count])){ | |
133 | $def[$count] .= "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ; | |
134 | } | |
135 | else { | |
136 | $def[$count] = "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ; | |
137 | } | |
138 | $def[$count] .= "LINE:var$i#".$colors[$a].":\"$NAME[$i]\" " ; | |
596e2160 | 139 | $def[$count] .= "GPRINT:var$i:LAST:\"%4.2lf A last \" "; |
140 | $def[$count] .= "GPRINT:var$i:MAX:\"%4.2lf A max \" "; | |
141 | $def[$count] .= "GPRINT:var$i:AVERAGE:\"%4.4lf A avg \\n\" "; | |
142 | } | |
143 | ||
144 | ||
145 | # VOLTAGE PROBE | |
146 | if (preg_match('/^V/', $NAME[$i])) { | |
e1283fe3 | 147 | |
148 | # Long label | |
0f49e9a3 | 149 | $NAME[$i] = preg_replace('/^V(\d+)_(.+)/', 'Probe $1 [$2]', $NAME[$i]); |
e1283fe3 | 150 | $NAME[$i] = preg_replace('/_/', ' ', $NAME[$i]); |
151 | ||
152 | # Short label | |
0f49e9a3 | 153 | $NAME[$i] = preg_replace('/^V(\d+)$/', 'Probe $1', $NAME[$i]); |
596e2160 | 154 | |
155 | if ($visited_volt == 0) { | |
156 | ++$count; | |
157 | $visited_volt = 1; | |
158 | } | |
159 | $ds_name[$count] = "Voltage Probes"; | |
160 | $vlabel = "Volts"; | |
e1283fe3 | 161 | |
596e2160 | 162 | $title = $ds_name[$count]; |
e1283fe3 | 163 | |
596e2160 | 164 | $opt[$count] = "-X0 --lower-limit 0 --slope-mode --vertical-label \"$vlabel\" --title \"$def_title: $title\" "; |
165 | if(isset($def[$count])){ | |
166 | $def[$count] .= "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ; | |
e1283fe3 | 167 | } |
596e2160 | 168 | else { |
169 | $def[$count] = "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ; | |
e1283fe3 | 170 | } |
596e2160 | 171 | $def[$count] .= "LINE:var$i#".$colors[$v].":\"$NAME[$i]\" " ; |
596e2160 | 172 | $def[$count] .= "GPRINT:var$i:LAST:\"%4.2lf A last \" "; |
173 | $def[$count] .= "GPRINT:var$i:MAX:\"%4.2lf A max \" "; | |
174 | $def[$count] .= "GPRINT:var$i:AVERAGE:\"%4.4lf A avg \\n\" "; | |
175 | } | |
e1283fe3 | 176 | |
596e2160 | 177 | # FANS (RPMs) |
178 | if (preg_match('/^F/', $NAME[$i])) { | |
179 | if ($visited_fan == 0) { | |
180 | ++$count; | |
181 | $visited_fan = 1; | |
182 | } | |
183 | ||
184 | # Long label | |
0f49e9a3 | 185 | $NAME[$i] = preg_replace('/^F(\d+)_(.+)/', 'Probe $1 [$2]', $NAME[$i]); |
596e2160 | 186 | $NAME[$i] = preg_replace('/_/', ' ', $NAME[$i]); |
187 | ||
188 | # Short label | |
0f49e9a3 | 189 | $NAME[$i] = preg_replace('/^F(\d+)$/', 'Probe $1', $NAME[$i]); |
596e2160 | 190 | |
191 | $ds_name[$count] = "Fan Probes"; | |
192 | ||
193 | $opt[$count] = "-X0 --slope-mode --vertical-label \"RPMs\" --title \"$def_title: Fan Speeds\" "; | |
e1283fe3 | 194 | if(isset($def[$count])){ |
195 | $def[$count] .= "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ; | |
7e2aee73 | 196 | } |
e1283fe3 | 197 | else { |
198 | $def[$count] = "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ; | |
199 | } | |
596e2160 | 200 | $def[$count] .= "LINE:var$i#".$colors[$f++].":\"$NAME[$i]\" " ; |
201 | $def[$count] .= "GPRINT:var$i:LAST:\"%6.0lf RPM last \" "; | |
202 | $def[$count] .= "GPRINT:var$i:MAX:\"%6.0lf RPM max \" "; | |
203 | $def[$count] .= "GPRINT:var$i:AVERAGE:\"%6.2lf RPM avg \\n\" "; | |
e1283fe3 | 204 | } |
56821ab5 | 205 | |
e0f53839 | 206 | # ENCLOSURE TEMPERATURES (Celsius) |
596e2160 | 207 | if(preg_match('/^E(?P<id>.+?)_temp_\d+$/', $NAME[$i], $matches) |
53d72bba | 208 | || preg_match('/^E(?P<id>.+?)_t\d+$/', $NAME[$i], $matches)){ |
e1283fe3 | 209 | $this_id = $matches['id']; |
210 | ||
211 | if ($enclosure_id != $this_id) { | |
212 | $e = 0; | |
213 | ++$count; | |
214 | $enclosure_id = $this_id; | |
215 | } | |
216 | ||
217 | # Long label | |
0cccc975 | 218 | $NAME[$i] = preg_replace('/^E.+?_temp_(\d+)$/', 'Probe $1', $NAME[$i]); |
e1283fe3 | 219 | |
220 | # Short label | |
0f49e9a3 | 221 | $NAME[$i] = preg_replace('/^E.+?t(\d+)$/', 'Probe $1', $NAME[$i]); |
e1283fe3 | 222 | |
223 | $ds_name[$count] = "Enclosure $enclosure_id Temperatures"; | |
224 | ||
225 | $warnThresh = "INF"; | |
226 | $critThresh = "INF"; | |
227 | ||
228 | if ($WARN[$i] != "") { | |
229 | $warnThresh = $WARN[$i]; | |
230 | } | |
231 | if ($CRIT[$i] != "") { | |
232 | $critThresh = $CRIT[$i]; | |
233 | } | |
234 | ||
e0f53839 | 235 | $opt[$count] = "--slope-mode --vertical-label \"Celsius\" --title \"$def_title: Enclosure $enclosure_id Temperatures\" "; |
e1283fe3 | 236 | |
237 | if(isset($def[$count])){ | |
238 | $def[$count] .= "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ; | |
239 | } | |
240 | else { | |
241 | $def[$count] = "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ; | |
242 | } | |
243 | $def[$count] .= "LINE:var$i#".$colors[$e++].":\"$NAME[$i]\" " ; | |
e1283fe3 | 244 | $def[$count] .= "GPRINT:var$i:LAST:\"%6.0lf C last \" "; |
245 | $def[$count] .= "GPRINT:var$i:MAX:\"%6.0lf C max \" "; | |
246 | $def[$count] .= "GPRINT:var$i:AVERAGE:\"%6.2lf C avg \\n\" "; | |
247 | } | |
7e2aee73 | 248 | } |
249 | ?> |