def slave_lag(**connection_args):
 dbc = _connect(**connection_args)
 if (dbc is None):
  return (-3)
 cur = dbc.cursor(MySQLdb.cursors.DictCursor)
 qry = 'show slave status'
 try:
  _execute(cur, qry)
 except MySQLdb.OperationalError as exc:
  err = 'MySQL Error {0}: {1}'.format(*exc)
  __context__['mysql.error'] = err
  log.error(err)
  return (-3)
 results = cur.fetchone()
 if (cur.rowcount == 0):
  return (-1)
 elif (results['Slave_IO_Running'] == 'Yes'):
  return results['Seconds_Behind_Master']
 else:
  return (-2)

def slave_lag ( ** connection_args ) : dbc = _connect ( ** connection_args ) if ( dbc is None ) : return ( - 3 ) cur = dbc . cursor ( MySQLdb . cursors . DictCursor ) qry = 'show slave status' try : _execute ( cur , qry ) except MySQLdb . OperationalError as exc : err = 'MySQL Error {0}: {1}' . format ( * exc ) __context__ [ 'mysql.error' ] = err log . error ( err ) return ( - 3 ) results = cur . fetchone ( ) if ( cur . rowcount == 0 ) : return ( - 1 ) elif ( results [ 'Slave_IO_Running' ] == 'Yes' ) : return results [ 'Seconds_Behind_Master' ] else : return ( - 2 )
return the number of seconds that a slave sql server is lagging behind the master .