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 December 1st, 2007, 3:03 PM   #136 (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
Thought I would post my new script that I had on this other thread (Server Load Fun), here so that my most recent version is on this thread as well:

PHP Code:
<?php
/* name:        serverload.php
   Author:      Jesse Chilcott, with further modification by Mark Headrick
   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(112,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);
$red_alert imagecolorallocate($im255,0,0);
$orange_alert imagecolorallocate($im255,85,0);
$bordercolor imagecolorallocate($im0,0,0);
$bordercolor2 imagecolorallocate($im40,40,40);
$graph_width 27;  // number of pixels inside black rectangle.
$cpus 4;          // number of cpus on server
$green_limit $cpus;   // anything below this is considered below 100% server load, 1 per cpu.
$orange_limit 1.5 $cpus;  // anything between this and green_limit is orange, 100-150%, anything above is red
$graph_limit 2.5 $cpus;    // this is the upper limit of the range of server load values...  adjust to your server 
                    


/* 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";
        }



$xLoc 23;
$yLoc 0;

//$loadav = 4;

/* over lap background image from the right with a white rectangle */
imagefilledrectangle $im,0$width$height$fillcolor1 );
imagefilledrectangle $im,020$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") {
     if (
$loadav $green_limit) {
         if (
$loadav <= $orange_limit) {
            
$metercolor $orange_alert
        } else {
            
$metercolor $red_alert;
        }
     }
    
$percent = ($loadav 100) / $green_limit;
    
$graph_percent = ($loadav 100) / $graph_limit;
    
$meterwidth = ($graph_percent 100) * $graph_width;
    if (
$meterwidth $graph_width) {
        
$meterwidth $graph_width;
        
    }
     
     
$meter_hundred_percent = ($green_limit $graph_limit) * $graph_width;
    
imagefilledrectangle $im54 ,454 $meterwidth$height-6$metercolor );
    
imagerectangle $im54,454+27$height-6$bordercolor2 );  // outside meter border
     
imagerectangle $im54,454+$meter_hundred_percent$height-6$bordercolor2 );  // 100% meter line border
     
imagestring($im286$yLocnumber_format($percent,0).'%'$textcolor);
}
/* output gif image to browser */
header("Content-type: image/gif");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");             // Date in the past
header("Cache-Control: no-cache, must-revalidate");           // HTTP/1.1
header("Pragma: no-cache");                                   // HTTP/1.0
imageGIF($im);
imagedestroy($im);
?>
As far as this working on a Windows Server? Well.. No. First off, you'd have to install PHP with the GD module if it wasn't installed and configure IIS to use it (unless you've installed Apache and using it instead, which is what I have done to most closely mimic the hosting environment at Surpass). Second, the "get server load" section will not work at all in Windows. You'd have to use some Windows command line function to get the CPU usage from Task Manager or something which I don't know what it would be as it's something I've never needed to find out or mess with. Hmm... and now my curiosity is up.
MarkRH is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
These users thank MarkRH for this great post!
Patty (December 1st, 2007), Prig (January 7th, 2008)
Old December 1st, 2007, 4:55 PM   #137 (permalink)
Registered User
Excelling Contributor
 
Joined in Feb 2005
536 posts
Gave thanks: 84
Thanked 24 times
hehehe.... curiosity is good.

My Windows server is with you guys. PHP is enabled.

Tks for posting your script. I'll try it out.

EDIT: Love your button!!
__________________
Patty

Pass 57 | Dime999 | SH 110

Last edited by Patty; December 1st, 2007 at 4:57 PM.
Patty is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old December 1st, 2007, 9:01 PM   #138 (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
thanks for this i'm using it...
__________________
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 January 6th, 2008, 10:30 PM   #139 (permalink)
dad
Registered User
On a golden path...
 
dad's Avatar
 
Joined in Jan 2004
Lives in orillia canada
Hosted on solacehosting
435 posts
Gave thanks: 4
Thanked 16 times
i was just reading through this post and on this link i get a call to access a cpanel account ...perhaps it should be checked and fixed

[Self-serve] Server Load Button
__________________
"colocation" is a nice way to say im codependant on surpass
www.solacehosting.com
www.christopherforlife.com
dad is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old January 7th, 2008, 2:26 AM   #140 (permalink)
H
after g, before i
Resident.
 
H's Avatar
 
Joined in Jul 2004
Lives in N,BC,CA
8,059 posts
Gave thanks: 48
Thanked 129 times
I'm sure a modera... oh, we don't have moderators anymore. I'm sure an admin will fix this.
H is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old January 7th, 2008, 8:26 AM   #141 (permalink)
is a
Comfy Contributor
 
Prig's Avatar
 
Joined in Jul 2004
Lives in CT
Hosted on Pass79
265 posts
Gave thanks: 11
Thanked 8 times
Quote:
Originally Posted by MarkRH View Post
Thought I would post my new script
Thanks. I just updated the script on my server.
__________________
Prig is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old January 7th, 2008, 8:56 AM   #142 (permalink)
Dan
Staff of Surpass
Super #1
 
Dan's Avatar
 
Joined in Apr 2007
2,692 posts
Gave thanks: 146
Thanked 179 times
Quote:
Originally Posted by dad View Post
i was just reading through this post and on this link i get a call to access a cpanel account ...perhaps it should be checked and fixed

[Self-serve] Server Load Button
Looks to be in a sig, which I don't think I have powers to edit
__________________
D4nz Net - Surpass Help Desk - NES Forever
Use the thanks button. It works!
AIM: dansorl
Dan is online now  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old January 7th, 2008, 12:35 PM   #143 (permalink)
Surpass Abuse Admin
Super #1
 
removed's Avatar
 
Joined in Mar 2005
Lives in Houston, TX
Hosted on NONE
7,796 posts
Gave thanks: 11
Thanked 277 times
Only one person here does.
__________________
Unofficial IRC Channel: #surpass EFNet
Unofficial = No official support. Support requests can be submitted to our helpdesk.
removed is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old January 7th, 2008, 12:44 PM   #144 (permalink)
H
after g, before i
Resident.
 
H's Avatar
 
Joined in Jul 2004
Lives in N,BC,CA
8,059 posts
Gave thanks: 48
Thanked 129 times
I remember a time when moderators could edit signatures.... I think I know why the edit ability has been removed from the higher powers. Oh, some good times were had back in the day...
H 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