nagios: adding template for nrpe_disks RRD perfdata
This commit is contained in:
parent
3f48f33bae
commit
285d24e09d
1 changed files with 79 additions and 0 deletions
79
nagios/check_nrpe_disks.php
Normal file
79
nagios/check_nrpe_disks.php
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
<?php
|
||||||
|
#
|
||||||
|
# Copyright (c) 2006-2010 Joerg Linge (http://www.pnp4nagios.org)
|
||||||
|
# Template for check_disk
|
||||||
|
#
|
||||||
|
# RRDtool Options
|
||||||
|
|
||||||
|
foreach ($this->DS as $KEY=>$VAL) {
|
||||||
|
# set initial values
|
||||||
|
$fmt = '%7.3lf';
|
||||||
|
$pct = '';
|
||||||
|
$upper = "";
|
||||||
|
$maximum = "";
|
||||||
|
$divis = 1;
|
||||||
|
$return = '\n';
|
||||||
|
$unit = "B";
|
||||||
|
$label = $unit;
|
||||||
|
if ($VAL['UNIT'] != "") {
|
||||||
|
$unit = $VAL['UNIT'];
|
||||||
|
$label = $unit;
|
||||||
|
if ($VAL['UNIT'] == "%%") {
|
||||||
|
$label = '%';
|
||||||
|
$fmt = '%5.1lf';
|
||||||
|
$pct = '%';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($VAL['MAX'] != "") {
|
||||||
|
# adjust value and unit, details in .../helpers/pnp.php
|
||||||
|
$max = pnp::adjust_unit( $VAL['MAX'].$unit,1024,$fmt );
|
||||||
|
//$upper = "-u $max[1] ";
|
||||||
|
$maximum = "of $max[1] $max[2]$pct free";
|
||||||
|
$label = $max[2];
|
||||||
|
$divis = $max[3];
|
||||||
|
//$return = '';
|
||||||
|
}
|
||||||
|
$ds_name[$KEY] = str_replace("_","/",$VAL['NAME']);
|
||||||
|
# set graph labels
|
||||||
|
$opt[$KEY] = "--vertical-label $label -l 0 $upper --title \"Free space on filesystem $ds_name[$KEY]\" ";
|
||||||
|
# Graph Definitions
|
||||||
|
$def[$KEY] = rrd::def( "var1", $VAL['RRDFILE'], $VAL['DS'], "AVERAGE" );
|
||||||
|
# "normalize" graph values
|
||||||
|
if ($VAL['MAX'] != "") {
|
||||||
|
$def[$KEY] .= rrd::cdef( "v_libre", $VAL['MAX'] . ",var1,-");
|
||||||
|
$def[$KEY] .= rrd::cdef( "v_n","v_libre,$divis,/");
|
||||||
|
} else {
|
||||||
|
$def[$KEY] .= rrd::cdef( "v_n","var1,$divis,/");
|
||||||
|
}
|
||||||
|
$def[$KEY] .= rrd::area( "v_n", "#c6c6c6", $ds_name[$KEY] );
|
||||||
|
$def[$KEY] .= rrd::line1( "v_n", "#003300" );
|
||||||
|
# show values in legend
|
||||||
|
$def[$KEY] .= rrd::gprint( "v_n", "LAST", "$fmt $label$pct $maximum ");
|
||||||
|
$def[$KEY] .= rrd::gprint( "v_n", "AVERAGE", "$fmt $label$pct avg $return");
|
||||||
|
# create max line and legend
|
||||||
|
if ($VAL['MAX'] != "") {
|
||||||
|
//$def[$KEY] .= "COMMENT:\"" . $max[1] . " Size of FS " . $max[0] ."\"";
|
||||||
|
# create warning line and legend
|
||||||
|
if ($VAL['WARN'] != "") {
|
||||||
|
$warn = pnp::adjust_unit( ($VAL['MAX'] - $VAL['WARN']) . $unit, 1024, $fmt );
|
||||||
|
$def[$KEY] .= rrd::hrule( ($VAL['MAX'] - $VAL['WARN']) / $divis, "#ffff00", "Warning on $warn[0] \\n" );
|
||||||
|
}
|
||||||
|
# create critical line and legend
|
||||||
|
if ($VAL['CRIT'] != "") {
|
||||||
|
$crit = pnp::adjust_unit( ($VAL['MAX'] - $VAL['CRIT']) . $unit, 1024, $fmt );
|
||||||
|
$def[$KEY] .= rrd::hrule( ($VAL['MAX'] - $VAL['CRIT']) / $divis, "#ff0000", "Critical on $crit[0]\\n" );
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
# create warning line and legend
|
||||||
|
if ($VAL['WARN'] != "") {
|
||||||
|
$warn = pnp::adjust_unit( $VAL['WARN'].$unit,1024,$fmt );
|
||||||
|
$def[$KEY] .= rrd::hrule( $warn[1], "#ffff00", "Warning on $warn[0] \\n" );
|
||||||
|
}
|
||||||
|
# create critical line and legend
|
||||||
|
if ($VAL['CRIT'] != "") {
|
||||||
|
$crit = pnp::adjust_unit( $VAL['CRIT'].$unit,1024,$fmt );
|
||||||
|
$def[$KEY] .= rrd::hrule( $crit[1], "#ff0000", "Critical on $crit[0]\\n" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
Loading…
Reference in a new issue