keep in sync with Service::GetSeverity() * One could think it may be smart to use an enum and some bitmask math here. * But the only thing the consuming icingaweb2 cares about is being able to * sort by severity. It is therefore easier to keep them seperated here. */
| 169 | * But the only thing the consuming icingaweb2 cares about is being able to |
| 170 | * sort by severity. It is therefore easier to keep them seperated here. */ |
| 171 | int Host::GetSeverity() const |
| 172 | { |
| 173 | ObjectLock olock(this); |
| 174 | HostState state = GetState(); |
| 175 | |
| 176 | if (!HasBeenChecked()) { |
| 177 | return 16; |
| 178 | } |
| 179 | if (state == HostUp) { |
| 180 | return 0; |
| 181 | } |
| 182 | |
| 183 | int severity = 32; // DOWN |
| 184 | |
| 185 | if (IsAcknowledged()) { |
| 186 | severity += 512; |
| 187 | } else if (IsInDowntime()) { |
| 188 | severity += 256; |
| 189 | } else if (!IsReachable()) { |
| 190 | severity += 1024; |
| 191 | } else { |
| 192 | severity += 2048; |
| 193 | } |
| 194 | |
| 195 | return severity; |
| 196 | } |
| 197 | |
| 198 | bool Host::IsStateOK(ServiceState state) const |
| 199 | { |