Hmm.. I just noticed a bug with this script. Here's the old section of code:
PHP Code:
/* do meter bar */
if ($loadav != "error") {
$limit = 20; //this is the upper limit of the range of server load values... adjust to your server
$percent = ($loadav * 100) /$limit;
$meterwidth = ($percent / 100) * 28;
if ($meterwidth > $limit)
$meterwidth = $limit;
imagefilledrectangle ( $im, 48 ,4, 48 + $meterwidth, $height-6, $metercolor );
imagerectangle ( $im, 48,4, 76, $height-6, $bordercolor2 );
}
/* output gif image to browser */
Here's my fixed version:
PHP Code:
/* do meter bar */
if ($loadav != "error") {
$graph_width = 27; //number of pixels inside black rectangle.
$limit = 20; //this is the upper limit of the range of server load values... adjust to your server
$percent = ($loadav * 100) /$limit;
$meterwidth = ($percent / 100) * $graph_width;
if ($meterwidth > $graph_width)
$meterwidth = $graph_width;
imagefilledrectangle ( $im, 48 ,4, 48 + $meterwidth, $height-6, $metercolor );
imagerectangle ( $im, 48,4, 76, $height-6, $bordercolor2 );
}
/* output gif image to browser */
It should have been checking the meterwidth against the actual width of the meter in pixels (27 in this case) and not the $limit value. If you set your limit to 8 like I did, then it never draws the green meter past like halfway.