Refactoring: Moved check parameters from unsorted.py to dedicated modules (CMK-1393)
[check_mk.git] / pnp-templates / check_mk-hp_blade_psu.php
blobc0f7c5625976c6bf541e7b0b3b1a486b8fbb7709
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.
27 # PNP4Nagios template for check_mk hp_blade_psu check
28 # http://mathias-kettner.de/ FIXME: Link to checks man page
30 # Author: Lars Michelsen <lm@mathias-kettner.de>
33 $colors = array("008CFF", "6FBEFF", "2F7EBF", "00589F");
35 $path = dirname($RRDFILE[1]);
37 # get all psu files
38 $files = array();
39 if($h = opendir($path)) {
40 while(($file = readdir($h)) !== false) {
41 if(preg_match('/^PSU_[0-9]+_output\.rrd$/', $file, $aRet))
42 $files[] = $aRet[0];
44 natcasesort($files);
45 closedir($h);
48 $opt[0] = "-l 0 --vertical-label \"Watt\" --title \"HP Blade Enclosure - PSU Power Usage\" ";
49 $def[0] = '';
51 $i = 0;
52 foreach($files AS $file) {
53 $color = $colors[$i % 4];
54 $name = str_replace('_', ' ', str_replace('.rrd', '', $file));
56 $def[0] .= "DEF:var$i=$path/$file:$DS[1]:AVERAGE " ;
57 if($i == 0)
58 $def[0] .= "AREA:var$i#$color:\"$name\" " ;
59 else
60 $def[0] .= "AREA:var$i#$color:\"$name\":STACK " ;
61 $def[0] .= "GPRINT:var$i:LAST:\"%6.0lfW last \" ";
62 $def[0] .= "GPRINT:var$i:MAX:\"%6.0lfW max \" ";
63 $def[0] .= "GPRINT:var$i:AVERAGE:\"%6.2lfW avg \\n\" ";
64 $i++;