Free Web Hosting Forum
Go Back   Free Web Hosting Forum > Website Building > Web Programming
Reload this Page How to display server load on 000webhost servers
Reply
 
Thread Tools Display Modes
(#1 (permalink))
Old
Bad Karma[CORE]'s Avatar
#not a funny guy at all#
Bad Karma[CORE] is on a distinguished road
 
Posts: 1,488
Join Date: May 2008
Post How to display server load on 000webhost servers - 05-13-2009, 12:57 PM

You surely all know this:
Your website is taking ages to load, the server doesn´t respond at all and your browser tells you that your site cannot be reached. This often, if not always, indicated a problem with the serverload that went through the roof. Not many free hosting services allow you to check server load so it might be a bit hard to tell if the problem is down to the server or if there is a problem with your script.

I can help you with the serverload thing. All you need to do to display the current serverload is create a PHP file (name it whatever you want, for example load.php) and copy this bit of code in it, then save it and upload it to your server:
PHP Code:
<?php
header
("Content-Type: application/rss+xml"); 
echo(
'<?xml version="1.0" encoding="ISO-8859-1"?>');
$MJ_LINK='http://'.$_SERVER['HTTP_HOST'].$_SERVER["PHP_SELF"];
?>
<rss version="2.0">

  <channel>
    <title><?php echo $_SERVER['HTTP_HOST']; ?> Server Load</title>
    <link><?php echo $MJ_LINK ?></link>
    <description>Server Load by <a href="http://www.outlaw-forum.info">Bad Karma[CORE]</a></description>
    <pubDate><?php echo date("r"); ?></pubDate>

    <?php
    
if (function_exists('sys_getloadavg')) {
        
$loadArray sys_getloadavg();
        
$load"Load: ".$loadArray[0]."/".$loadArray[1]."/".$loadArray[2];
    } else {
        
$load=@file_get_contents('/proc/loadavg');
    }
    if(!
$load) {
      
$load'Sorry, no load average available for your server';
      
$info 'PHP >= 5.1.3 or access to /proc/loadavg is required.';
    } 
?>
    <item>
        <title><?php echo $load;?></title>
        <description><![CDATA[<?php echo $info;?>]]></description>
        <pubDate><?php echo date("r"); ?></pubDate>
              <link><?php echo $MJ_LINK ?></link>
              <guid><?php echo $_SERVER['REQUEST_URI']; ?></guid>
    </item>

  </channel>

</rss>
This will display the current serverload and help to determine whether the problem is with your website or the server. Just upload the file and call it in your browser by opening
Code:
http://www.yourdomain.com/load.php
A live example of it can be seen at
badkarma.000webhost.com Server Load
Reply With Quote
(#2 (permalink))
Old
chanh's Avatar
Administrator
chanh is on a distinguished road
 
Posts: 1,372
Join Date: Dec 2008
Default 05-13-2009, 03:03 PM

Very good idea!
Thanks
Reply With Quote
(#3 (permalink))
Old
Leder678's Avatar
Senior Member
Leder678 is on a distinguished road
 
Posts: 282
Join Date: Jan 2009
Location: Norway
Send a message via MSN to Leder678
Default 05-13-2009, 07:36 PM

Great, thanks, i'll use it


Take and use: (Made by me)

Reply With Quote
(#4 (permalink))
Old
ffengfeng's Avatar
Member
ffengfeng is on a distinguished road
 
Posts: 44
Join Date: Apr 2009
Default 05-15-2009, 03:44 AM

Thx,but it's too simple.
Reply With Quote
Reply

Thread Tools
Display Modes

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 Off
Pingbacks are Off
Refbacks are Off




Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.2
vBulletin Skin developed by: vBStyles.com