This script can be useful if you have two servers with your website and you hate breakdowns, it checks is the primary server available and redirects to primary or secondary server.

CODE
#!/usr/bin/perl

##



use LWP::UserAgent;

use CGI;

$| = 1;

my $query = new CGI;

$ua = LWP::UserAgent->new;

$ua->agent("MyApp/0.1 ");



my $req = HTTP::Request->new(GET => 'http://primary.server/index.php');

$req->content_type('application/x-www-form-urlencoded');

$ua->timeout(10);

my $res = $ua->request($req);



if ($res->is_success) {

 print $query->redirect("http://primary.server/index.php");

} else {

 print $query->redirect("http://secondary.server/index.php");

}

 

 

 


Reply