Skip to content

Commit

Permalink
17595 FIX Fix miscalculated summary of availability
Browse files Browse the repository at this point in the history
When calculating the availability average, unmonitored hosts/services were subtracted twice from the total number of hosts/services.
This resulted in average availabilities greater than 100%.

Now the average availability is calculated and displayed correctly on when unmonitored hosts/services are present.

Change-Id: I841ea98d1304a6904daa31cd41a99d1106897992
  • Loading branch information
otAAAh committed Feb 6, 2025
1 parent 894cca9 commit 5224afb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
17 changes: 17 additions & 0 deletions .werks/17595.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[//]: # (werk v2)
# Fix miscalculated summary of availability

key | value
---------- | ---
date | 2025-02-05T14:49:03+00:00
version | 2.5.0b1
class | fix
edition | cre
component | multisite
level | 1
compatible | yes

When calculating the availability average, unmonitored hosts/services were subtracted twice from the total number of hosts/services.
This resulted in average availabilities greater than 100%.

Now the average availability is calculated and displayed correctly on when unmonitored hosts/services are present.
23 changes: 11 additions & 12 deletions cmk/gui/availability.py
Original file line number Diff line number Diff line change
Expand Up @@ -1838,18 +1838,17 @@ def layout_availability_table(
statistics.append(("", ""))
cells.extend(statistics)

# If timeline == [] and states == {} then this objects has complete unmonitored state
if entry["timeline"] == [] and entry["states"] == {}:
unmonitored_objects += 1

# regardless of timeformat the percentage value should be taken for summary levels
# verification since the percentage value takes the considered duration as reference duration
if show_summary and av_levels:
summary["ok_level"] = sum(
float(entry["states"].get("ok", 0)) / entry["considered_duration"]
for entry in availability_table
if entry["considered_duration"] > 0
)
# regardless of timeformat the percentage value should be taken for summary levels
# verification since the percentage value takes the considered duration as reference duration
if show_summary and av_levels:
summary["ok_level"] = sum(
float(entry["states"].get("ok", 0)) / entry["considered_duration"]
for entry in availability_table
if entry["considered_duration"] > 0
)
# If timeline == [] and states == {} then this objects has complete unmonitored state
if entry["timeline"] == [] and entry["states"] == {}:
unmonitored_objects += 1

# Summary line. It has the same format as each entry in cells
# We ignore unmonitored objects
Expand Down

0 comments on commit 5224afb

Please sign in to comment.