Clear conditions

The clear condition is an optional part of the rule that determines when a network condition or event is no longer occurring.

When an agent is created, the condition associated with the rule is active and the clear condition is inactive. When the condition becomes true:

  • The condition becomes inactive and the clear condition becomes active.

  • The condition does not become active again until the clear condition is true.

Using a clear condition can help to prevent the numerous alerts that can occur when monitored data fluctuates narrowly above and below the threshold.

For example, consider a rule that sets the alert level to critical when CPU utilization exceeds 90%, and removes the alert level when the condition is no longer true.
  • If you do not define a clear condition and the CPU utilization frequently fluctuates between 85% and 91%, the monitor generates alerts and then removes the alert level every time the fluctuation occurs.

  • Instead, if you define a clear condition to be when the CPU utilization drops below 70%, the following behavior occurs:

    • The first time the CPU utilization exceeds 90%, the alert level is set to critical. The condition becomes inactive and it is no longer evaluated. Instead, the clear condition becomes active, and is evaluated at regular intervals.

    • The CPU utilization can fluctuate from above 90% to as low as 70%, an unlimited number of times. The alert level remains critical and additional alerts are not generated.

    • The clear action—removing the alert level—is executed only when the clear condition becomes true—the CPU utilization drops below 70%. The clear condition becomes inactive and is no longer evaluated. The condition becomes active again and is evaluated at regular intervals.

In effect, one of the ways you can use a clear condition is to use it in combination with the condition to set both a high threshold and a low threshold.

You define a clear condition using the clear_condition function. The clear_condition function contains the condition expression (in quotes) and, optionally, any parameters used in the condition expression.

Example of a clear condition in a monitor:

self.monitor = Monitor(AverageOverTime("/rest/v1/system/subsystems/management_module/1%2F5?attributes=resource_utilization.cpu", "5 minutes")
self.rule = Rule("")
self.rule.condition("{} > 90", [self.monitor])
seld.rule.action("ALERT_LEVEL", AlertLevel.CRITICAL)
self.rule.clear_condition("{} < 70", [self.monitor])
self.rule.clear_action(self.set_normal)