Refactoring: Moved check parameters from unsorted.py to dedicated modules (CMK-1393)
[check_mk.git] / pnp-templates / check_mk-mem.used.php
blobfbc619d09509232b27e0f2d2bd1455e6be160706
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 $opt[1] = "--vertical-label 'MEMORY(MB)' -X0 --upper-limit " . ($MAX[1] * 120 / 100) . " -l0 --title \"Memory usage $hostname\" ";
28 $maxgb = sprintf("%.1f", $MAX[1] / 1024.0);
30 # For the rest of the data we rather work with names instead
31 # of numbers
32 $RRD = array();
33 foreach ($NAME as $i => $n) {
34 $RRD[$n] = "$RRDFILE[$i]:$DS[$i]:MAX";
35 $WARN[$n] = $WARN[$i];
36 $CRIT[$n] = $CRIT[$i];
37 $MIN[$n] = $MIN[$i];
38 $MAX[$n] = $MAX[$i];
41 $def[1] = "";
43 if (isset($RRD['pagetables'])) {
44 $def[1] .= "DEF:pagetables=$RRD[pagetables] "
45 . "DEF:ram=$RRD[ramused] ";
47 else {
48 $def[1] .= "DEF:ram=$RRD[ramused] ";
51 $def[1] .= "DEF:virt=$RRDFILE[3]:$DS[3]:MAX "
52 . "DEF:swap=$RRDFILE[2]:$DS[2]:MAX "
54 . "HRULE:$MAX[3]#000080:\"RAM+SWAP installed\" "
55 . "HRULE:$MAX[1]#2040d0:\"$maxgb GB RAM installed\" "
56 . "HRULE:$WARN[3]#FFFF00:\"Warning\" "
57 . "HRULE:$CRIT[3]#FF0000:\"Critical\" "
59 . "'COMMENT:\\n' "
60 . "AREA:ram#80ff40:\"RAM used \" "
61 . "GPRINT:ram:LAST:\"%6.0lf MB last\" "
62 . "GPRINT:ram:AVERAGE:\"%6.0lf MB avg\" "
63 . "GPRINT:ram:MAX:\"%6.0lf MB max\\n\" "
65 . "AREA:swap#008030:\"SWAP used \":STACK "
66 . "GPRINT:swap:LAST:\"%6.0lf MB last\" "
67 . "GPRINT:swap:AVERAGE:\"%6.0lf MB avg\" "
68 . "GPRINT:swap:MAX:\"%6.0lf MB max\\n\" "
72 if (isset($RRD['pagetables'])) {
73 $def[1] .= ""
74 . "AREA:pagetables#ff8800:\"Page tables \":STACK "
75 . "GPRINT:pagetables:LAST:\"%6.0lf MB last\" "
76 . "GPRINT:pagetables:AVERAGE:\"%6.0lf MB avg\" "
77 . "GPRINT:pagetables:MAX:\"%6.0lf MB max\\n\" "
78 . "LINE:virt#000000:\"RAM+SWAP+PT used\" "
79 . "GPRINT:virt:LAST:\"%6.0lf MB last\" "
80 . "GPRINT:virt:AVERAGE:\"%6.0lf MB avg\" "
81 . "GPRINT:virt:MAX:\"%6.0lf MB max\\n\" "
85 else {
86 $def[1] .= "LINE:virt#000000:\"RAM+SWAP used \" "
87 . "GPRINT:virt:LAST:\"%6.0lf MB last\" "
88 . "GPRINT:virt:AVERAGE:\"%6.0lf MB avg\" "
89 . "GPRINT:virt:MAX:\"%6.0lf MB max\\n\" "
93 if (isset($RRD['mapped'])) {
94 $def[1] .= "DEF:mapped=$RRD[mapped] "
95 . "LINE2:mapped#8822ff:\"Memory mapped \" "
96 . "GPRINT:mapped:LAST:\"%6.0lf MB last\" "
97 . "GPRINT:mapped:AVERAGE:\"%6.0lf MB avg\" "
98 . "GPRINT:mapped:MAX:\"%6.0lf MB max\\n\" " ;
101 if (isset($RRD['committed_as'])) {
102 $def[1] .= "DEF:committed=$RRD[committed_as] "
103 . "LINE2:committed#cc00dd:\"Committed \" "
104 . "GPRINT:committed:LAST:\"%6.0lf MB last\" "
105 . "GPRINT:committed:AVERAGE:\"%6.0lf MB avg\" "
106 . "GPRINT:committed:MAX:\"%6.0lf MB max\\n\" " ;
109 /* Shared memory is part of RAM. So simply overlay it */
110 if (isset($RRD['shared'])) {
111 $def[1] .= "DEF:shared=$RRD[shared] "
112 . "AREA:shared#44ccff:\"Shared Memory \" "
113 . "GPRINT:shared:LAST:\"%6.0lf MB last\" "
114 . "GPRINT:shared:AVERAGE:\"%6.0lf MB avg\" "
115 . "GPRINT:shared:MAX:\"%6.0lf MB max\\n\" " ;