-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix sla report inconsistencies #560
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ BEGIN | |
DECLARE active_downtimes int unsigned; | ||
DECLARE problem_time bigint unsigned; | ||
DECLARE total_time bigint unsigned; | ||
DECLARE rowCounts int unsigned; | ||
DECLARE done int; | ||
DECLARE cur CURSOR FOR | ||
( | ||
|
@@ -69,6 +70,8 @@ BEGIN | |
AND ((in_service_id IS NULL AND s.service_id IS NULL) OR s.service_id = in_service_id) | ||
AND s.event_time > in_start_time | ||
AND s.event_time < in_end_time | ||
AND s.hard_state IS NOT NULL | ||
AND s.previous_hard_state IS NOT NULL | ||
) UNION ALL ( | ||
-- end event to keep loop simple, values are not used | ||
SELECT | ||
|
@@ -130,6 +133,7 @@ BEGIN | |
|
||
SET done = 0; | ||
OPEN cur; | ||
SELECT FOUND_ROWS() INTO rowCounts; | ||
read_loop: LOOP | ||
FETCH cur INTO row_event_time, row_event_type, row_event_prio, row_hard_state, row_previous_hard_state; | ||
IF done THEN | ||
|
@@ -156,7 +160,12 @@ BEGIN | |
END LOOP; | ||
CLOSE cur; | ||
|
||
SET result = 100 * (total_time - problem_time) / total_time; | ||
-- row count "1" because of the faked ending result used for the | ||
-- cursor loop, whose result set is never used. | ||
IF rowCounts > 1 THEN | ||
Comment on lines
+163
to
+165
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would also count downtime rows returned by that query which I doubt you want. But also if this would just count the state rows, this makes the assumption that if there's no event in the interval, there's no valid result to report. Problem with this is that if nothing happens on a checkable, there is no history. So for something that's 100% up, had no downtimes, this would now no longer return a value. |
||
SET result = 100 * (total_time - problem_time) / total_time; | ||
END IF; -- else no data available to be reported | ||
|
||
RETURN result; | ||
END// | ||
DELIMITER ; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't these columns already have a
NOT NULL
constraint?