foreach ($this->DS as $KEY => $VAL) {
    if ($VAL['TEMPLATE'] == "check_brick_usage") {
        $ds_name[$KEY] = "Brick Utilization";
    } else {
        $ds_name[$KEY] = "Disk Utilization";
    }
    $name[$KEY] = "Mount Path: ";
    $graph_type = $VAL['LABEL'];
    $max_limit = $VAL['MAX'];
    $unit = "GiB";
    if (endsWith($graph_type, ".inode") || endsWith($graph_type, ".thinpool") || endsWith($graph_type, ".thinpool-metadata")) {
        list($brick, $data_type) = explode(".", $graph_type);
        $ds_name[$KEY] .= "(";
        $ds_name[$KEY] .= $data_type;
        $ds_name[$KEY] .= ")";
        $name[$KEY] .= $brick;
        if ($data_type == "inode") {
            $unit = "";
        }
    } else {
        $name[$KEY] .= $graph_type;
        $ds_name[$KEY] .= "(space)";
    }
    $opt[$KEY] = "--vertical-label \"%(Total: {$max_limit} {$unit}) \"  --lower-limit 0 --upper-limit 100 -r --title \"{$name[$KEY]}\" ";
    $def[$KEY] = rrd::def("var1", $VAL['RRDFILE'], $VAL['DS'], "AVERAGE");
    $def[$KEY] .= rrd::area("var1", "#008000", "Usage");
    $def[$KEY] .= rrd::gprint("var1", array("LAST", "MAX", "AVERAGE"), "%.3lf %%");
    $def[$KEY] .= rrd::line2($VAL['WARN'], "#FFA500", "Warning\\n");
    $def[$KEY] .= rrd::line2($VAL['CRIT'], "#FF0000", "Critical\\n");
    $def[$KEY] .= rrd::comment("   \\n");
}
<?php

$alpha = 'CC';
$colors = array('#00FF00' . $alpha, '#0000FF' . $alpha);
$ds_name[1] = 'Duplication';
$opt[1] = "-T 55 --vertical-label \"Percent\" --title \"{$hostname} / PuppetDB Duplication\"";
$def[1] = '';
foreach ($DS as $i) {
    $def[1] .= rrd::def("var{$i}", $rrdfile, $DS[$i], 'AVERAGE');
    $def[1] .= rrd::line2("var{$i}", $colors[$i - 1], rrd::cut(ucfirst($NAME[$i]), 15));
    $def[1] .= rrd::gprint("var{$i}", array('LAST', 'AVERAGE', 'MAX'), "%4.2lf %s\\t");
}
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
 
  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
//$fp = fopen('/tmp/test', 'a');
//ob_start();
//print_r($this->DS);
$DS_gc1_count = $this->DS[0];
$DS_gc2_count = $this->DS[1];
$DS_gc1_time = $this->DS[2];
$DS_gc2_time = $this->DS[3];
$opt[1] = "--vertical-label \"GC usage\" -l 0 --title \"{$hostname} - GC usage\" ";
$def[1] = rrd::def("var1", $DS_gc1_count['RRDFILE'], $DS_gc1_count['DS']);
$def[1] .= rrd::def("var2", $DS_gc2_count['RRDFILE'], $DS_gc2_count['DS']);
$def[1] .= rrd::def("var3", $DS_gc1_time['RRDFILE'], $DS_gc1_time['DS']);
$def[1] .= rrd::def("var4", $DS_gc2_time['RRDFILE'], $DS_gc2_time['DS']);
$def[1] .= rrd::line1("var1", "#00FF00", $DS_gc1_count['NAME']);
$def[1] .= rrd::gprint("var1", array("LAST", "MAX", "AVERAGE"), "%3.2lfcount/s");
$def[1] .= rrd::line1("var2", "#0000FF", $DS_gc2_count['NAME']);
$def[1] .= rrd::gprint("var2", array("LAST", "MAX", "AVERAGE"), "%3.2lfcount/s");
$def[1] .= rrd::line2("var3", "#FFFF00", $DS_gc1_time['NAME']);
$def[1] .= rrd::gprint("var3", array("LAST", "MAX", "AVERAGE"), "%3.2lfms/s");
$def[1] .= rrd::line2("var4", "#FF00FF", $DS_gc2_time['NAME']);
$def[1] .= rrd::gprint("var4", array("LAST", "MAX", "AVERAGE"), "%3.2lfms/s");
// Debug
//$content = ob_get_clean();
//fwrite($fp, "$content\n");
//fclose($fp);
Example #4
0
#
#
#
#
$index = 1;
foreach ($DS as $i => $VAL) {
    if (!isset($def[$index])) {
        $def[$index] = "";
    }
    $def[$index] .= "DEF:var{$i}={$RRDFILE[$i]}:{$DS[$i]}:AVERAGE ";
    if (!preg_match('/^threshold$/', $NAME[$i], $matches)) {
        $opt[$index] = "--title \"{$hostname} / {$servicedesc} / {$NAME[$i]} \" ";
        $def[$index] .= rrd::gradient("var{$i}", "ff5c00", "ffdc00", "{$NAME[$i]}", 20);
        $def[$index] .= rrd::line1("var{$i}", "#000000");
        $def[$index] .= rrd::gprint("var{$i}", "LAST", "%6.0lf \\n");
    } else {
        $def[$index] .= rrd::line2("var{$i}", "#555210", "{$NAME[$i]}");
        $def[$index] .= rrd::gprint("var{$i}", "LAST", "%6.0lf \\n");
        $val = $i - 1;
        if ($WARN[$val] != "") {
            $def[$index] .= rrd::hrule($WARN[$val], "#FFFF00", "Warning   " . $WARN[$val] . $UNIT[$val] . "\\n");
        }
        if ($CRIT[$val] != "") {
            $def[$index] .= rrd::hrule($CRIT[$val], "#FF0000", "Critical  " . $CRIT[$val] . $UNIT[$val] . "\\n");
        }
        $index = $index + 1;
    }
}
?>

#third graph - open slots count
$ds_name[3] = "Open slots";
$opt[3] = " --vertical-label \"Workers\" --title \"Apache open slots on {$hostname} / {$servicedesc}\" ";
$opt[3] .= " --slope-mode ";
$def[3] = rrd::def("var1", $RRDFILE[1], $DS[11], "AVERAGE");
$def[3] .= rrd::area("var1", "#e0e0e0", "open slots");
$def[3] .= rrd::line1("var1", "#858585");
$def[3] .= rrd::gprint("var1", array("LAST", "MAX", "AVERAGE"), "%7.0lf");
#fourth graph - server's traffic total and per request
$ds_name[4] = "Apache Traffic";
$opt[4] = " --vertical-label \"Traffic\" -b 1024 --title \"Apache Traffic for {$hostname} / {$servicedesc}\" ";
$opt[4] .= " --slope-mode ";
$def[4] = rrd::def("var1", $RRDFILE[1], $DS[13], "AVERAGE");
$def[4] .= rrd::cdef("trbytes", "var1,1024,*");
$def[4] .= rrd::def("var2", $RRDFILE[1], $DS[14], "AVERAGE");
$def[4] .= rrd::cdef("negperreq", "var2,-1,*");
$def[4] .= "VDEF:totalbytes=trbytes,TOTAL ";
$def[4] .= rrd::area("trbytes", "#b0c0fb", "throughput");
$def[4] .= rrd::line1("trbytes", "#3c63ff");
$def[4] .= rrd::gprint("trbytes", array("LAST", "MAX", "AVERAGE"), "%7.2lf %sB/sec");
$def[4] .= rrd::line2("negperreq", "#00ff00", "kB/request");
$def[4] .= rrd::gprint("var2", array("LAST", "MAX", "AVERAGE"), "%7.2lf %s{$UNIT['14']}");
$def[4] .= "GPRINT:totalbytes:\"%3.0lf %sB total\\n\" ";
#fifth graph - requests per sec ( rate is calculated by apache, time smoothed, very averaged, shouldn't be believed)
$ds_name[5] = "Apache requests";
$opt[5] = " --vertical-label \"Request/sec\" --title \"Apache request/sec for {$hostname} / {$servicedesc}\" ";
$opt[5] .= " --slope-mode ";
$def[5] = rrd::def("var1", $RRDFILE[1], $DS[12], "AVERAGE");
$def[5] .= rrd::area("var1", "#b7ff9e", "Requests / sec");
$def[5] .= rrd::line1("var1", "#2eae00");
$def[5] .= rrd::gprint("var1", array("LAST", "MAX", "AVERAGE"), "%7.2lf %s");
$alpha = 'CC';
$colors_allowed = '#AAAAAA' . $alpha;
$colors_used = '#ffd660' . $alpha;
$colors_current = '#ff7d00' . $alpha;
$colors_connected = '#0000FF' . $alpha;
$colors_abrt_client = '#FF0000' . $alpha;
$colors_abrt_conn = '#00FF00' . $alpha;
$ds_name[1] = 'Connections';
$opt[1] = sprintf('-T 55 -l 0 --vertical-label "Connections" --title "%s / MySQL Connections"', $hostname);
$def[1] = '';
$def[1] .= rrd::def('var1', $rrdfile, $DS[1], 'AVERAGE');
$def[1] .= rrd::area('var1', $colors_allowed, rrd::cut('Max Connections', 20));
$def[1] .= rrd::gprint('var1', array('LAST'), '%4.0lf %s');
$def[1] .= rrd::def('var2', $rrdfile, $DS[2], 'AVERAGE');
$def[1] .= rrd::area('var2', $colors_used, rrd::cut('Max Used Connections', 20));
$def[1] .= rrd::gprint('var2', array('LAST'), '%4.0lf %s');
$def[1] .= rrd::def('var3', $rrdfile, $DS[3], 'AVERAGE');
$def[1] .= rrd::line2('var3', $colors_current, rrd::cut('Current Connections', 20));
$def[1] .= rrd::gprint('var3', array('LAST', 'AVERAGE', 'MAX'), '%4.0lf %s');
$ds_name[2] = 'Connections Per Second';
$opt[2] = sprintf('-T 55 -l 0 --vertical-label "Connections/Second" --title "%s / MySQL Connections Per Second"', $hostname);
$def[2] = '';
$def[2] .= rrd::def('var1', $rrdfile, $DS[6], 'AVERAGE');
$def[2] .= rrd::line2('var1', $colors_connected, rrd::cut('Connections', 20));
$def[2] .= rrd::gprint('var1', array('LAST', 'AVERAGE', 'MAX'), '%4.0lf %s');
$def[2] .= rrd::def('var2', $rrdfile, $DS[4], 'AVERAGE');
$def[2] .= rrd::line2('var2', $colors_abrt_client, rrd::cut('Aborted Clients', 20));
$def[2] .= rrd::gprint('var2', array('LAST', 'AVERAGE', 'MAX'), '%4.0lf %s');
$def[2] .= rrd::def('var3', $rrdfile, $DS[5], 'AVERAGE');
$def[2] .= rrd::line2('var3', $colors_abrt_conn, rrd::cut('Aborted Connections', 20));
$def[2] .= rrd::gprint('var3', array('LAST', 'AVERAGE', 'MAX'), '%4.0lf %s');
  (at your option) any later version.
 
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
 
  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
$DS_threads = $this->DS[0];
$DS_questions = $this->DS[1];
$DS_slowq = $this->DS[2];
$DS_opentables = $this->DS[3];
$DS_status = $this->DS[4];
$opt[1] = "-l0 --title \"{$hostname} / Mysql Activity\" ";
$def[1] = rrd::def("var1", $DS_threads['RRDFILE'], $DS_threads['DS']);
$def[1] .= rrd::def("var2", $DS_questions['RRDFILE'], $DS_questions['DS']);
$def[1] .= rrd::def("var3", $DS_slowq['RRDFILE'], $DS_slowq['DS']);
$def[1] .= rrd::def("var4", $DS_opentables['RRDFILE'], $DS_opentables['DS']);
$def[1] .= rrd::def("var5", $DS_status['RRDFILE'], $DS_status['DS']);
$def[1] .= rrd::line2("var1", "#00FFFF", "Threads");
$def[1] .= rrd::gprint("var1", array("LAST", "AVERAGE", "MIN", "MAX"), "%4.2lfT");
$def[1] .= rrd::gradient("var2", "#00FF0099", "#00880099", "Query");
$def[1] .= rrd::gprint("var2", array("LAST", "AVERAGE", "MIN", "MAX"), "%4.2lfq/s");
$def[1] .= rrd::line2("var3", "#FF0000", "Slow Query");
$def[1] .= rrd::gprint("var3", array("LAST", "AVERAGE", "MAX"), "%4.2lfq/s");
#$def[1] .= rrd::line1("var4", "#0000FF", "Open Tables");
#$def[1] .= rrd::gprint("var3", array("LAST", "AVERAGE", "MAX"), "%4.2lfc");
$def[1] .= rrd::ticker("var1", $DS_threads['WARN'], $DS_threads['CRIT'], -0.05, "ff", "#00ff00", "#ff8c00", "#ff0000");
$def[1] .= rrd::ticker("var5", 2, 1, -0.05, "ff", "#00ff00", "#ff8c00", "#ff0000");
Example #8
0
<?php

#
# Copyright (c) 2011 Anders Håål, based on check_load
# Plugin: check_bischeck
#
$opt[1] = "--title \"{$hostname} / {$servicedesc}\" ";
#
#
#
$def[1] = rrd::def("var1", $RRDFILE[1], $DS[1], "AVERAGE");
$def[1] .= rrd::def("var2", $RRDFILE[1], $DS[2], "AVERAGE");
#if ($WARN[1] != "") {
#    $def[1] .= "HRULE:$WARN[1]#FFFF00 ";
#}
#if ($CRIT[1] != "") {
#    $def[1] .= "HRULE:$CRIT[1]#FF0000 ";
#}
$def[1] .= rrd::area("var1", "#EACC00", "Measured  ");
$def[1] .= rrd::gprint("var1", array("LAST", "AVERAGE", "MAX"), "%6.0lf");
#$def[1] .= rrd::area("var2", "#EA8F00B0", "Threshold ") ;
$def[1] .= rrd::line2("var2", "#555210", "Threshold ");
$def[1] .= rrd::gprint("var2", array("LAST", "AVERAGE", "MAX"), "%6.0lf");
if ($WARN[1] != "") {
    $def[1] .= rrd::hrule($WARN[1], "#FFFF00", "Warning   " . $WARN[1] . $UNIT[1] . "\\n");
}
if ($CRIT[1] != "") {
    $def[1] .= rrd::hrule($CRIT[1], "#FF0000", "Critical  " . $CRIT[1] . $UNIT[1] . "\\n");
}
  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.
 
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
 
  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
$ds_threads = $this->DS[0];
$ds_daemon = $this->DS[1];
$ds_peak = $this->DS[2];
$ds_total = $this->DS[3];
$unit = $ds_threads['UNIT'];
$max = $ds_threads['ACT'] > $ds_threads['CRIT'] ? $ds_threads['ACT'] : $ds_threads['CRIT'];
$opt[1] = "--vertical-label Load -l0 -u {$max} --title \"JVM threads for {$hostname}\" ";
$def[1] = rrd::def("var1", $ds_threads['RRDFILE'], $ds_threads['DS']);
$def[1] .= rrd::def("var2", $ds_daemon['RRDFILE'], $ds_daemon['DS']);
$def[1] .= rrd::def("var3", $ds_peak['RRDFILE'], $ds_peak['DS']);
$def[1] .= rrd::def("var4", $ds_total['RRDFILE'], $ds_total['DS']);
$def[1] .= rrd::line2("var1", "#66ccff", "Live threads");
$def[1] .= rrd::gprint("var1", array("LAST", "AVERAGE", "MIN", "MAX"), "%.0lf{$unit}");
$def[1] .= rrd::line1("var2", "#CCCC33", "Daemon threads");
$def[1] .= rrd::gprint("var2", array("LAST", "AVERAGE", "MIN", "MAX"), "%.0lf{$unit}");
$def[1] .= rrd::hrule($ds_threads['WARN'], "#FFFF00", "Warning (" . $ds_threads['WARN'] . ") \\n");
$def[1] .= rrd::hrule($ds_threads['CRIT'], "#FF0000", "Critical (" . $ds_threads['CRIT'] . ") \\n");
$def[1] .= rrd::gprint("var3", "LAST", "Last peak \\: %.0lf{$unit}");