Chapter 18 . Replication 539 (Web hosting reseller) The previous code

Chapter 18 . Replication 539 The previous code runs the system command ifconfig and does some minor massaging to get the IP address of this host. $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(); Nothing new for this section of the script. Standard Perl-DBI. Cross-For more information on the Perl-DBI and MySQL DBD, see Chapter 15. Reference The next snippet, however, shows some essential differences: while ((@status) = ( $sth->fetchrow_array() ) ) { $host = $status[0]; $file = $status[4]; $position = $status[5]; $run = $status[6]; } The previous section takes the output from the SHOW SLAVE STATUSstatement and parses it into variables that make sense for the various columns in the statement. 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 final section of the script evaluates the Slave_running column. Under normal operations the Slave_runningcolumn is Yes if replication is running. However, if the result is anything other than Yes, an e-mail will be sent to an administrator. The e-mail contents from the script are shown in Figure 18-12: This script could be run on a schedule with cron so that the system is automatically monitored.
You want to have a cheap webhost for your apache application, then check apache web hosting services.

Leave a Reply