onStatus method

void onStatus(
  1. String nodeId,
  2. MetricPoint point
)

Judges point — a node's latest reading — against every threshold rule.

Implementation

void onStatus(String nodeId, MetricPoint point) {
  for (final rule in rules) {
    if (rule.metric == AlertMetric.offline) continue;
    _judge(
      nodeId: nodeId,
      rule: rule,
      breached: rule.breachedBy(point),
      value: switch (rule.metric) {
        AlertMetric.cpu => point.cpuPercent,
        AlertMetric.memory => point.memoryPercent,
        AlertMetric.disk => point.storagePercent,
        AlertMetric.offline => null,
      },
    );
  }
}