I'm running Icinga 2.7.0-1.trusty (on Ubuntu 14.04) with PostgreSQL IDO Backend, and I ran into an issue involving the last_hard_state column of the icinga_statehistory table.
My goal was to calculate availability percentages for hosts and services during a specific timeframe using the icinga_statehistory table by writing my own plpgsql script.
It seems that as of now a reliable calculation seems impossible due to the last_hard_state column always stating the current state in case of a current hard state.
I found one other topic in this forum which describes the same problem:
I think there is also a corresponding issue on GitHub: #5441
My suspicion is that this issue is being carried along since Icinga 1.x, since there are also several remarks regarding wrong values of last_hard_state in the SQL files of the Icinga Reporting package.
Is there something I could do to assist tracking the cause of this issue? Are there any plans to correct this issue in the near future?
Or does someone maybe have an alternative way of calculating availability percentages?
From what I have gathered from the icinga reports package, that every record in icinga_statehistory (even for soft state changes) is being fetched, so that all state changes can be processed.
However, from what I found out, this leaves one big issue:
When the first record of icinga_statehistory within the specific timeframe is a recovery (state = 0), it is impossible to distinct between a previous soft or hard problem state.
In this case I would have to count the time between the start of my specific timeframe and the recovery entry as a problem timeframe, even though the previous problem state could have been a soft one, which is not relevant to any SLAs.
Any input would be greatly appreciated!