WIP implementing flapping avoidance
This commit is contained in:
parent
8efa0966df
commit
0770abf2e0
@ -80,6 +80,14 @@ NOTIFY_ALARM_END=TRUE
|
|||||||
# success result, error result, command failure. Then paste the command
|
# success result, error result, command failure. Then paste the command
|
||||||
# and regex in this config, enable the check and run to verify is working.
|
# and regex in this config, enable the check and run to verify is working.
|
||||||
|
|
||||||
|
#### AVOID FLAPPING ####
|
||||||
|
# For values slowly changing, like a server cabinet temperature, a lot of start/end alarm notifications
|
||||||
|
# may be generated if the value is near the limit (e.g. alarm set to 30, temperature jumping between 30.1
|
||||||
|
# and 29.9). To avoid this, a "grace" delta can be set with:
|
||||||
|
# DELTA=0.5
|
||||||
|
# In the previous example, this make the alarm fire at 30.5 and stop at 29.5.
|
||||||
|
# If not specified, the delta is 0.
|
||||||
|
|
||||||
|
|
||||||
[system_load_1min]
|
[system_load_1min]
|
||||||
# The system load average in the last minute
|
# The system load average in the last minute
|
||||||
|
@ -169,13 +169,20 @@ class Main:
|
|||||||
|
|
||||||
# Compare detected value with equal, not equal, more than and less values
|
# Compare detected value with equal, not equal, more than and less values
|
||||||
logging.info('detected {}'.format(detectedValue))
|
logging.info('detected {}'.format(detectedValue))
|
||||||
|
|
||||||
|
# String comparison
|
||||||
if config.alarm_string_equal and (detectedValue == config.alarm_string_equal):
|
if config.alarm_string_equal and (detectedValue == config.alarm_string_equal):
|
||||||
return 'value is "{}"'.format(detectedValue)
|
return 'value is "{}"'.format(detectedValue)
|
||||||
if config.alarm_string_not_equal and (detectedValue != config.alarm_string_not_equal):
|
if config.alarm_string_not_equal and (detectedValue != config.alarm_string_not_equal):
|
||||||
return 'value is "{}", but should be "{}"'.format(detectedValue, config.alarm_string_not_equal)
|
return 'value is "{}", but should be "{}"'.format(detectedValue, config.alarm_string_not_equal)
|
||||||
if config.alarm_value_equal and (locale.atof(detectedValue) == float(config.alarm_value_equal)):
|
|
||||||
|
# Numeric comparison
|
||||||
|
numeric_value = locale.atof(detectedValue)
|
||||||
|
delta_upper = numeric_value + config.delta
|
||||||
|
delta_lower = numeric_value - config.delta
|
||||||
|
if config.alarm_value_equal and (delta_lower < float(config.alarm_value_equal) or delta_upper > float(config.alarm_value_equal)):
|
||||||
return 'value is {}'.format(detectedValue)
|
return 'value is {}'.format(detectedValue)
|
||||||
if config.alarm_value_not_equal and (locale.atof(detectedValue) != float(config.alarm_value_not_equal)):
|
if config.alarm_value_not_equal and (delta_lower > float(config.alarm_value_not_equal) or delta_upper < float(config.alarm_value_not_equal)):
|
||||||
return 'value is {}, but should be {}'.format(detectedValue, config.alarm_value_not_equal)
|
return 'value is {}, but should be {}'.format(detectedValue, config.alarm_value_not_equal)
|
||||||
if config.alarm_value_more_than and locale.atof(detectedValue) > float(config.alarm_value_more_than):
|
if config.alarm_value_more_than and locale.atof(detectedValue) > float(config.alarm_value_more_than):
|
||||||
return 'value is {}, but should not exceed {}'.format(locale.atof(detectedValue), config.alarm_value_more_than)
|
return 'value is {}, but should not exceed {}'.format(locale.atof(detectedValue), config.alarm_value_more_than)
|
||||||
|
Loading…
Reference in New Issue
Block a user