Closed lippserd closed 4 years ago
I discovered some wrong numbers compared to MySQL and I do think that there is a problem with the function if there is only one state change in the requested time frame and if the initial state has to be selected from the status tables.
The following screenshots illustrate the wrong numbers. The dataset is the same. Icinga 2 writes to both MySQL and PostgreSQL and I checked whether the history tables match which they do. The requested time frame was "last 4 hours".
Dataset
Reports (right column is MySQL)
Ignore the report titles please. I just changed the time frames.
And this is what MySQL uses as events for the calculation for dummy-116:
+---------------------+--------------+-------+------------+
| state_time | type | state | last_state |
+---------------------+--------------+-------+------------+
| 2020-04-01 11:43:16 | former_state | 1 | 1 |
| 2020-04-01 13:51:17 | hard_state | 0 | 1 |
| 2020-04-01 15:43:16 | fake_end | NULL | NULL |
+---------------------+--------------+-------+------------+
Given that data the dummy-116 is roughly 50% available which MySQL also calculated. I don't know what PostgreSQL is calculating here.
@bluthg I also pushed some failing tests. Please check whether they're meaningful 😆
@mbanck I'd like to cleanup everything when we're ready to merge. But thanks for the hint.
With the data extracted from the above, I get 46.65972222222222 availability, which seems right to me... maybe we have a timezone issue here?
Test added, also did the cleanups @mbanck wished for ;-)
With the data extracted from the above, I get 46.65972222222222 availability, which seems right to me... maybe we have a timezone issue here?
Test added, also did the cleanups @mbanck wished for ;-)
Well, I forgot to push the tests. Should be there now. Note that we have a new branch. I don't know where you've pushed the cleanup 😆
Ok, so, after switching to this repo, I fixed:
Thanks for the changes @bluthg
Which IDE are you using? Some of your lines contain superfluous spaces at the end of the line. I removed those but now you've reintroduced them 😆
I'll test the changes asap.
The best IDE of them all: vim!
The best IDE of them all: vim!
Well 😆Could you then please use 4 spaces instead of tabs for the indent and make sure that there are no superfluous whitespaces at the end of lines.
I did some tests and it looks really good to me now. 👍 Thanks!
Because I'm a friend of readability and code standards, I reformatted the code [1] in 8bb2c09. @bluthg Could you please tell me whether you're ok with this?
[1] With the best IDE of them all - PhpStorm 🤣
Looks fine to me!
Any news on this?
resolves #2