]> git.uio.no Git - check_openmanage.git/blame - check_openmanage.php
pnp4nagios templates
[check_openmanage.git] / check_openmanage.php
CommitLineData
7e2aee73 1<?php
2
3#
4# check_openmanage 3.4.6
5#
6
7$colors = array("0022ff", "22ff22", "ff0000", "00aaaa", "ff00ff",
8 "ffa500", "cc0000", "0000cc", "0080C0", "8080C0",
9 "FF0080", "800080", "688e23", "408080", "808000",
10 "000000", "00FF00", "0080FF", "FF8000", "800000",
11 "FB31FB");
12
13
14$PWRcolor = "FFFF00";
15$AMPcolor = "ff00ff";
16
17# counters
18$count=0; # general counter
19$f = 0; # fan probe counter
20$t = 0; # temp probe counter
21$a = 0; # amp probe counter
22$e = 0; # enclosure counter
23
24# flags
25$visited_fan = 0;
26$visited_temp = 0;
27$visited_pwr = 0;
28
29# enclosure id
30$enclosure_id = '';
31
32# loop through the performance data
33foreach ($DS as $i) {
34
35 # AMPERAGE PROBE (Watts)
36 if(preg_match('/^pwr_mon_/',$NAME[$i]) && $UNIT[$i] == 'W') {
37 $NAME[$i] = preg_replace('/^pwr_mon_\d+_/', '', $NAME[$i]);
38
39 ++$count;
40 $ds_name[$count] = "Power Consumption";
41 $vlabel = "Watt";
42
43 $title = $ds_name[$count];
44
45 $opt[$count] = "--slope-mode --vertical-label \"$vlabel\" --title \"(Dell OMSA) $title\" ";
46
47 $def[$count] .= "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ;
48
49 $def[$count] .= "CDEF:c${i}shading2=var$i,0.98,* ";
50 $def[$count] .= "CDEF:c${i}shading10=var$i,0.90,* ";
51 $def[$count] .= "CDEF:c${i}shading15=var$i,0.85,* ";
52 $def[$count] .= "CDEF:c${i}shading20=var$i,0.80,* ";
53 $def[$count] .= "CDEF:c${i}shading25=var$i,0.75,* ";
54 $def[$count] .= "CDEF:c${i}shading30=var$i,0.70,* ";
55 $def[$count] .= "CDEF:c${i}shading35=var$i,0.65,* ";
56 $def[$count] .= "CDEF:c${i}shading40=var$i,0.60,* ";
57 $def[$count] .= "CDEF:c${i}shading45=var$i,0.55,* ";
58 $def[$count] .= "CDEF:c${i}shading50=var$i,0.50,* ";
59 $def[$count] .= "CDEF:c${i}shading55=var$i,0.45,* ";
60 $def[$count] .= "CDEF:c${i}shading60=var$i,0.40,* ";
61 $def[$count] .= "CDEF:c${i}shading65=var$i,0.35,* ";
62 $def[$count] .= "CDEF:c${i}shading70=var$i,0.30,* ";
63 $def[$count] .= "CDEF:c${i}shading75=var$i,0.25,* ";
64 $def[$count] .= "CDEF:c${i}shading80=var$i,0.20,* ";
65 $def[$count] .= "CDEF:c${i}shading85=var$i,0.15,* ";
66
67 $def[$count] .= "AREA:var$i#$PWRcolor:\"$NAME[$i]\" " ;
68
69 $def[$count] .= "AREA:c${i}shading2#F9000022: ";
70 $def[$count] .= "AREA:c${i}shading10#E1000011: ";
71 $def[$count] .= "AREA:c${i}shading15#D2000011: ";
72 $def[$count] .= "AREA:c${i}shading20#C3000011: ";
73 $def[$count] .= "AREA:c${i}shading25#B4000011: ";
74 $def[$count] .= "AREA:c${i}shading30#A5000011: ";
75 $def[$count] .= "AREA:c${i}shading35#96000011: ";
76 $def[$count] .= "AREA:c${i}shading40#87000011: ";
77 $def[$count] .= "AREA:c${i}shading45#78000011: ";
78 $def[$count] .= "AREA:c${i}shading50#69000011: ";
79 $def[$count] .= "AREA:c${i}shading55#5A000011: ";
80 $def[$count] .= "AREA:c${i}shading60#4B000011: ";
81 $def[$count] .= "AREA:c${i}shading65#3C000011: ";
82 $def[$count] .= "AREA:c${i}shading70#2D000011: ";
83 $def[$count] .= "AREA:c${i}shading75#18000011: ";
84 $def[$count] .= "AREA:c${i}shading80#0F000011: ";
85 $def[$count] .= "AREA:c${i}shading85#00000011: ";
86
87 $def[$count] .= "LINE:var$i#000000: " ;
88
89 $def[$count] .= "GPRINT:var$i:LAST:\"%6.0lf $UNIT[$i] last \" ";
90 $def[$count] .= "GPRINT:var$i:MAX:\"%6.0lf $UNIT[$i] max \" ";
91 $def[$count] .= "GPRINT:var$i:AVERAGE:\"%6.2lf $UNIT[$i] avg \\n\" ";
92 }
93
94 # AMPERAGE PROBES (Ampere)
95 if(preg_match('/^pwr_mon_/',$NAME[$i]) && $UNIT[$i] == 'A') {
96 $NAME[$i] = preg_replace('/^pwr_mon_\d+_/', '', $NAME[$i]);
97
98 if ($visited_pwr == 0) {
99 ++$count;
100 $visited_pwr = 1;
101 }
102 $ds_name[$count] = "Amperage Probe";
103 $vlabel = "Ampere";
104
105 $title = $ds_name[$count];
106
107 $opt[$count] = "-X0 --lower-limit 0 --slope-mode --vertical-label \"$vlabel\" --title \"(Dell OMSA) $title\" ";
108
109 $def[$count] .= "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ;
110 $def[$count] .= "LINE:var$i#".$colors[$a].":\"$NAME[$i]\" " ;
111 $def[$count] .= "AREA:var$i#".$colors[$a++]."20: " ;
112 $def[$count] .= "GPRINT:var$i:LAST:\"%4.2lf $UNIT[$i] last \" ";
113 $def[$count] .= "GPRINT:var$i:MAX:\"%4.2lf $UNIT[$i] max \" ";
114 $def[$count] .= "GPRINT:var$i:AVERAGE:\"%4.4lf $UNIT[$i] avg \\n\" ";
115 }
116
117 # FANS (RPMs)
118 if(preg_match('/^fan_/',$NAME[$i])){
119 if ($visited_fan == 0) {
120 ++$count;
121 $visited_fan = 1;
122 }
123
124 $NAME[$i] = preg_replace('/^fan_\d+_/', '', $NAME[$i]);
125 $NAME[$i] = preg_replace('/_rpm$/', '', $NAME[$i]);
126
127 $ds_name[$count] = "Fan Speed";
128
129 $opt[$count] = "-X0 --slope-mode --vertical-label \"RPMs\" --title \"(Dell OMSA) Fan Speeds\" ";
130
131 $def[$count] .= "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ;
132 $def[$count] .= "LINE:var$i#".$colors[$f++].":\"$NAME[$i]\" " ;
133 $def[$count] .= "GPRINT:var$i:LAST:\"%6.0lf RPM last \" ";
134 $def[$count] .= "GPRINT:var$i:MAX:\"%6.0lf RPM max \" ";
135 $def[$count] .= "GPRINT:var$i:AVERAGE:\"%6.2lf RPM avg \\n\" ";
136 }
137
138 # TEMPERATURES (Celcius)
139 if(preg_match('/^temp_/',$NAME[$i])){
140 if ($visited_temp == 0) {
141 ++$count;
142 $visited_temp = 1;
143 }
144 $NAME[$i] = preg_replace('/^temp_\d+_/', '', $NAME[$i]);
145
146 $ds_name[$count] = "Chassis Temperatures";
147
148 $warnThresh = "INF";
149 $critThresh = "INF";
150
151 if ($WARN[$i] != "") {
152 $warnThresh = $WARN[$i];
153 }
154 if ($CRIT[$i] != "") {
155 $critThresh = $CRIT[$i];
156 }
157
158 $opt[$count] = "--slope-mode --vertical-label \"Celcius\" --title \"(Dell OMSA) Chassis Temperatures\" ";
159
160 $def[$count] .= "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ;
161 $def[$count] .= "LINE:var$i#".$colors[$t++].":\"$NAME[$i]\" " ;
162
163 $def[$count] .= "GPRINT:var$i:LAST:\"%6.0lf $UNIT[$i] last \" ";
164 $def[$count] .= "GPRINT:var$i:MAX:\"%6.0lf $UNIT[$i] max \" ";
165 $def[$count] .= "GPRINT:var$i:AVERAGE:\"%6.2lf $UNIT[$i] avg \\n\" ";
166 }
167
168 # ENCLOSURE TEMPERATURES (Celcius)
169 if(preg_match('/^enclosure_(?<id>.+?)_temp_\d+$/', $NAME[$i], $matches)){
170 $this_id = $matches['id'];
171
172 if ($enclosure_id != $this_id) {
173 $e = 0;
174 ++$count;
175 $enclosure_id = $this_id;
176 }
177 $NAME[$i] = preg_replace('/^enclosure_.+?_temp_(\d+)$/', 'Probe $1', $NAME[$i]);
178
179 $ds_name[$count] = "Enclosure $enclosure_id Temperatures";
180
181 $warnThresh = "INF";
182 $critThresh = "INF";
183
184 if ($WARN[$i] != "") {
185 $warnThresh = $WARN[$i];
186 }
187 if ($CRIT[$i] != "") {
188 $critThresh = $CRIT[$i];
189 }
190
191 $opt[$count] = "--slope-mode --vertical-label \"Celcius\" --title \"(Dell OMSA) Enclosure $enclosure_id Temperatures\" ";
192
193 $def[$count] .= "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ;
194 $def[$count] .= "LINE:var$i#".$colors[$e++].":\"$NAME[$i]\" " ;
195
196 $def[$count] .= "GPRINT:var$i:LAST:\"%6.0lf $UNIT[$i] last \" ";
197 $def[$count] .= "GPRINT:var$i:MAX:\"%6.0lf $UNIT[$i] max \" ";
198 $def[$count] .= "GPRINT:var$i:AVERAGE:\"%6.2lf $UNIT[$i] avg \\n\" ";
199 }
200
201}
202?>