Tuesday, 16th April 2024

Comment posted How to check MASTER / SLAVE MySQL nodes status – Check MySQL Replication Status by .

Recent comments by

Share this on:

Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

No Responses to “…”

  1. Thibs says:
    Firefox 11.0 Firefox 11.0 Windows 7 x64 Edition Windows 7 x64 Edition
    Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20100101 Firefox/11.0

    Hello,
    If your are interrested, here is the script I've done a few years ago to monitor the replication into my monitoring system
     
    #!/usr/bin/perl -w
    use strict;
    use DBI;
    # Script to test MySQL replication by TRD 08/01/2008

    if (scalar(@ARGV)==3) {
            #Variables
            my $dbServer="DBI:mysql:database=syslog;host=$ARGV[0]";
            my $dbUser=$ARGV[1];
            my $dbPwd=$ARGV[2];

            #Connect to DB
            my $db=DBI->connect($dbServer,$dbUser,$dbPwd) || exit 2;

            my $rs=$db->prepare('show slave status');
            $rs->execute();
            my $dr=$rs->fetchrow_hashref();
            my $Slave_IO_Running=$dr->{'Slave_IO_Running'};
            my $Slave_SQL_Running=$dr->{'Slave_SQL_Running'};
            $rs->finish();
            $db->disconnect();
            if (($Slave_IO_Running eq 'Yes') && ($Slave_SQL_Running eq 'Yes')) {
                    exit 0;
            }
            else {
                    exit 2;
            }
    }
    else {
            print "Missing parameter\n";
            exit 1;
    }
     

    View CommentView Comment
    • admin says:
      Firefox 3.6.3 Firefox 3.6.3 Windows 7 Windows 7
      Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3

      Hi Thibs,

      Long time no hear you. This is nice script.

      Only I need to change the name of the monitored database, cause right now I got error;

      # perl monitor-replication.pl localhost root password

      DBI connect(‘database=syslog;host=localhost’,’root’,…) failed: Unknown database ‘syslog’ at monitor-replication.pl line 15

      I’ve made minor modifications to your script and added some text to clear up the script is written by you as well as a link to your site http://qmailrocks.thibs.com for further reference.
      The script is here: http://www.pc-freak.net/bshscr/not-mine/monitor-replication.pl

      As it was recently Easter the passed sunday and we have the habit to great each other with the paschal Greeting. I would like to great you with our paschal Greeting Jesus is Risen!

      Best
      Georgi

      View CommentView Comment
      • Thibs says:
        Firefox 11.0 Firefox 11.0 Windows 7 x64 Edition Windows 7 x64 Edition
        Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20100101 Firefox/11.0

        Thanks for all ! Great andholy Easter to you !

        View CommentView Comment
      • Thibs says:
        Firefox 11.0 Firefox 11.0 Windows 7 x64 Edition Windows 7 x64 Edition
        Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20100101 Firefox/11.0

        Thanks for all ! Great and holy Easter to you !
        For the script, I can adapt it o allow database name beeing passed as parameter.
        Note that according to my experience, it's useless to check replication for all replicated database .. one is enough to check the whole replication status

        View CommentView Comment