Fork me on GitHub
Translations of this page:

check_cpu

Template Description

This template use the output from check_cpu plugin for Solaris and draw a 1 month trend and a global trend (edit file to customize it).

Here's the expected output of this plugin :

CPU STATISTICS OK : user=36% system=16% iowait=14% idle=34% | user=36 sys=16 iowait=14 idle=34 warn=45 crit=60

Preview

This is the template look like :

Template Code

check_cpu.php
<?php
#
# Copyright (c)  2010 Yannig Perre (http://lesaventuresdeyannigdanslemondeit.blogspot.com)
# Plugin: check_cpu
#
$ds_name[1] = "CPU Activity";
 
$opt[1] = "--upper-limit 100 --vertical-label CPU -l0  --title \"CPU activity for $hostname\" ";
#
#
#

$trend_array = array(
  "one_month"    => array(strtotime("-1 month", $this->TIMERANGE['end']), $this->TIMERANGE['end'], "1 month trend:dashes=10", "#FF007F", "LINE3"),
  "global_trend" => array($this->TIMERANGE['start'], $this->TIMERANGE['end'], "Global trend:dashes=20", "#707070", "LINE2"),
);
 
$def[1] =  "DEF:var1=$RRDFILE[1]:$DS[1]:AVERAGE " ;
$def[1] .= "DEF:var2=$RRDFILE[2]:$DS[2]:AVERAGE " ;
$def[1] .= "CDEF:user=var2,var1,+ " ;
$def[1] .= "DEF:var3=$RRDFILE[3]:$DS[3]:AVERAGE " ;
$def[1] .= "CDEF:io=var3,var2,+,var1,+ " ;
 
$trend_elements = "";
 
foreach(array_keys($trend_array) as $trend) {
  $def[1] .= "DEF:var1$trend=$RRDFILE[1]:$DS[1]:AVERAGE:start=".$trend_array[$trend][0]." ";
  $def[1] .= "DEF:var2$trend=$RRDFILE[2]:$DS[2]:AVERAGE:start=".$trend_array[$trend][0]." ";
  $def[1] .= "CDEF:user$trend=var2$trend,var1$trend,+ " ;
 
  $def[1] .= "VDEF:dtrend$trend=user$trend,LSLSLOPE ";
  $def[1] .= "VDEF:htrend$trend=user$trend,LSLINT ";
  $def[1] .= "CDEF:curve_user$trend=user$trend,POP,dtrend$trend,COUNT,*,htrend$trend,+ ";
  $trend_elements .= $trend_array[$trend][4].":curve_user$trend".$trend_array[$trend][3].":\"".$trend_array[$trend][2]."\" " ;
}
 
if ($WARN[1] != "") {
    $def[1] .= "HRULE:$WARN[1]#FFFF00 ";
}
if ($CRIT[1] != "") {
    $def[1] .= "HRULE:$CRIT[1]#FF0000 ";       
}
 
$def[1] .= "AREA:io#00FF00:\"iowait\" " ;
$def[1] .= "GPRINT:var3:LAST:\"%6.2lf\" " ;
$def[1] .= "GPRINT:var3:AVERAGE:\"moy %6.2lf\" " ;
$def[1] .= "GPRINT:var3:MAX:\"max %6.2lf\\n\" " ;
$def[1] .= "AREA:user#005CFF:\"user  \" " ;
$def[1] .= "GPRINT:var1:LAST:\"%6.2lf\" " ;
$def[1] .= "GPRINT:var1:AVERAGE:\"moy %6.2lf\" " ;
$def[1] .= "GPRINT:var1:MAX:\"max %6.2lf\\n\" ";
$def[1] .= "AREA:var2#FF5C00:\"sys   \" " ;
$def[1] .= "GPRINT:var2:LAST:\"%6.2lf\" " ;
$def[1] .= "GPRINT:var2:AVERAGE:\"moy %6.2lf\" " ;
$def[1] .= "GPRINT:var2:MAX:\"max %6.2lf\\n\" " ;
$def[1] .= "LINE1:io#000000:\"\" " ;
$def[1] .= "LINE1:user#000000:\"\" " ;
$def[1] .= "LINE1:var2#000000:\"\" " ;
$def[1] .= $trend_elements;
?>
templates/check_cpu.txt · Last modified: 2010/05/17 09:44 by Yannig PerrĂ©
www.chimeric.de Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0