Creating a Website / Server Monitoring Script

Creating a Website / Server Monitoring ScriptHi there!

I have created a script which allows users to check to see if their server is online. Obviously running this script from the same server and trying to check your server status whilst its down its too clever, so try using an include or iframe from a free hosting company.

Ok, I will be checking my website, jamesterror.net on port 80 which is the HTTP port.

Firstly you'll need to setup your variables.

<?php
$site = 'jamesterror.net';
$port = '80';

This is setting up the site you will be checking and on the port you will be checking.

$check = fsockopen( "$site", "$port", $errno, $errstr, 6 );

This t string $check is now making a connection to a website by using the 'fsockopen' command.

Now we are going to add the part where it say if the server is offline. I have decided to put it in red font so it stands out.

if ( ! $check ){ echo "<font color="#FF0000">Server is Currently Down!</font>";

What this has now done is, if $check (connection to the site) is unable to connect it was echo the message "Server is Currently Down".

We then add the final lines,

}
else{ echo "<font color="#009900">Everything is fine!</font>";}

We now use the ELSE statement, this is so if there is a connection the page will show "Everything is fine!"

Here is the complete script

<?php
$site = 'jamesterror.net';
$port = '80';
$check = fsockopen( "$site", "$port", $errno, $errstr, 6 );
if ( ! $check ){ echo "<font color="#FF0000">Server is Currently Down!</font>";
}
else{ echo "<font color="#009900">Everything is fine!</font>";}
?>

Thank you, James


Related Articles

  • Creating Alerts
    A simple guide to using alerts (and annoying your visitors)
  • Why web hosts and ISPs need web site monitoring
    Here are four reasons why every web host and ISP (Internet service provider) should post uptime and connectivity statistics from an independent third-party web site.
  • The Basics- JavaScript Tutorial
    To get started with JavaScript, you will want to be able to see the tag that will set a script apart from the HTML. The tags used to begin and end a script are the tags. The opening tag should appear like this
  • AIM Profile Screenname Viewer as a component of AIM Profile Designs
    Aim Profile Designs constantly develop. Read ASP Tutorial: AIM Profile Screenname Viewer. This tutorial will show you how to make a script to see who has seen your AOL Instant Messenger profile.
  • Remove Banners And Pop-Ups
    If you want to get rid of a banner on a free server and are willing to risk it, try these simple HTML tricks to remove it.
  • Client Side Scripting
    However, this is not to say that other technologies are not extremely useful. Several technologies have proven to be just as important as CGI for the average Internet developer. These technologies focus on putting the demands of computation in the hands of the client instead of the server...
  • Changing Web Hosts - Step by Step Guide
    How to switch web hosts without any downtime.
  • PHP Server to Client with No Refresh
    Although most of our companies work is template based design, the end result is always unique and adapts to each clients individual needs.
  • 5 Keys On Hosting Your Website
    Anybody who wants to put a website on the internet must decide where and how the site will be hosted.The key to deciding what you need in a hosting provider is to understand the nature of the website you are planning to put on the internet.
  • If You Don't Like The Weather... Just Wait Ten Minutes
    This old saying which addresses the variability of the weather in Montana is also applicable to the volatile market dynamics for an online business. If there is one thing that is certain about the future of online marketing, it is that it will continue to constantly change...

Contact Web Design Outsource and get started today

Need Website Designing, Development, Redesigning, Maintenance and SEO services or help growing your company's web presence? Request a free Quote Now.