]>
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 | |
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 | 38 | foreach ($DS as $i) { |
7e2aee73 | 39 | |
e1283fe3 | 40 | # AMPERAGE PROBE |
41 | if(preg_match('/^pwr_mon_/', $NAME[$i]) || preg_match('/^p\d+[aw]$/', $NAME[$i])) { | |
42 | ||
43 | # Watt | |
44 | if (preg_match('/system/', $NAME[$i]) || preg_match('/^p\d+w$/', $NAME[$i])) { | |
45 | ||
46 | # Long label | |
47 | $NAME[$i] = preg_replace('/^pwr_mon_\d+_/', '', $NAME[$i]); | |
48 | $NAME[$i] = preg_replace('/_/', ' ', $NAME[$i]); | |
49 | ||
50 | # Short label | |
51 | $NAME[$i] = preg_replace('/^p(\d+)w$/', 'Power Probe $1', $NAME[$i]); | |
52 | ||
53 | ++$count; | |
54 | $ds_name[$count] = "Power Consumption"; | |
55 | $vlabel = "Watt"; | |
56 | ||
57 | $title = $ds_name[$count]; | |
58 | ||
59 | $opt[$count] = "--slope-mode --vertical-label \"$vlabel\" --title \"$def_title: $title\" "; | |
60 | ||
42aa52ff | 61 | if(isset($def[$count])){ |
62 | $def[$count] .= "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ; | |
63 | } | |
64 | else { | |
65 | $def[$count] = "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ; | |
66 | } | |
e1283fe3 | 67 | $def[$count] .= "AREA:var$i#$PWRcolor:\"$NAME[$i]\" " ; |
68 | $def[$count] .= "LINE:var$i#000000: " ; | |
69 | $def[$count] .= "GPRINT:var$i:LAST:\"%6.0lf W last \" "; | |
70 | $def[$count] .= "GPRINT:var$i:MAX:\"%6.0lf W max \" "; | |
71 | $def[$count] .= "GPRINT:var$i:AVERAGE:\"%6.2lf W avg \\n\" "; | |
72 | } | |
73 | # Ampere | |
74 | elseif (preg_match('/current/', $NAME[$i]) || preg_match('/^p\d+a$/', $NAME[$i])) { | |
75 | ||
76 | # Long label | |
77 | $NAME[$i] = preg_replace('/^pwr_mon_\d+_/', '', $NAME[$i]); | |
78 | $NAME[$i] = preg_replace('/_/', ' ', $NAME[$i]); | |
79 | $NAME[$i] = preg_replace('/ current \d+$/', '', $NAME[$i]); | |
80 | $NAME[$i] = preg_replace('/ps/', 'PowerSupply', $NAME[$i]); | |
81 | ||
82 | # Short label | |
83 | $NAME[$i] = preg_replace('/^p(\d+)a$/', 'Amperage Probe $1', $NAME[$i]); | |
56821ab5 | 84 | |
e1283fe3 | 85 | if ($visited_pwr == 0) { |
56821ab5 | 86 | ++$count; |
e1283fe3 | 87 | $visited_pwr = 1; |
88 | } | |
89 | $ds_name[$count] = "Amperage Probes"; | |
90 | $vlabel = "Ampere"; | |
91 | ||
92 | $title = $ds_name[$count]; | |
93 | ||
94 | $opt[$count] = "-X0 --lower-limit 0 --slope-mode --vertical-label \"$vlabel\" --title \"$def_title: $title\" "; | |
95 | if(isset($def[$count])){ | |
96 | $def[$count] .= "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ; | |
97 | } | |
98 | else { | |
56821ab5 | 99 | $def[$count] = "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ; |
e1283fe3 | 100 | } |
101 | $def[$count] .= "LINE:var$i#".$colors[$a].":\"$NAME[$i]\" " ; | |
102 | $def[$count] .= "AREA:var$i#".$colors[$a++]."20: " ; | |
103 | $def[$count] .= "GPRINT:var$i:LAST:\"%4.2lf A last \" "; | |
104 | $def[$count] .= "GPRINT:var$i:MAX:\"%4.2lf A max \" "; | |
105 | $def[$count] .= "GPRINT:var$i:AVERAGE:\"%4.4lf A avg \\n\" "; | |
7e2aee73 | 106 | } |
e1283fe3 | 107 | } |
108 | ||
109 | # FANS (RPMs) | |
110 | if(preg_match('/^fan_/', $NAME[$i]) || preg_match('/^f\d+$/', $NAME[$i])){ | |
111 | if ($visited_fan == 0) { | |
112 | ++$count; | |
113 | $visited_fan = 1; | |
7e2aee73 | 114 | } |
e1283fe3 | 115 | |
116 | # Long label | |
117 | $NAME[$i] = preg_replace('/^fan_\d+_/', '', $NAME[$i]); | |
118 | $NAME[$i] = preg_replace('/_rpm$/', '', $NAME[$i]); | |
119 | $NAME[$i] = preg_replace('/_/', ' ', $NAME[$i]); | |
120 | ||
121 | # Short label | |
122 | $NAME[$i] = preg_replace('/^f(\d+)$/', 'Fan Probe $1', $NAME[$i]); | |
123 | ||
124 | $ds_name[$count] = "Fan Speed"; | |
125 | ||
126 | $opt[$count] = "-X0 --slope-mode --vertical-label \"RPMs\" --title \"$def_title: Fan Speeds\" "; | |
127 | if(isset($def[$count])){ | |
128 | $def[$count] .= "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ; | |
7e2aee73 | 129 | } |
e1283fe3 | 130 | else { |
131 | $def[$count] = "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ; | |
7e2aee73 | 132 | } |
e1283fe3 | 133 | $def[$count] .= "LINE:var$i#".$colors[$f++].":\"$NAME[$i]\" " ; |
134 | $def[$count] .= "GPRINT:var$i:LAST:\"%6.0lf RPM last \" "; | |
135 | $def[$count] .= "GPRINT:var$i:MAX:\"%6.0lf RPM max \" "; | |
136 | $def[$count] .= "GPRINT:var$i:AVERAGE:\"%6.2lf RPM avg \\n\" "; | |
137 | } | |
56821ab5 | 138 | |
e1283fe3 | 139 | # TEMPERATURES (Celcius) |
140 | if(preg_match('/^temp_/', $NAME[$i]) || preg_match('/^t\d+$/', $NAME[$i])){ | |
141 | if ($visited_temp == 0) { | |
142 | ++$count; | |
143 | $visited_temp = 1; | |
144 | } | |
145 | ||
146 | # Long label | |
147 | $NAME[$i] = preg_replace('/^temp_\d+_/', '', $NAME[$i]); | |
148 | $NAME[$i] = preg_replace('/_/', ' ', $NAME[$i]); | |
149 | ||
150 | # Short label | |
151 | $NAME[$i] = preg_replace('/^t(\d+)$/', 'Temperature Probe $1', $NAME[$i]); | |
152 | ||
153 | $ds_name[$count] = "Chassis Temperatures"; | |
154 | ||
155 | $warnThresh = "INF"; | |
156 | $critThresh = "INF"; | |
157 | ||
158 | if ($WARN[$i] != "") { | |
159 | $warnThresh = $WARN[$i]; | |
160 | } | |
161 | if ($CRIT[$i] != "") { | |
162 | $critThresh = $CRIT[$i]; | |
163 | } | |
164 | ||
165 | $opt[$count] = "--slope-mode --vertical-label \"Celcius\" --title \"$def_title: Chassis Temperatures\" "; | |
166 | if(isset($def[$count])){ | |
167 | $def[$count] .= "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ; | |
7e2aee73 | 168 | } |
e1283fe3 | 169 | else { |
170 | $def[$count] = "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ; | |
171 | } | |
172 | $def[$count] .= "LINE:var$i#".$colors[$t++].":\"$NAME[$i]\" " ; | |
e1283fe3 | 173 | $def[$count] .= "GPRINT:var$i:LAST:\"%6.0lf C last \" "; |
174 | $def[$count] .= "GPRINT:var$i:MAX:\"%6.0lf C max \" "; | |
175 | $def[$count] .= "GPRINT:var$i:AVERAGE:\"%6.2lf C avg \\n\" "; | |
176 | } | |
56821ab5 | 177 | |
e1283fe3 | 178 | # ENCLOSURE TEMPERATURES (Celcius) |
179 | if(preg_match('/^enclosure_(?<id>.+?)_temp_\d+$/', $NAME[$i], $matches) | |
180 | || preg_match('/^e(?<id>.+?)t\d+$/', $NAME[$i], $matches)){ | |
181 | $this_id = $matches['id']; | |
182 | ||
183 | if ($enclosure_id != $this_id) { | |
184 | $e = 0; | |
185 | ++$count; | |
186 | $enclosure_id = $this_id; | |
187 | } | |
188 | ||
189 | # Long label | |
190 | $NAME[$i] = preg_replace('/^enclosure_.+?_temp_(\d+)$/', 'Probe $1', $NAME[$i]); | |
191 | ||
192 | # Short label | |
193 | $NAME[$i] = preg_replace('/^e.+?t(\d+)$/', 'Probe $1', $NAME[$i]); | |
194 | ||
195 | $ds_name[$count] = "Enclosure $enclosure_id Temperatures"; | |
196 | ||
197 | $warnThresh = "INF"; | |
198 | $critThresh = "INF"; | |
199 | ||
200 | if ($WARN[$i] != "") { | |
201 | $warnThresh = $WARN[$i]; | |
202 | } | |
203 | if ($CRIT[$i] != "") { | |
204 | $critThresh = $CRIT[$i]; | |
205 | } | |
206 | ||
207 | $opt[$count] = "--slope-mode --vertical-label \"Celcius\" --title \"$def_title: Enclosure $enclosure_id Temperatures\" "; | |
208 | ||
209 | if(isset($def[$count])){ | |
210 | $def[$count] .= "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ; | |
211 | } | |
212 | else { | |
213 | $def[$count] = "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ; | |
214 | } | |
215 | $def[$count] .= "LINE:var$i#".$colors[$e++].":\"$NAME[$i]\" " ; | |
e1283fe3 | 216 | $def[$count] .= "GPRINT:var$i:LAST:\"%6.0lf C last \" "; |
217 | $def[$count] .= "GPRINT:var$i:MAX:\"%6.0lf C max \" "; | |
218 | $def[$count] .= "GPRINT:var$i:AVERAGE:\"%6.2lf C avg \\n\" "; | |
219 | } | |
7e2aee73 | 220 | } |
221 | ?> |