538 Part V . Advanced Performance Using Perl (Web hosting uk)
538 Part V . Advanced Performance Using Perl you can quickly build a custom monitoring solution for your replication implementation. At the most basic level, an administrator has to know when a slave server stops replicating. What methods you use to notify the administrator upon failure are dependent on your needs. Examine the following code: #!/usr/bin/perl use DBI; $thishost = `ifconfig | grep -1 eth | grep inet | cut -d : -f2 | cut -d -f1`; $dbh = DBI->connect( DBI:mysql::localhost ,undef, boo ); # Error Checking using an IF test. if (! $dbh) { print Connection unsuccessful!nn ; } $query = SHOW SLAVE STATUS ; $sth = $dbh->prepare($query); $sth->execute(); while ((@status) = ( $sth->fetchrow_array() ) ) { $host = $status[0]; $file = $status[4]; $position = $status[5]; $run = $status[6]; } if ($run ne Yes ) { open MAIL, |mail -s Replication Problem: $thishost suehring@braingia.org ; print MAIL REPLICATION PROBLEM on $thishostn ; print MAIL Replicating from: $hostn ; print MAIL Replication file: $file. Position: $positionn ; print MAIL Replication running: $runn ; close (MAIL); } The code shows a small but useful monitoring script for watching slave replication. If something goes wrong and the slave reports a running status other than Yes , an e-mail will be sent to an administrator. Examining code snippets for some interesting (and not-so-interesting) areas: $thishost = `ifconfig | grep -1 eth | grep inet | cut -d : -f2 | cut -d -f1`;
You want to have a cheap webhost for your apache application, then check apache web hosting services.