Refactoring: Moved check parameters from unsorted.py to dedicated modules (CMK-1393)
[check_mk.git] / pnp-templates / check_mk-ps.perf.php
blob3c409f4687b69396756a165bec6f9061a303de58
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 # The number of data source various due to different
27 # settings (such as averaging). We rather work with names
28 # than with numbers.
29 $RRD = array();
30 foreach ($NAME as $i => $n) {
31 $RRD[$n] = "$RRDFILE[$i]:$DS[$i]:MAX";
32 $WARN[$n] = $WARN[$i];
33 $CRIT[$n] = $CRIT[$i];
34 $MIN[$n] = $MIN[$i];
35 $MAX[$n] = $MAX[$i];
39 # 1. Graph: Number of processes
40 $vertical = "count";
41 $format = "%3.0lf";
42 $upto = max(20, $CRIT["count"]);
43 $color = "8040f0";
44 $line = "202060";
46 $opt[1] = " --vertical-label \"count\" -X0 -L5 -l 0 -u $upto --title \"Number of Processes\" ";
48 $def[1] = ""
49 . "DEF:count=$RRD[count] "
50 . "AREA:count#$color:\"Processes\" "
51 . "LINE1:count#$line:\"\" "
52 . "GPRINT:count:LAST:\"Current\: $format\" "
53 . "GPRINT:count:MAX:\"Maximum\: $format \" "
54 . "HRULE:$WARN[count]#FFFF00:\"Warning at $WARN[count]\" "
55 . "HRULE:$CRIT[count]#FF0000:\"Critical at $CRIT[count]\" "
58 # 2. Graph: Memory usage
59 if (isset($RRD["vsz"])) {
60 $opt[2] = " --vertical-label \"MB\" -l 0 --title \"Memory Usage for all Processes\" ";
61 $def[2] = ""
62 . "DEF:count=$RRD[count] "
63 . "DEF:vsz=$RRD[vsz] "
64 . "DEF:rss=$RRD[rss] "
65 . "CDEF:vszmb=vsz,1024,/,count,/ "
66 . "CDEF:rssmb=rss,1024,/,count,/ "
67 . "AREA:vszmb#90a0f0:\"Virtual size \" "
68 . "GPRINT:vszmb:LAST:\"Current\: %5.1lf MB\" "
69 . "GPRINT:vszmb:MIN:\"Min\: %5.1lf MB\" "
70 . "GPRINT:vszmb:MAX:\"Max\: %5.1lf MB\" "
71 . "AREA:rssmb#2070ff:\"Resident size\" "
72 . "GPRINT:rssmb:LAST:\"Current\: %5.1lf MB\" "
73 . "GPRINT:rssmb:MIN:\"Min\: %5.1lf MB\" "
74 . "GPRINT:rssmb:MAX:\"Max\: %5.1lf MB\" "
78 if (isset($RRD["pcpu"])) {
79 $opt[3] = " --vertical-label \"CPU(%)\" -l 0 -u 100 --title \"CPU Usage for all Processes\" ";
80 $def[3] = ""
81 . "DEF:pcpu=$RRD[pcpu] "
82 . "AREA:pcpu#30ff80:\"CPU usage (%) \" "
83 . "LINE:pcpu#20a060:\"\" "
84 . "GPRINT:pcpu:LAST:\"Current\: %4.1lf%%\" "
85 . "GPRINT:pcpu:MIN:\"Min\: %4.1lf%%\" "
86 . "GPRINT:pcpu:MAX:\"Max\: %4.1lf%%\\n\" ";
88 if ($WARN['pcpu'] != '')
89 $def[3] .= "HRULE:$WARN[pcpu]#FFFF00:\"Warning at $WARN[pcpu]%\" ";
90 if ($CRIT['pcpu'] != '')
91 $def[3] .= "HRULE:$CRIT[pcpu]#FF0000:\"Critical at $CRIT[pcpu]%\" ";
93 if (isset($RRD["pcpuavg"])) {
94 $def[3] .= "DEF:pcpuavg=$RRD[pcpuavg] ";
95 $def[3] .= "LINE:pcpuavg#000000:\"Average over $MAX[pcpuavg] minutes\\n\" ";