Refactoring: Changed remaining check parameters starting with an 's' to the new rules...
[check_mk.git] / pnp-templates / template-diskstat.php
bloba1dfaa2988e95bd63518538fa922710c2bb96c0d
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 // new version of diskstat
27 if (isset($DS[2])) {
29 // Make data sources available via names
30 $RRD = array();
31 foreach ($NAME as $i => $n) {
32 $RRD[$n] = "$RRDFILE[$i]:$DS[$i]:MAX";
33 $WARN[$n] = $WARN[$i];
34 $CRIT[$n] = $CRIT[$i];
35 $MIN[$n] = $MIN[$i];
36 $MAX[$n] = $MAX[$i];
39 $parts = explode("_", $servicedesc);
40 $disk = $parts[2];
42 $opt[1] = "--vertical-label 'Throughput (MB/s)' -X0 --title \"Disk throughput $hostname / $disk\" ";
44 $def[1] =
45 "HRULE:0#a0a0a0 ".
46 # read
47 "DEF:read=$RRD[read] ".
48 "CDEF:read_mb=read,1048576,/ ".
49 "AREA:read_mb#40c080:\"Read \" ".
50 "GPRINT:read_mb:LAST:\"%8.1lf MB/s last\" ".
51 "GPRINT:read_mb:AVERAGE:\"%6.1lf MB/s avg\" ".
52 "GPRINT:read_mb:MAX:\"%6.1lf MB/s max\\n\" ";
54 # read average as line in the same graph
55 if (isset($RRD["read.avg"])) {
56 $def[1] .=
57 "DEF:read_avg=${RRD['read.avg']} ".
58 "CDEF:read_avg_mb=read_avg,1048576,/ ".
59 "LINE:read_avg_mb#202020 ";
62 # write
63 $def[1] .=
64 "DEF:write=$RRD[write] ".
65 "CDEF:write_mb=write,1048576,/ ".
66 "CDEF:write_mb_neg=write_mb,-1,* ".
67 "AREA:write_mb_neg#4080c0:\"Write \" ".
68 "GPRINT:write_mb:LAST:\"%6.1lf MB/s last\" ".
69 "GPRINT:write_mb:AVERAGE:\"%6.1lf MB/s avg\" ".
70 "GPRINT:write_mb:MAX:\"%6.1lf MB/s max\\n\" ".
71 "";
73 # show levels for read
74 if ($WARN['read']) {
75 $def[1] .= "HRULE:$WARN[read]#ffd000:\"Warning for read at " . sprintf("%6.1f", $WARN[1]) . " MB/s \" ";
76 $def[1] .= "HRULE:$CRIT[read]#ff0000:\"Critical for read at " . sprintf("%6.1f", $CRIT[1]) . " MB/s\\n\" ";
79 # show levels for write
80 if ($WARN['write']) {
81 $def[1] .= "HRULE:-$WARN[write]#ffd000:\"Warning for write at " . sprintf("%6.1f", $WARN[2]) . " MB/s \" ";
82 $def[1] .= "HRULE:-$CRIT[write]#ff0000:\"Critical for write at " . sprintf("%6.1f", $CRIT[2]) . " MB/s\\n\" ";
85 # write average
86 if (isset($DS["write.avg"])) {
87 $def[1] .=
88 "DEF:write_avg=${RRD['write.avg']} ".
89 "CDEF:write_avg_mb=write_avg,1048576,/ ".
90 "CDEF:write_avg_mb_neg=write_avg_mb,-1,* ".
91 "LINE:write_avg_mb_neg#202020 ";
94 # latency
95 if (isset($RRD["latency"])) {
96 $opt[] = "--vertical-label 'Latency (ms)' -X0 --title \"Latency $hostname / $disk\" ";
97 $def[] = ""
98 . "DEF:latency=$RRD[latency] "
99 . "AREA:latency#aaccdd:\"Latency\" "
100 . "LINE:latency#7799aa "
101 . "GPRINT:latency:LAST:\"%6.1lf ms last\" "
102 . "GPRINT:latency:AVERAGE:\"%6.1lf ms avg\" "
103 . "GPRINT:latency:MAX:\"%6.1lf ms max\\n\" "
107 # IOs per second
108 if (isset($RRD["ios"])) {
109 $opt[] = "--vertical-label 'IO Operations / sec' -X0 --title \"IOs/sec $hostname / $disk\" ";
110 $def[] = ""
111 . "DEF:ios=$RRD[ios] "
112 . "AREA:ios#ddccaa:\"ios\" "
113 . "LINE:ios#aa9977 "
114 . "GPRINT:ios:LAST:\"%6.1lf/sec last\" "
115 . "GPRINT:ios:AVERAGE:\"%6.1lf/sec avg\" "
116 . "GPRINT:ios:MAX:\"%6.1lf/sec max\\n\" "
120 if (isset($RRD["read_ql"])) {
121 $opt[] = "--vertical-label 'Queue Length' -X0 -u5 -l-5 --title \"Queue Length $hostname / $disk\" ";
122 $def[] = ""
123 . "DEF:read=$RRD[read_ql] "
124 . "DEF:write=$RRD[write_ql] "
125 . "CDEF:writen=write,-1,* "
126 . "HRULE:0#a0a0a0 "
127 . "AREA:read#669a76 "
128 . "AREA:writen#517ba5 "
135 // legacy version of diskstat
136 else {
137 $opt[1] = "--vertical-label 'Througput (MByte/s)' -l0 -u 1 --title \"Disk throughput $hostname / $servicedesc\" ";
139 $def[1] = "DEF:kb=$RRDFILE[1]:$DS[1]:AVERAGE " ;
140 $def[1] .= "CDEF:mb=kb,1024,/ " ;
141 $def[1] .= "AREA:mb#40c080 " ;
142 "HRULE:0#a0a0a0 ".
143 $def[1] .= "GPRINT:mb:LAST:\"%6.1lf MByte/s last\" " ;
144 $def[1] .= "GPRINT:mb:AVERAGE:\"%6.1lf MByte/s avg\" " ;
145 $def[1] .= "GPRINT:mb:MAX:\"%6.1lf MByte/s max\\n\" ";