-
Notifications
You must be signed in to change notification settings - Fork 13
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
WIP: Support PostgreSQL #23
Conversation
) | ||
RETURNS float | ||
LANGUAGE SQL | ||
id INTEGER, |
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.
why the change from bigint
to int
for id
? AFAICT object_id
is still bigint
or bigserial
, so this would require casting.
Maybe this just didn't age well, while the rest of the code went on... it's been a while ;-) I'll fix that. |
Apart from #22 (i.e. if I change |
@@ -0,0 +1 @@ | |||
../get_sla_ok_percent_postgres.sql |
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.
This is a symlink, but ../get_sla_ok_percent_postgres.sql
does not exist in this branch, it's ../get_sla_ok_percent.sql
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.
Fixed
I think there is a problem if a host stays down, then the SLA for a random timerange since it went down does not seem to be 0. For example for
The host went down hard at 12:00 and never came back up. Not sure it matters, but I also set
Then I get a failure for the following as
The test passes if I set the expected result of the third (but not the second!) test to 100, which looks clearly wrong to me. |
I think the problem might be this line in the
If I keep it in, If I comment out the above |
…web2-module-idoreports into feature/postgresql
That WHERE was a shortcut (idea was to keep the number of rows smaller). The end result is still correct when omitting it, the CTE just has to look at more rows. |
Cool! give it another round of tests tomorrow hopefully. |
I've tested it again now and it seems to work fine for me. I've deployed it for a customer and asked them to check as well, but not sure whether we get much feedback soon. In any case, this is much better than what's currently in |
As pointed out by @mbanck, the referred tables all use TIMESTAMP, not TIMESTAMP WITH TIME ZONE, which leads ti skewed results in Grafana. |
So I implemented similar test cases for mysql, see #28. However, I had to include quite a few more columns in the test data as they are referenced from the corresponding mysql function:
That makes me wonder whether there are still corner cases lurking. I am not saying that there is a problem, just that there might be. |
32a6f9f
to
6f64eb6
Compare
@mbanck Yeah, there may be cases which the PostgreSQL procedure is not covering at the moment. Many of the MySQL code is for older Icinga 2 versions where we had slight problems with the history tables. I do think that this is sufficient for the moment. I took the liberty to polish the commits a little bit and created a new PR #30 Thanks everybody for the effort. Great work 👍 @bluthg You should have commit rights in the new PR, if needed. Closing here. |
The code that ended up in the Github is not the actually working version. It has a badly named alias that leads to NULL results sometimes!
I also added the pg_tap tests with a small README.md.