View Single Post
Old June 1st, 2007, 6:18 PM   #129 (permalink)
MarkRH
Race Surpass
Super #1
 
MarkRH's Avatar
 
Joined in Jul 2006
Lives in Oklahoma City, OK
Hosted on sh102
1,224 posts
Gave thanks: 18
Thanked 86 times
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 $im48 ,448 $meterwidth$height-6$metercolor ); 
    
imagerectangle $im48,476$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 $im48 ,448 $meterwidth$height-6$metercolor );
    
imagerectangle $im48,476$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.
MarkRH is offline   Reply With Quote