The nagios monitoring scripts for mysql should be a good start.
If you want to monitor your database with this kind of email alerts, you should really try to setup nagios or some similar software as this is exactly the purpose of a monitoring software.
Once I have asked the similar question there was ultimate Answer. Please have a look at it.
Then you will be clear with the
Seconds_Behind_Master
The Seconds_Behind_Master is not a good Parameter for monitoring the replication.
Try to use mk-heartbeat
monitoring script. I use that and it's really reliable.
For documentation of mk-heartbeat, click here.
UPDATE
Try MONyog Web based application which has separate Replication tab and pretty easy to use, with lots of features
This will let you know Status of all slaves and Master on Replication tab for example: Replication topology, Master detail, Slave detail in a tabular format. Also, using Monitors page, you can get alert if seconds_behind_master lags behind certain threshold value.
You can also use the MySQL Community Replication Monitor
The community driven MySQL replication monitoring tools is a collection of scripts in SQL and other languages, to achieve the same result that others can get with expensive applications.
Best Answer
First, let's identify each status variable:
The only place I can think of where these number would make sense would be in the network. These status values represent the amount of data passing in and out of DB Connections. These bytes would most likely be visible from another perspective: the Operating System.
You could measure the amount on incoming/outgoing traffic in netstat against MySQL's view of it. If the amount of incoming data is low, or if the amount of outgoing data from MySQL is significantly higher than netstat says, check MySQL and/or the network. You may also want to look for any signs of dropped packets along any interfaces.
In light of this, when it comes to tuning, the only thing I can think of that you may want to tune is setting two things:
What is a MySQL Packet ?
According to the page 99 of the Book
here are paragraphs 1-3 explaining it:
Given this information, you may want to