@@ -112,6 +112,13 @@ class CheckMysqlReplicationStatus < Sensu::Plugin::Check::CLI
112112 default : 1 ,
113113 proc : proc { |s | s . to_i }
114114
115+ option :lag_outlier_report ,
116+ long : '--lag-outlier-report=VALUE' ,
117+ description : 'Level to report lag outlier' ,
118+ default : :ok ,
119+ proc : proc ( &:to_sym ) ,
120+ in : %i( ok warning critical )
121+
115122
116123 def detect_replication_status? ( row )
117124 %w[
@@ -199,6 +206,8 @@ def run
199206 retries = config [ :lag_outlier_retry ]
200207 unknown "Invalid value for --lag-outlier-retry" if retries < 0
201208
209+ lag_outlier = 0
210+
202211 while retries >= 0
203212 row = query_slave_status ( db )
204213 ok 'show slave status was nil. This server is not a slave.' if row . nil?
@@ -213,13 +222,22 @@ def run
213222 break if retries < 0 || replication_delay < config [ :lag_outlier_threshold ]
214223
215224 # Outlier detected - wait and retry
225+ lag_outlier = [ lag_outlier , replication_delay ] . max
216226 sleep config [ :lag_outlier_sleep ]
217227 end
218228
219229 message = "replication delayed by #{ replication_delay } "
220- # TODO (breaking change): Thresholds are exclusive which is not consistent with all other checks
221- critical message if replication_delay > config [ :crit ]
222- warning message if replication_delay > config [ :warn ]
230+ message = "#{ message } , with max. outlier at #{ lag_outlier } " if lag_outlier > 0
231+
232+ # Special reporting if outlier condition was met but calmed down
233+ if lag_outlier > 0 && replication_delay == 0
234+ critical message if config [ :lag_outlier_report ] == :critical
235+ warning message if config [ :lag_outlier_report ] == :warning
236+ else
237+ # TODO (breaking change): Thresholds are exclusive which is not consistent with all other checks
238+ critical message if replication_delay > config [ :crit ]
239+ warning message if replication_delay > config [ :warn ]
240+ end
223241 ok "#{ ok_slave_message } , #{ message } "
224242 rescue Mysql ::Error => e
225243 errstr = "Error code: #{ e . errno } Error message: #{ e . error } "
0 commit comments