I've created a custom graph for my check_cpu plugin.
Template looks good. Perf data looks good. Graph on my screen looks to be the default graph and not my custom graph.
templates/check_cpu.php
Code: Select all
<?php
$opt[1] = "--vertical-label \"% Used\" -l0 --title \"CPU for $hostname / $servicedesc\" ";
# Memory Used
$def[1] = "DEF:load=$rrdfile:$DS[1]:AVERAGE " ;
$def[1] .= "AREA:load#00CC00:\"Load \" ";
$def[1] .= "GPRINT:load:LAST:\"%3.2lf %sB CUR \" ";
$def[1] .= "GPRINT:load:MAX:\"%3.2lf %sB MAX \" ";
$def[1] .= "GPRINT:load" . ':AVERAGE:"%3.2lf %sB AVG \j" ';
$opt[2] = "--vertical-label \"% Used\" -l0 --title \"CPU usage for $hostname / $servicedesc\" ";
# CPU
$def[2] = "DEF:cpuSys=$rrdfile:$DS[3]:AVERAGE " ;
$def[2] .= "AREA:cpuSys#FF0000:\"System \" ";
$def[2] .= "GPRINT:cpuSys:LAST:\"%3.2lf %sB CUR \" ";
$def[2] .= "GPRINT:cpuSys:MAX:\"%3.2lf %sB MAX \" ";
$def[2] .= "GPRINT:cpuSys" . ':AVERAGE:"%3.2lf %sB AVG \j" ';
$def[2] .= "DEF:cpuUser=$rrdfile:$DS[2]:AVERAGE " ;
$def[2] .= "AREA:cpuUser#FFFF00:\"User \" ";
$def[2] .= "GPRINT:cpuUser:LAST:\"%3.2lf %sB CUR \" ";
$def[2] .= "GPRINT:cpuUser:MAX:\"%3.2lf %sB MAX \" ";
$def[2] .= "GPRINT:cpuUser" . ':AVERAGE:"%3.2lf %sB AVG \j" ';
$def[2] .= "DEF:cpuIdle=$rrdfile:$DS[4]:AVERAGE " ;
$def[2] .= "AREA:cpuIdle#00CC00:\"Idle \" ";
$def[2] .= "GPRINT:cpuIdle:LAST:\"%3.2lf %sB CUR \" ";
$def[2] .= "GPRINT:cpuIdle:MAX:\"%3.2lf %sB MAX \" ";
$def[2] .= "GPRINT:cpuIdle" . ':AVERAGE:"%3.2lf %sB AVG \j" ';
$opt[3] = "--vertical-label \"% Used\" -l0 --title \"IO Wait for $hostname / $servicedesc\" ";
# CPU
$def[3] = "DEF:IoWait=$rrdfile:$DS[2]:AVERAGE " ;
$def[3] .= "AREA:IoWait#00CC00:\"IoWait \" ";
$def[3] .= "GPRINT:IoWait:LAST:\"%3.2lf %sB CUR \" ";
$def[3] .= "GPRINT:IoWait:MAX:\"%3.2lf %sB MAX \" ";
$def[3] .= "GPRINT:IoWait" . ':AVERAGE:"%3.2lf %sB AVG \j" ';
?>
load=1.77;cpuUser=17.6;cpuSys=3.5;cpuIdle=;IoWait=0.1