Refactoring: Moved check parameters from unsorted.py to dedicated modules (CMK-1393)
[check_mk.git] / pnp-templates / check_mk-if.php
blobbe496de2aebb8e45f0a248c61065f02f12dfba25
1 <?php
2 # +------------------------------------------------------------------+
3 # | ____ _ _ __ __ _ __ |
4 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
5 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
6 # | | |___| | | | __/ (__| < | | | | . \ |
7 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
8 # | |
9 # | Copyright Mathias Kettner 2014 mk@mathias-kettner.de |
10 # +------------------------------------------------------------------+
12 # This file is part of Check_MK.
13 # The official homepage is at http://mathias-kettner.de/check_mk.
15 # check_mk is free software; you can redistribute it and/or modify it
16 # under the terms of the GNU General Public License as published by
17 # the Free Software Foundation in version 2. check_mk is distributed
18 # in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
19 # out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
20 # PARTICULAR PURPOSE. See the GNU General Public License for more de-
21 # tails. You should have received a copy of the GNU General Public
22 # License along with GNU Make; see the file COPYING. If not, write
23 # to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
24 # Boston, MA 02110-1301 USA.
26 setlocale(LC_ALL, 'C');
28 # Performance data from check:
29 # in=6864.39071505;0.01;0.1;0;125000000.0
30 # inucast=48.496962273;0.01;0.1;;
31 # innucast=4.60122981717;0.01;0.1;;
32 # indisc=0.0;0.01;0.1;;
33 # inerr=0.0;0.01;0.1;;
34 # out=12448.259172;0.01;0.1;0;125000000.0
35 # outucast=54.9846963152;0.01;0.1;;
36 # outnucast=10.5828285795;0.01;0.1;;
37 # outdisc=0.0;0.01;0.1;;
38 # outerr=0.0;0.01;0.1;;
39 # outqlen=0;;;;10000000
41 # Graph 1: used bandwidth
43 # Determine if Bit or Byte. Bit is signalled via a min value of 0.0
44 # in the 11th performance value.
45 if (!strcmp($MIN[11], "0.0")) {
46 $unit = "Bit";
47 $unit_multiplier = 8;
48 $base = 1000; // Megabit is 1000 * 1000
50 else {
51 $unit = "B";
52 $unit_multiplier = 1;
53 $base = 1000; // Megabyte is 1000 * 1000
56 # Convert bytes to bits if neccessary
57 $bandwidth = $MAX[1] != "" ? $MAX[1] * $unit_multiplier : 0;
58 $warn = $WARN[1] != "" ? $WARN[1] * $unit_multiplier : 0;
59 $crit = $CRIT[1] != "" ? $CRIT[1] * $unit_multiplier : 0;
61 # Now choose a convenient scale, based on the known bandwith of
62 # the interface, and break down bandwidth, warn and crit by that
63 # scale.
64 $bwuom = ' ';
65 if ($bandwidth > $base * $base * $base) {
66 $scale = $base * $base * $base;
67 $bwuom = 'G';
69 elseif ($bandwidth > $base * $base) {
70 $scale = $base * $base;
71 $bwuom = 'M';
73 elseif ($bandwidth > $base) {
74 $scale = $base;
75 $bwuom = 'k';
77 else {
78 $scale = 1;
79 $bwuom = ' ';
82 $warn /= $scale;
83 $crit /= $scale;
84 $bandwidth /= $scale;
86 $vertical_label_name = $bwuom . $unit . "/sec";
88 $range = min(10, $bandwidth);
91 $bandwidthInfo = "";
92 if ($bandwidth > 0){
93 $bandwidthInfo = " at " . sprintf("%.1f", $bandwidth) . " ${bwuom}${unit}/s";
95 $ds_name[1] = 'Used bandwidth';
96 $opt[1] = "--vertical-label \"$vertical_label_name\" -l -$range -u $range -X0 -b 1024 --title \"Used bandwidth $hostname / $servicedesc$bandwidthInfo\" ";
97 $def[1] =
98 "HRULE:0#c0c0c0 ";
99 if ($bandwidth)
100 $def[1] .= "HRULE:$bandwidth#808080:\"Port speed\: " . sprintf("%10.1f", $bandwidth) . " ".$bwuom."$unit/s\\n\" ".
101 "HRULE:-$bandwidth#808080: ";
102 if ($warn)
103 $def[1] .= "HRULE:$warn#ffff00:\"Warning\: " . sprintf("%13.1f", $warn) . " ".$bwuom."$unit/s\\n\" ".
104 "HRULE:-$warn#ffff00: ";
105 if ($crit)
106 $def[1] .= "HRULE:$crit#ff0000:\"Critical\: " . sprintf("%13.1f", $crit) . " ".$bwuom."$unit/s\\n\" ".
107 "HRULE:-$crit#ff0000: ";
109 $def[1] .= "".
110 # incoming
111 "DEF:inbytes=$RRDFILE[1]:$DS[1]:MAX ".
112 "CDEF:intraffic=inbytes,$unit_multiplier,* ".
113 "CDEF:inmb=intraffic,$scale,/ ".
114 "AREA:inmb#00e060:\"in \" ".
115 "GPRINT:intraffic:LAST:\"%7.1lf %s$unit/s last\" ".
116 "GPRINT:intraffic:AVERAGE:\"%7.1lf %s$unit/s avg\" ".
117 "GPRINT:intraffic:MAX:\"%7.1lf %s$unit/s max\\n\" ".
118 "VDEF:inperc=intraffic,95,PERCENTNAN ".
119 "VDEF:inpercmb=inmb,95,PERCENTNAN ".
120 "LINE:inpercmb#008f00:\"95% percentile\" ".
121 "GPRINT:inperc:\"%7.1lf %s$unit/s\\n\" ".
123 # outgoing
124 "DEF:outbytes=$RRDFILE[6]:$DS[6]:MAX ".
125 "CDEF:outtraffic=outbytes,$unit_multiplier,* ".
126 "CDEF:minusouttraffic=outtraffic,-1,* ".
127 "CDEF:outmb=outtraffic,$scale,/ ".
128 "CDEF:minusoutmb=0,outmb,- ".
129 "AREA:minusoutmb#0080e0:\"out \" ".
130 "GPRINT:outtraffic:LAST:\"%7.1lf %s$unit/s last\" ".
131 "GPRINT:outtraffic:AVERAGE:\"%7.1lf %s$unit/s avg\" ".
132 "GPRINT:outtraffic:MAX:\"%7.1lf %s$unit/s max\\n\" ".
133 "VDEF:outperc=minusouttraffic,5,PERCENTNAN ".
134 "VDEF:outpercmb=minusoutmb,5,PERCENTNAN ".
135 "LINE:outpercmb#00008f:\"95% percentile\" ".
136 "GPRINT:outperc:\"%7.1lf %s$unit/s\\n\" ".
140 if (isset($DS[12])) {
141 $def[1] .=
142 "DEF:inbytesa=$RRDFILE[12]:$DS[12]:MAX ".
143 "DEF:outbytesa=$RRDFILE[13]:$DS[13]:MAX ".
144 "CDEF:intraffica=inbytesa,$unit_multiplier,* ".
145 "CDEF:outtraffica=outbytesa,$unit_multiplier,* ".
146 "CDEF:inmba=intraffica,$scale,/ ".
147 "CDEF:outmba=outtraffica,$scale,/ ".
148 "CDEF:minusoutmba=0,outmba,- ".
149 "LINE:inmba#00a060:\"in (avg) \" ".
150 "GPRINT:intraffica:LAST:\"%6.1lf %s$unit/s last\" ".
151 "GPRINT:intraffica:AVERAGE:\"%6.1lf %s$unit/s avg\" ".
152 "GPRINT:intraffica:MAX:\"%6.1lf %s$unit/s max\\n\" ".
153 "LINE:minusoutmba#0060c0:\"out (avg) \" ".
154 "GPRINT:outtraffica:LAST:\"%6.1lf %s$unit/s last\" ".
155 "GPRINT:outtraffica:AVERAGE:\"%6.1lf %s$unit/s avg\" ".
156 "GPRINT:outtraffica:MAX:\"%6.1lf %s$unit/s max\\n\" ";
159 # Graph 2: packets
160 $ds_name[2] = 'Packets';
161 $opt[2] = "--vertical-label \"packets/sec\" --title \"Packets $hostname / $servicedesc\" ";
162 $def[2] =
163 # ingoing
164 "HRULE:0#c0c0c0 ".
165 "DEF:inu=$RRDFILE[2]:$DS[2]:MAX ".
166 "DEF:innu=$RRDFILE[3]:$DS[3]:MAX ".
167 "CDEF:in=inu,innu,+ ".
168 "AREA:inu#00ffc0:\"in unicast \" ".
169 "GPRINT:inu:LAST:\"%9.1lf/s last \" ".
170 "GPRINT:inu:AVERAGE:\"%9.1lf/s avg \" ".
171 "GPRINT:inu:MAX:\"%9.1lf/s max\\n\" ".
172 "AREA:innu#00c080:\"in broadcast/multicast \":STACK ".
173 "GPRINT:innu:LAST:\"%9.1lf/s last \" ".
174 "GPRINT:innu:AVERAGE:\"%9.1lf/s avg \" ".
175 "GPRINT:innu:MAX:\"%9.1lf/s max\\n\" ".
176 "VDEF:inperc=in,95,PERCENTNAN ".
177 "LINE:inperc#00cf00:\"in 95% percentile \" ".
178 "GPRINT:inperc:\"%9.1lf/s\\n\" ".
180 # outgoing
181 "DEF:outu=$RRDFILE[7]:$DS[7]:MAX ".
182 "DEF:outnu=$RRDFILE[8]:$DS[8]:MAX ".
183 "CDEF:minusoutu=0,outu,- ".
184 "CDEF:minusoutnu=0,outnu,- ".
185 "CDEF:minusout=minusoutu,minusoutnu,+ ".
186 "AREA:minusoutu#00c0ff:\"out unicast \" ".
187 "GPRINT:outu:LAST:\"%9.1lf/s last \" ".
188 "GPRINT:outu:AVERAGE:\"%9.1lf/s avg \" ".
189 "GPRINT:outu:MAX:\"%9.1lf/s max\\n\" ".
190 "AREA:minusoutnu#0080c0:\"out broadcast/multicast\":STACK ".
191 "GPRINT:outnu:LAST:\"%9.1lf/s last \" ".
192 "GPRINT:outnu:AVERAGE:\"%9.1lf/s avg \" ".
193 "GPRINT:outnu:MAX:\"%9.1lf/s max\\n\" ".
194 "VDEF:outperc=minusout,5,PERCENTNAN ".
195 "LINE:outperc#0000cf:\"out 95% percentile \" ".
196 "GPRINT:outperc:\"%9.1lf/s\\n\" ".
199 # Graph 3: errors and discards
200 $ds_name[3] = 'Errors and discards';
201 $opt[3] = "--vertical-label \"packets/sec\" -X0 --title \"Problems $hostname / $servicedesc\" ";
202 $def[3] =
203 "HRULE:0#c0c0c0 ".
204 "DEF:inerr=$RRDFILE[5]:$DS[5]:MAX ".
205 "DEF:indisc=$RRDFILE[4]:$DS[4]:MAX ".
206 "AREA:inerr#ff0000:\"in errors \" ".
207 "GPRINT:inerr:LAST:\"%7.2lf/s last \" ".
208 "GPRINT:inerr:AVERAGE:\"%7.2lf/s avg \" ".
209 "GPRINT:inerr:MAX:\"%7.2lf/s max\\n\" ".
210 "AREA:indisc#ff8000:\"in discards \":STACK ".
211 "GPRINT:indisc:LAST:\"%7.2lf/s last \" ".
212 "GPRINT:indisc:AVERAGE:\"%7.2lf/s avg \" ".
213 "GPRINT:indisc:MAX:\"%7.2lf/s max\\n\" ".
214 "DEF:outerr=$RRDFILE[10]:$DS[10]:MAX ".
215 "DEF:outdisc=$RRDFILE[9]:$DS[9]:MAX ".
216 "CDEF:minusouterr=0,outerr,- ".
217 "CDEF:minusoutdisc=0,outdisc,- ".
218 "AREA:minusouterr#ff0080:\"out errors \" ".
219 "GPRINT:outerr:LAST:\"%7.2lf/s last \" ".
220 "GPRINT:outerr:AVERAGE:\"%7.2lf/s avg \" ".
221 "GPRINT:outerr:MAX:\"%7.2lf/s max\\n\" ".
222 "AREA:minusoutdisc#ff8080:\"out discards \":STACK ".
223 "GPRINT:outdisc:LAST:\"%7.2lf/s last \" ".
224 "GPRINT:outdisc:AVERAGE:\"%7.2lf/s avg \" ".
225 "GPRINT:outdisc:MAX:\"%7.2lf/s max\\n\" ";