From 7b8c0603def20501fd5f8f7e2a9466c514f5570e Mon Sep 17 00:00:00 2001 From: Charles JUDITH Date: Mon, 21 May 2018 21:34:50 +0200 Subject: [PATCH] Improve slave_running check The current code only consider condition Slave_SQL_Running is yes and then send slave_running equal 1. We should consider both of condition are Slave_IO_Running and Slave_SQL_Running to set the value of slave_running metric. --- mysql.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql.py b/mysql.py index 95f9bb1..b4135e8 100644 --- a/mysql.py +++ b/mysql.py @@ -398,8 +398,8 @@ def fetch_mysql_slave_stats(conn): if 'delay' in row and row['delay'] != None: status['slave_lag'] = row['delay'] - status['slave_running'] = 1 if slave_row['Slave_SQL_Running'] == 'Yes' else 0 - status['slave_stopped'] = 1 if slave_row['Slave_SQL_Running'] != 'Yes' else 0 + status['slave_running'] = 1 if slave_row['Slave_SQL_Running'] == 'Yes' and slave_row['Slave_IO_Running'] == 'Yes' else 0 + status['slave_stopped'] = 1 if slave_row['Slave_SQL_Running'] != 'Yes' or slave_row['Slave_IO_Running'] != 'Yes' else 0 return status def fetch_mysql_process_states(conn):