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 February 1st, 2007, 6:34 AM   #1 (permalink)
tealeaf
Surpass Staff
 
Joined in May 2003
Lives in Orlando
24,047 posts
Gave thanks: 908
Thanked 771 times
[Self-serve] Server Load Button


Do a little something so Surpass can help you better. It might be a good idea to put this in your sig. This way when I am browsing the forum I can see if any servers are in trouble, even if you aren't in the forum.

Put this code into a text file, name it serverload.php and upload to your site anywhere you'd like. Then insert http://domain.com/serverload.php as an image source!

Another explanation from TomK:
[When you edit your signature] click the icon to "insert image" (to the right of insert email) and paste the file name there.


PHP Code:
<?php
/* name:        severload.php
   Author:      Jesse Chilcott
   Description: This script creates a horizontal meter that shows the server load
   Useage:      link to the script as if it is an image
*/


/* get and set more image and font details */
$im imageCreate(80,15);

$width imagesx($im);
$height imagesy($im);
$textcolor imagecolorallocate($im000);
$textcolor2 imagecolorallocate($im255,255,255);
$fillcolor1 imagecolorallocate($im255,255,255);
$fillcolor2 imagecolorallocate($im255,85,0);
$metercolor imagecolorallocate($im0,240,0);
$bordercolor imagecolorallocate($im0,0,0);
$bordercolor2 imagecolorallocate($im40,40,40);
$textWidth imagefontwidth($font) * strlen$str );
$textHeight imagefontheight($font);

/* get server load */
        
if (file_exists("/proc/loadavg") == true)
        {
            
$fp = @fopen("/proc/loadavg""r");
            if (empty(
$fp) == false)
            {
                
$loadavg explode(" "fread($fp6));
                
fclose($fp);
                
$loadav substr($loadavg[0], 04);  // we don't want to many digits or it will overlap the meter
            
}
            else
            {
                
$loadav   "error";
            }
        }
        else
        {
            
$loadav   "error";
        }


header("Content-type: image/gif");

$xLoc 23;
$yLoc 0;

/* over lap background image from the right with a white rectangle */
imagefilledrectangle $im,0$width$height$fillcolor1 );
imagefilledrectangle $im,0$width/4$height$fillcolor2 );
imagerectangle $im0,0$width -1$height-1$bordercolor );
imagestring($im44$yLoc-1"SL"$textcolor2);
imagestring($im,2$xLoc$yLoc$loadav$textcolor);

/* 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 */
imageGIF($im);
imagedestroy($im);
?>
__________________
Follow Surpass on Twitter, Facebook and FriendFeed
Check out interesting finds on the Surpass Blog
Kayla is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
These users thank Kayla for this great post!
2BitWannabe (February 7th, 2007), braincracking (September 10th, 2007), Brandonnn (February 1st, 2007), ceo (November 4th, 2007), Cøbra (March 5th, 2007), DewKnight (February 1st, 2007), Edwin (February 1st, 2007), Gaia (February 1st, 2007), ice2cu (January 20th, 2008), JadedSouls (January 10th, 2008), Kya (August 19th, 2007), lovetrick (September 19th, 2007), lucifer.dejos (February 28th, 2007), musicman2059 (February 6th, 2007), newbees (February 9th, 2007), oracleredux (February 9th, 2007), roxana (November 20th, 2007), Roxy (December 20th, 2007), Smo_Bob (September 20th, 2007), Zeggy (December 20th, 2007), ~ K ~ (August 26th, 2007)
Old February 1st, 2007, 6:38 AM   #2 (permalink)
Surpassing Dutch
Super #1
 
Edwin's Avatar
 
Joined in Sep 2004
Lives in Arnhem, the Netherlands
Hosted on SH98
2,296 posts
Gave thanks: 166
Thanked 39 times
Okay, will do so
__________________
sh98
Edwin is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
This user thanks Edwin for this great post!
Kayla (February 1st, 2007)
Old February 1st, 2007, 6:43 AM   #3 (permalink)
tealeaf
Surpass Staff
 
Joined in May 2003
Lives in Orlando
24,047 posts
Gave thanks: 908
Thanked 771 times
Wow, I feel the open server and forum communication reaching new heights already.
__________________
Follow Surpass on Twitter, Facebook and FriendFeed
Check out interesting finds on the Surpass Blog
Kayla is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old February 1st, 2007, 6:53 AM   #4 (permalink)
Registered User
Fresh Surpasser
 
Joined in Jun 2006
21 posts
Gave thanks: 1
Thanked 0 times
What exactly does it mean?
Which load is very bad?

I am shocked, to see, that against your 0.24 I have loads of 2-over 3.0.
__________________
love, Martina.

Sites at surpass: http://inspirationally.org and http://johnny-depp.org

SH 100
server
Martina is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old February 1st, 2007, 7:27 AM   #5 (permalink)
minor deity
Super #1
 
Bigjohn's Avatar
 
Joined in Apr 2004
Lives in Georgia
Hosted on XEON
7,262 posts
Gave thanks: 20
Thanked 91 times
On a XEON processor, loads over 5-6 are bad. On a dual core Opteron thing still work up to 7-8 range.

Of course, it's best for your loads to be around 1 or lower.
__________________
Proud to be a Surmunity Mod!
XEON PASS60 PASS61
Make a fundamental difference!
My Sites:
Curious about Brewing Beer? Join the community!
>>>>> Some Change is GOOD! Keep your paycheck! Support the Fair Tax
Get into an Art museum
Victorian London
It's your brain -ON WEB - mybrainhost.com (under development)
What SHOULD Government do? Much Less than it Does!
Bigjohn is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
These users thank Bigjohn for this great post!
ceo (November 4th, 2007), Kickersny.com (February 1st, 2007), Martina (February 1st, 2007)
Old February 1st, 2007, 8:19 AM   #6 (permalink)
Surpass Fan
On a golden path...
 
Joined in Mar 2006
Hosted on SH100
429 posts
Gave thanks: 63
Thanked 17 times
I'll give it a try.
Sentinel is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old February 1st, 2007, 8:20 AM   #7 (permalink)
minor deity
Super #1
 
Bigjohn's Avatar
 
Joined in Apr 2004
Lives in Georgia
Hosted on XEON
7,262 posts
Gave thanks: 20
Thanked 91 times
I'll have to see if I can figure a way to modify the script. Make the color of the bar change...
__________________
Proud to be a Surmunity Mod!
XEON PASS60 PASS61
Make a fundamental difference!
My Sites:
Curious about Brewing Beer? Join the community!
>>>>> Some Change is GOOD! Keep your paycheck! Support the Fair Tax
Get into an Art museum
Victorian London
It's your brain -ON WEB - mybrainhost.com (under development)
What SHOULD Government do? Much Less than it Does!
Bigjohn is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old February 1st, 2007, 8:53 AM   #8 (permalink)
Registered User
Super #1
 
Joined in Jul 2003
Lives in So. NJ
1,557 posts
Gave thanks: 0
Thanked 9 times
Good idea.
__________________
Dime13 | Pass17
snide is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old February 1st, 2007, 8:55 AM   #9 (permalink)
Registered User
Super #1
 
Joined in Jul 2003
Lives in So. NJ
1,557 posts
Gave thanks: 0
Thanked 9 times
This is a good idea. I have to figure out why it doesn't work on my dedicated.
__________________
Dime13 | Pass17
snide 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