icon Get the most out of Surmunity, read our tips here! Need an interesting blog to read? You've got to read the Surpass Blog! | Welcome! Please register to access all of our features.

» Surpass Web Hosting Forums » Discussions » All Things Techy » Site Maintenance » [Self-serve] Server Load Button

Site Maintenance Program updates, securing your website, creating backups.

Reply
 
LinkBack Thread Tools Search this Thread
Old May 14th, 2007, 3:42 PM   #127 (permalink)
eye
Lost in code...
Fresh Surpasser
 
Joined in Mar 2007
Lives in UK
Hosted on Sh120
20 posts
Gave thanks: 0
Thanked 2 times
Copy paste to Textwrangler, save as serverload.php, drop in public_html, edit signature, voila!

Although now I know it hasn't dropped below 4 since I did it !

__________________
http://www.opcp.co.uk
Sh120
eye is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old May 14th, 2007, 4:21 PM   #128 (permalink)
eye
Lost in code...
Fresh Surpasser
 
Joined in Mar 2007
Lives in UK
Hosted on Sh120
20 posts
Gave thanks: 0
Thanked 2 times
Then it drops to 3.

__________________
http://www.opcp.co.uk
Sh120
eye is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old June 1st, 2007, 5:18 PM   #129 (permalink)
Race Surpass
Super #1
 
MarkRH's Avatar
 
Joined in Jul 2006
Lives in Oklahoma City, OK
Hosted on sh102
1,219 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  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old June 1st, 2007, 11:46 PM   #130 (permalink)
Registered User
Seasoned Poster
 
Joined in May 2007
Lives in Manila, Philippines
Hosted on Pass68
32 posts
Gave thanks: 3
Thanked 1 Time in 1 Post
Thank you for this cool script. MarkRH, I'm using your fix now.
__________________
Reseller - Pass68
BrinkNotes Hosting | My Boring Life...Now A Blog! | Just Jeric | So Sick of Taxi
brinknotes is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old August 2nd, 2007, 7:11 PM   #131 (permalink)
4-8-15-16-23-42
Excelling Contributor
 
caseylee's Avatar
 
Joined in Jul 2007
Lives in Australia, turn left at America
Hosted on Luna & Nexus (dedicated)
775 posts
Gave thanks: 36
Thanked 29 times
I wanted a pretty girly one, >_> so I have my own version that rotates through different backgrounds.
__________________
caseylee is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old August 30th, 2007, 8:36 PM   #132 (permalink)
Registered User
Fresh Surpasser
 
Joined in Jun 2006
10 posts
Gave thanks: 0
Thanked 0 times
Mine doesnt work...
__________________
Pass59
www.a12lions.org
trivialguy is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old November 8th, 2007, 12:12 AM   #133 (permalink)
Registered User
Fresh Surpasser
 
Joined in Jul 2007
9 posts
Gave thanks: 0
Thanked 0 times
this is my SL ;-)
__________________
HIDEUNG.COM >> PASS60
zoel is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old December 1st, 2007, 2:23 PM   #134 (permalink)
Registered User
Excelling Contributor
 
Joined in Feb 2005
536 posts
Gave thanks: 84
Thanked 24 times
Anyway to have this working in a Windows server?
And how to make the green bar turns red when the load goes over the "safe limit"?
__________________
Patty

Pass 57 | Dime999 | SH 110
Patty is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old December 1st, 2007, 2:45 PM   #135 (permalink)
Registered User
Excelling Contributor
 
Joined in Feb 2005
536 posts
Gave thanks: 84
Thanked 24 times
I've found this script, but it's giving an error:


Warning: (null)(): Invalid ProgID, GUID string, or Moniker: No description available in <b>C:\Inetpub\vhosts\user\httpdocs\windowsuptime.p hp</b> on line <b>8</b><br />
PHP has encountered an Access Violation at 01C3E3F8


Maybe it's just a matter of few tweaks... anybody???

Code:
<?php
// PHP 5

header("Content-type: image/png");
    
function getServerLoad(){

    $wmi = new COM("Winmgmts://");
    $server = $wmi->execquery("SELECT LoadPercentage FROM Win32_Processor");

    foreach($server as $cpu){
    
        return $cpu->loadpercentage;
    }
}

$load     = getServerLoad();
$img     = @imagecreate(107, 12) or die("Server ondersteunt geen GD library...");

$background_color     = imagecolorallocate($img, 255, 255, 255);
$border_color         = imagecolorallocate($img, 197, 197, 197);
$procent             = imagecolorallocate($img, 0, 0, 0);

if($load < 33){
    
    $load_color     = imagecolorallocate($img, 149, 191, 77); // Green

}elseif($load >= 33 && $load < 66){
    
    $load_color     = imagecolorallocate($img, 213, 184, 55); // Orange

}else{

    $load_color     = imagecolorallocate($img, 186, 83, 83); // Red
}

imagerectangle($img, 0, 0, 106, 11, $border_color);
imagefilledrectangle($img, 3, 3, 3 + $load, 8, $load_color);

imagestring($img, 1, 50, 2, $load . "%", $procent);

// Create Image
imagepng($img);
imagedestroy($img);

?>
__________________
Patty

Pass 57 | Dime999 | SH 110
Patty is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On