The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 23, 2019, 12:18:53 AM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: Get notified when MYSQL replication stalls?  (Read 2113 times)
nutballs
Administrator
Lifer
*****
Offline Offline

Posts: 5627


Back in my day we had 9 planets


View Profile
« on: November 12, 2009, 02:30:07 PM »

Anyone have any hint/idea of how to get notification that a mysql replication slave server is no longer updating?

Of course as I typed this, i just realized i could probably do it from php by just running the "show slave status" and looking for Slave_SQL_Running = Yes.

wonder if my base user has that priv...
Logged

I could eat a bowl of Alphabet Soup and shit a better argument than that.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #1 on: November 12, 2009, 03:02:58 PM »

If you can replicate, you can see the status of it.

that's almost exactly what I did ... cron job checks it, emails me if it's not working. Kludgy but effective.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
nutballs
Administrator
Lifer
*****
Offline Offline

Posts: 5627


Back in my day we had 9 planets


View Profile
« Reply #2 on: November 12, 2009, 03:50:07 PM »

Yep just got it working. Obviously you would trigger emails upon fail, instead of echoing, but thats semantic.

Quick and dirty:

on the slave in MYSQL:
GRANT REPLICATION CLIENT ON *.* TO 'slavemonitor'@'theremoteip' IDENTIFIED BY 'somepassword';

<?php
$dbhost 
'yourreplicationserver';
$dbuser 'slavemonitor';
$dbpass 'somepassword';

$conn mysql_connect($dbhost$dbuser$dbpass) or die('Error connecting to mysql');

$result mysql_query("show slave status;") or die(mysql_error());
$row mysql_fetch_array$result );
echo 
'IO:'.$row['Slave_IO_Running'];
echo 
'<br />';
echo 
'SQL:'.$row['Slave_SQL_Running'];
?>
Logged

I could eat a bowl of Alphabet Soup and shit a better argument than that.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #3 on: November 12, 2009, 04:54:38 PM »

I have a really strong php email class, includes send, recv, imap ... the works. you need?
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
nutballs
Administrator
Lifer
*****
Offline Offline

Posts: 5627


Back in my day we had 9 planets


View Profile
« Reply #4 on: November 12, 2009, 05:08:20 PM »

nope im good.

this is actually exactly what I am doing. i realized i will just monitor this page with zenoss (which is what I use for my monitoring), and look for "SQL:Yes" and such.
Logged

I could eat a bowl of Alphabet Soup and shit a better argument than that.
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!