Checkable::GetSeverity(): always take reachability into account

So far, Service::GetSeverity() only considered the state of its own host, i.e.
the implicit service to its own host dependency, and treated it similar to
acknowledgements and downtimes. In contrast, Host::GetSeverity() considered
reachability and treated it like a state, i.e. for the severity calculation,
the host was either up, down, or unreachable.

This commit changes the following things:
1. Make the service severity also consider explicitly configured dependencies
   by using IsReachable().
2. Prefer acknowledgements and downtimes over unreachability in the severity
   calculation so that if an already acknowledged or in-downtime services (i.e.
   already handled service) becomes unreachable, it shouln't become more
   severe.
3. To unify host and service severities a bit, hosts now use the same logic
   that treats reachability more like acknowledgements/downtimes instead of
   like a state (changing the other way around would the state from the check
   plugin would not affect the severity for unrachable services anymore).
This commit is contained in:
Julian Brost 2025-03-31 13:53:14 +02:00
parent 1e05a166f1
commit 31a224c509
2 changed files with 6 additions and 12 deletions

View File

@ -180,18 +180,14 @@ int Host::GetSeverity() const
return 0;
}
int severity = 0;
if (IsReachable()) {
severity = 64;
} else {
severity = 32;
}
int severity = 32; // DOWN
if (IsAcknowledged()) {
severity += 512;
} else if (IsInDowntime()) {
severity += 256;
} else if (!IsReachable()) {
severity += 1024;
} else {
severity += 2048;
}

View File

@ -133,14 +133,12 @@ int Service::GetSeverity() const
severity = 256;
}
Host::Ptr host = GetHost();
ObjectLock hlock (host);
if (host->GetState() != HostUp) {
severity += 1024;
} else if (IsAcknowledged()) {
if (IsAcknowledged()) {
severity += 512;
} else if (IsInDowntime()) {
severity += 256;
} else if (!IsReachable()) {
severity += 1024;
} else {
severity += 2048;
}