Create Your Own Server Stat Script

If you would like to create your own server stat script in PHP you should first check the current server load and your portsare responding correctly, also you should aware when your service are down such as HTT, MySQL, POP/SMTP  and the users which will be the chief  indicator of a runaway script, or process.

In addition make sure your php script ALWAYS start with <?php  this tells your server that it is in fact a php script

<?php

//You can replace the domain with an IP if you wish

$site = “mysite.com”;  //this is the site you wish to check

// Let’s check our common ports 80, 21, and 110
$http = fsockopen($site, 80);
$ftp = fsockopen($site, 21);
$pop3 = fsockopen($site, 110);

if ($http) {
$status .= “<font face=\”Arial\”><font size=\”2\”><b>HTTP</b>: Working</font></font><br>”;
}
else {
$status .= “<font face=\”Arial\”><font size=\”2\”><b>HTTP</b>: Not Working</font></font><br>”;
}

if ($ftp) {
$status .= “<font face=\”Arial\”><font size=\”2\”><b>FTP</b>: Working</font></font><br>”;
}
else {
$status .= “<font face=\”Arial\”><font size=\”2\”><b>FTP</b>: Not Working</font></font><br>”;
}

if ($pop3) {
$status .= “<font face=\”Arial\”><font size=\”2\”><b>POP3/SMTP</b>: Working</font></font><br>”;
}
else {
$status .= “<font face=\”Arial\”><font size=\”2\”><b>POP3/SMTP</b>: Not Working</font></font><br>”;
}
echo(”$status”);

echo(”<hr>”);

// Users and load information
$reguptime = trim(exec(”uptime”));
if ($reguptime) {
if (preg_match(”/, *(\d) (users?), .*: (.*), (.*), (.*)/”, $reguptime, $uptime)) {
$users[0] = $uptime[1];
$users[1] = $uptime[2];
$loadnow = $uptime[3];
$load15 = $uptime[4];
$load30 = $uptime[5];
}
} else {
$users[0] = “Unavailable”;
$users[1] = “–”;
$loadnow = “Unavailable”;
$load15 = “–”;
$load30 = “–”;
}

echo(”<b>Current Users:</b> $users[0]<br>
<b>Current Load:</b> $loadnow<br><b>Load 15 mins ago:</b> $load15<br><b>Load 15 mins ago:</b> $load30<br><hr>”);

// Operating system
$fp = @fopen(”/proc/version”, “r”);
if ($fp) {
$temp = fgets($fp);
fclose($fp);

if (preg_match(”/version (.*?) /”, $temp, $osarray)) {
$kernel = $osarray[1];
preg_match(”/[0-9]{5,} (\((.* *)\)\))/”, $temp, $osarray);
$flavour = $osarray[2];
$operatingsystem = $flavour.” (”.PHP_OS.” “.$kernel.”)”;
if (preg_match(”/SMP/”, $buf)) {
$operatingsystem .= ” (SMP)”;
}
} else {
$result = “(N/A)”;
}
} else {
$result = “(N/A)”;
}

echo(”<b>Operating System:</b><br>$operatingsystem”);
?>

When you upload the above code to your server, it will display the status of your services,  the load average and your user.

Now you can work with this, and make it look however you want, add new ports, etc.

Remember, this is just a very basic stat script.

Key Issue
Make sure your host should allow the exec() funtion, in order for this to work properly.

Posted under web server by on Monday 29 September 2008 at 2:41 pm

VPS Server

VPS Hosting, virtual private server is one of the best option for both small and medium size businesses that need hosting for a customized website, VPS hosting plan is good option for those who can not afford the cost of dedicated server hosting at the moment but require almost same dedicated level of services. With Micfo’s virtual dedicated hosting you can have multiple domains hosting on a single server. It enable you to install your own software and run your own applications in secured environment. With a VPS server you can creates multiple isolated Virtual Private Servers on a single physical server to share hardware, which provide independence and maximize efficiency and performance.

While choosing a VPS host give priority to select a virtual private server hosting plan that preferably offer both linux vps hosting and window vps hosting because in case if you launch a site which need window hosting, it will save your time in searching a window VPS host providers. Also make sure the plans are geared towards the requirement of your websites which might need higher resources and secured environment.

Each VPS has its own absolute directory structure and set of dedicated applications. Each can be rebooted without having an effect on any other VPS on the physical server. This technology features ‘fair share’ scheduling of processes, memory, and network, hence each VPS receives the deserved resources and additional brust memory. The VPS features include complete virtual isolation and you get dedicated IP address and fully customize server where you can run your own applications and get root SSH level access. Within the fraction of the cost you get more likely same benefits of a dedicated server and still have same guarantees of a dedicated server.

Micfo use Virtuozzo technology which is time tested and security built up, it all has friendly residents and provide enough memory and superb network to make sure each VPS receives the deserved resources.

Posted under vps server by on Thursday 28 August 2008 at 12:45 pm