Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top


I am looking for a bash script (using Perl - As that is already installed on the machine and I don't want to have to install Ruby, Python etc. just for this requirement) that will perform some simple mySQL replication monitoring of a remote Master & Slave. The script will be able to:

  • Connect to a remote mySQL master and a remote mySQL slave (cron job is running on a different machine)
  • Using the output of SHOW SLAVE STATUS; and SHOW MASTER STATUS be able to email notify:

1) A general problem with replication ie. Not running, slave threads stopped etc. 2) Whether the slave is behind in transactions (Ideally this would be configurable)

  • Email should be configurable for delivery details as well as a cooling off period. So if the cron is run every minute emails for the same error kind are only sent after the cooling off period. So instead of 10 emails for the replication not running you get 1

I have looked online for a solution, but have been unable to find anything suitable.

So if anyone can point me in the right direction I would appreciate it.

share|improve this question

migrated from Feb 24 '11 at 10:23

This question came from our site for users of Linux, FreeBSD and other Un*x-like operating systems.

It sounds like you have a very specific solution in mind - have you considered writing your own script? – Justin Ethier Feb 17 '11 at 22:00
While your question is on-topic here, there may be more expertise on other Stack Exchange where I think it is also appropriate: Server Fault and Database administration. If you want to migrate your question (you don't have to), use the flag link and ask a moderator to do it (do not repost it). – Gilles Feb 17 '11 at 22:08
Your script logic is perfectly fine, don't go for any opensource monitoring for this. Try having your monitoring as precise under your control, and have them customized whenever you need them to be. – Mannoj Mar 11 '13 at 16:28

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.

share|improve this answer

We have a little site to monitor this kind of MySql Replication. Actually, I monitor and admin like 40 MySql databases between servers and end user machines, all of them replicating like crazy daily =P

The site is

(Because of my boss I preferred to make a tinyurl, sorry hehe)

It's written in PHP. I could share some code if you want, but I don't have mailers. I prefer for that stuff. But it's quite easy to mail any error.

Good luck!

share|improve this answer
Awesome can you please share the code? – Lucky Murari Sep 9 '11 at 7:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.