Refactoring: Moved check parameters from unsorted.py to dedicated modules (CMK-1393)
[check_mk.git] / pnp-templates / check_mk-local.php
blob03e073d2cce7810f6029641e9dc310fde3738654
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 // try to find template matching a prefix of the service
27 // description first. Slashes are replaced by underscores.
28 $template_dirs = array('templates');
29 if (isset($this->config->conf['template_dirs'])) {
30 $template_dirs = $this->config->conf['template_dirs'];
32 $descr = str_replace("/", "_", $servicedesc);
33 foreach ($template_dirs as $template_dir) {
34 $found = 0;
35 for ($i = strlen($descr); $i > 0; $i--)
37 $tryname = $template_dir . '/' . substr($descr, 0, $i) . '.php';
38 if (file_exists($tryname) && include($tryname)) {
39 $found = 1;
40 break;
43 if ($found) {
44 break;
48 # Use another color for each graph. After eight graphs colors wrap around.
49 $area_colors = array( "beff5f", "5fffef", "5faaff", "cc5fff", "ff5fe2", "ff5f6c", "ff975f", "ffec5f");
50 $line_colors = array( "5f7a2f", "2f8077", "2f5580", "662f80", "802f71", "802f36", "804b2f", "80762f");
52 if (!$found) {
53 foreach ($RRDFILE as $i => $RRD) {
54 $ii = $i % 8;
55 $name = $NAME[$i];
56 $def[$i] = "DEF:cnt=$RRDFILE[$i]:$DS[$i]:MAX ";
57 $def[$i] .= "AREA:cnt#$area_colors[$ii]:\"$name\" ";
58 $def[$i] .= "LINE1:cnt#$line_colors[$ii]: ";
60 $upper = "";
61 $lower = " -l 0";
62 if ($WARN[$i] != "") {
63 $def[$i] .= "HRULE:$WARN[$i]#ffff00:\"Warning\" ";
65 if ($CRIT[$i] != "") {
66 $def[$i] .= "HRULE:$CRIT[$i]#ff0000:\"Critical\" ";
68 if ($MIN[$i] != "") {
69 $lower = " -l " . $MIN[$i];
70 $minimum = $MIN[$i];
72 if ($MAX[$i] != "") {
73 $upper = " -u" . $MAX[$i];
74 $def[$i] .= "HRULE:$MAX[$i]#0000b0:\"Upper limit\" ";
77 $opt[$i] = "$lower $upper --title '$hostname: $servicedesc - $name' ";
78 $def[$i] .= "GPRINT:cnt:LAST:\"current\: %6.2lf\" ";
79 $def[$i] .= "GPRINT:cnt:MAX:\"max\: %6.2lf\" ";
80 $def[$i] .= "GPRINT:cnt:AVERAGE:\"avg\: %6.2lf\" ";