Icinga / icingaweb2-module-idoreports

Icinga IDO Reports provides host and service availability reports for Icinga based on the monitoring database (IDO).
GNU General Public License v2.0
34 stars 13 forks source link

Support PostgreSQL #30

Closed lippserd closed 4 years ago

lippserd commented 4 years ago

resolves #2

lippserd commented 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

10 211 55 9_icingaweb2_monitoring_host_history_host=dummy-116

Reports (right column is MySQL)

Ignore the report titles please. I just changed the time frames.

10 211 55 9_icingaweb2_reporting_report_id=1

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 😆

lippserd commented 4 years ago

@mbanck I'd like to cleanup everything when we're ready to merge. But thanks for the hint.

bluthg commented 4 years ago

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 ;-)

lippserd commented 4 years ago

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 😆

bluthg commented 4 years ago

Ok, so, after switching to this repo, I fixed:

lippserd commented 4 years ago

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.

bluthg commented 4 years ago

The best IDE of them all: vim!

lippserd commented 4 years ago

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 🤣

bluthg commented 4 years ago

Looks fine to me!

mbanck commented 4 years ago

Any news on this?