hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : Access server uptime / loads etc
Reply

Programming Discussion Discussions related to web programming languages and other related issues. Topics may include configuration, optimization, practical usage and database connectivity.
Forum Jump

Access server uptime / loads etc

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 04-14-2009, 08:11 AM
SH-Dave SH-Dave is offline
WHT Addict
 
Join Date: Jul 2003
Posts: 120

Access server uptime / loads etc


Im a reseller so dont have full root access.
Can anyone advise how i would access the server uptime & information (ie loads, hdd space etc)

David

__________________
David Spalton
www.solidwebservices.net
European & US Webhosting at Affordable Prices
UK: 033 0001 1098 | USA: +1 (347) 878 2932

Reply With Quote


Sponsored Links
  #2  
Old 04-14-2009, 10:27 AM
HostXV HostXV is offline
Aspiring Evangelist
 
Join Date: Feb 2008
Location: Texas, USA
Posts: 429
Well, you can use HyperSpin to keep track of your UpTime. As for the Server Information, HDD Space, etc, those should be under your WHM 'Server Information'. If your provider does not allow you to view it, maybe request it from them. I have a script (I'll find it and give it to you) that shows every detail of a server, HDD Information, mounts, etc. I use this script all the time.

__________________
██ HostXV, LLC -- Shared, Resellers, Business, VPS & Dedicated Servers.
██ cPanel/WHM, Fantastico, Softaculous, RVSkins, RVSite Builder, Hardened & Shielded Servers. 100% Secure!

Reply With Quote
  #3  
Old 04-14-2009, 01:13 PM
SH-Dave SH-Dave is offline
WHT Addict
 
Join Date: Jul 2003
Posts: 120
The script would be perfect.
I have access to the info just looking to dispaly it outside cpanel

Thank you

__________________
David Spalton
www.solidwebservices.net
European & US Webhosting at Affordable Prices
UK: 033 0001 1098 | USA: +1 (347) 878 2932

Reply With Quote
Sponsored Links
  #4  
Old 04-14-2009, 01:36 PM
HostXV HostXV is offline
Aspiring Evangelist
 
Join Date: Feb 2008
Location: Texas, USA
Posts: 429
Hey,

Are you looking for something like this?

View: Click Here

That's what I use.

__________________
██ HostXV, LLC -- Shared, Resellers, Business, VPS & Dedicated Servers.
██ cPanel/WHM, Fantastico, Softaculous, RVSkins, RVSite Builder, Hardened & Shielded Servers. 100% Secure!

Reply With Quote
  #5  
Old 04-14-2009, 01:44 PM
SH-Dave SH-Dave is offline
WHT Addict
 
Join Date: Jul 2003
Posts: 120
yep that would be exactly something that i would be looking for

David

__________________
David Spalton
www.solidwebservices.net
European & US Webhosting at Affordable Prices
UK: 033 0001 1098 | USA: +1 (347) 878 2932

Reply With Quote
  #6  
Old 04-14-2009, 02:02 PM
HostXV HostXV is offline
Aspiring Evangelist
 
Join Date: Feb 2008
Location: Texas, USA
Posts: 429
Here you go.

Code:
<? 
// Set the services you want the script to check.
// You can add more by just adding a line "servers name"=>"host/IP:port number",
// You can use game servers or anything.
// e.g. "IRCdaemon"=>"localhost:6667",
$services = array( 
    "http"=>"localhost:80", 
    "ssh"=>"localhost:22", 
//    "telnet"=>"localhost:23", 
    "ftp"=>"localhost:21", 
//    "smtp"=>"localhost:25", 
    "pop3"=>"localhost:110", 
    "mysql"=>"localhost:3306"
    ); 

// Variables at the top of the page, date, uptime etc.
$date = date("l, M d, Y - h:i:s A"); 
$version = `uname -sr`; 
$name = `hostname`; 
$uptime = `uptime`; 
 
// df command function, formatted into a table
function output_df() 
{ 
    $disk = `df`; 
    $lines = split("\n", $disk); 
    echo "<table border=\"0\" align=\"center\" cellpadding=\"1\" cellspacing=\"1\">"; 
    for ($i = 0; $i < sizeof($lines) && strlen($lines[$i]) > 1; $i++) 
    { 
        $cols = preg_split("/[\s]+/", $lines[$i]); 
        if ($i == 0) 
            echo "<tr bgcolor=\"black\"><font color=orange>"; 
        else 
            echo "<tr>"; 
        for ($j = 0; $j < 6; $j++) 
        { 
            if ($j == 0 || $j == 5) 
                $align = "left"; 
            else if ($j == 1 || $j == 2 || $j == 3) 
                $align = "right"; 
            else if ($j == 4) 
                $align = "center"; 
                 
            echo "<td align=$align> <font face=\"Verdana\" size=\"1\" color=\"orange\">$cols[$j]</font> </td>"; 
        } 
        echo "</font></tr>"; 
    } 
    echo "</table>"; 
} 

// free comand function, formatted into a table
function output_free() 
{ 
    $free = `free`; 
    $lines = split("\n", $free); 
    echo "<table border=\"0\" align=\"center\" cellpadding=\"1\" cellspacing=\"1\">"; 
    for ($i = 0; $i < sizeof($lines) && strlen($lines[$i]) > 1; $i++) 
    { 
        if ($i == 2) $i++; 
        $cols = preg_split("/[\s]+/", $lines[$i]); 
        if ($i == 0) 
            echo "<tr bgcolor=\"black\">"; 
        else 
            echo "<tr>"; 
        foreach ($cols as $data) 
            echo "<td align=right> <font face=\"Verdana\" size=\"1\" color=\"orange\">$data</font> </td>"; 
        echo "</tr>"; 
    } 
    echo "</table>"; 
} 

// info grabbind done, onto the html
?> 
<table border="0" align="center" cellpadding="1" cellspacing="0">
<tr><td>
<p><font face="Verdana" size="1"><b>System Status:</b> <? echo $name ?><br><b>Time:</b> <? echo $date ?></font></p> 
<font face="Verdana" size="1"> 
<? echo $version ?><br> 
<? echo $uptime ?> 
<p><table>
<b>Services:</b><br>
<tr bgcolor="black"><td><font face="Verdana" size="1" color="orange">Status</font></td><td><font face="Verdana" size="1" color="orange">Service</font></td><td><font face="Verdana" size="1" color="orange">Host</font></td></tr> 
<? 
foreach ($services as $name=>$location) 
{ 
    list($host, $port) = split(":",$location); 
    $running = fsockopen($host, $port, $errno, $errstr, 30); 
    if (!$running) 
        $status_color = "red"; 
    else 
    { 
        fclose($running); 
        $status_color = "green"; 
    } 
    echo "<tr><td align=center><div align=\"center\" style=\"font-size: 13pt; color: $status_color\" width=\"15\" height=\"15\"><b>?</b></div></td><td><font face=\"Verdana\" size=\"1\">$name</font></td><td><font face=\"Verdana\" size=\"1\">$host</font></td></tr>"; 
} 
?> 
</table></p>
<b>Memory:</b><br>
<? output_free(); ?><br>
<b>Drive Info:</b><br>
<? output_df(); ?> 
</font>
</td></tr></table>

__________________
██ HostXV, LLC -- Shared, Resellers, Business, VPS & Dedicated Servers.
██ cPanel/WHM, Fantastico, Softaculous, RVSkins, RVSite Builder, Hardened & Shielded Servers. 100% Secure!

Reply With Quote
  #7  
Old 04-14-2009, 04:37 PM
SH-Dave SH-Dave is offline
WHT Addict
 
Join Date: Jul 2003
Posts: 120
thanks for the script, however does not work with shell_exec disabled, grr

Annoying me now

David

__________________
David Spalton
www.solidwebservices.net
European & US Webhosting at Affordable Prices
UK: 033 0001 1098 | USA: +1 (347) 878 2932

Reply With Quote
  #8  
Old 04-14-2009, 04:44 PM
HostXV HostXV is offline
Aspiring Evangelist
 
Join Date: Feb 2008
Location: Texas, USA
Posts: 429
Oh, that's not good.

__________________
██ HostXV, LLC -- Shared, Resellers, Business, VPS & Dedicated Servers.
██ cPanel/WHM, Fantastico, Softaculous, RVSkins, RVSite Builder, Hardened & Shielded Servers. 100% Secure!

Reply With Quote
  #9  
Old 04-14-2009, 04:49 PM
SH-Dave SH-Dave is offline
WHT Addict
 
Join Date: Jul 2003
Posts: 120
is there anyway to disable it for just that domain?

David

__________________
David Spalton
www.solidwebservices.net
European & US Webhosting at Affordable Prices
UK: 033 0001 1098 | USA: +1 (347) 878 2932

Reply With Quote
  #10  
Old 04-14-2009, 04:53 PM
HostXV HostXV is offline
Aspiring Evangelist
 
Join Date: Feb 2008
Location: Texas, USA
Posts: 429
I'm not exactly sure. I hope someone else can assist you in this question.

__________________
██ HostXV, LLC -- Shared, Resellers, Business, VPS & Dedicated Servers.
██ cPanel/WHM, Fantastico, Softaculous, RVSkins, RVSite Builder, Hardened & Shielded Servers. 100% Secure!

Reply With Quote
  #11  
Old 04-14-2009, 05:16 PM
sasha sasha is offline
Hail Eris !
 
Join Date: Oct 2002
Location: Canada
Posts: 3,100
If you can use cron to schedule jobs on server, you could make small script that will gather data for you and have it run every minute. Something like this:
Code:
#!/bin/sh
DATA_DIR=/home/username/html/data/
uname -sr > $DATA_DIR/version
hostname >  $DATA_DIR/hostname
uptime > $DATA_DIR/uptime
free > $DATA_DIR/free
df > $DATA_DIR/df
... and then from your php rather then calling exec you read data from files with file_get_contents()

So instead
PHP Code:
$version = `uname -sr`; 
$name = `hostname`; 
$uptime = `uptime`; 
....
function 
output_df() 

    
$disk = `df`; 

...
function 
output_free() 

    
$free = `free`;
... 
You would have
PHP Code:
$DATA_DIR '/home/username/html/data/';

$version file_get_contents("$DATA_DIR/version"); 
$name file_get_contents("$DATA_DIR/hostname"); 
$uptime file_get_contents("$DATA_DIR/uptime"); 
....

function 
output_df() 

global 
$DATA_DIR;
    
$disk file_get_contents("$DATA_DIR/df"); 

...
function 
output_free() 

global 
$DATA_DIR;
    
$disk file_get_contents("$DATA_DIR/free"); 


Last edited by sasha; 04-14-2009 at 05:22 PM.
Reply With Quote
  #12  
Old 04-14-2009, 06:20 PM
SH-Dave SH-Dave is offline
WHT Addict
 
Join Date: Jul 2003
Posts: 120
ive tried using file_get_contents for the /proc/uptime scripts but getting open base dir restrictions.

Would the method of home/username/html/data work instead?

David

__________________
David Spalton
www.solidwebservices.net
European & US Webhosting at Affordable Prices
UK: 033 0001 1098 | USA: +1 (347) 878 2932

Reply With Quote
  #13  
Old 04-14-2009, 06:54 PM
LH-Danny LH-Danny is offline
Aspiring Evangelist
 
Join Date: Feb 2008
Location: United Kingdom
Posts: 442
There was a free script on sourceforge that did exactly this. I will have to take a look and find it for you.

Reply With Quote
  #14  
Old 04-14-2009, 06:57 PM
LH-Danny LH-Danny is offline
Aspiring Evangelist
 
Join Date: Feb 2008
Location: United Kingdom
Posts: 442
Nevermind, I've found it!

Link: http://phpsysinfo.sourceforge.net/

There is also some demo links on there, so you can see what it is like before you download. I'm not sure if it works with shell_exec disabled though.

Reply With Quote
  #15  
Old 04-14-2009, 07:15 PM
SH-Dave SH-Dave is offline
WHT Addict
 
Join Date: Jul 2003
Posts: 120
jus trying that

was hoping to write my own

David

__________________
David Spalton
www.solidwebservices.net
European & US Webhosting at Affordable Prices
UK: 033 0001 1098 | USA: +1 (347) 878 2932

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
Colocation America Launches Colocation Service for Mac Mini Users Web Hosting News 2013-02-27 16:42:41
Uptime Institute Symposium 2012 Web Hosting Events 2012-05-07 15:27:28
Colocation America Maintains 100 Percent Uptime for Third Consecutive Year Web Hosting News 2012-01-12 16:17:47
Web Host CoolHandle Uses CloudLinux to Improve Server Performance Web Hosting News 2011-08-19 16:27:55
Web Host Gazzin.com Upgrades Reseller and VPS Plans Web Hosting News 2011-07-29 18:48:35


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

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 Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?