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

feature/postgresql: host states not accounted for #22

Closed mbanck closed 4 years ago

mbanck commented 4 years ago

Describe the bug

The Postgres idoreports_get_sla_ok_percent() function in the feature/postgresql branch has the following code (or similar) multiple times:

                SELECT
[...]
                   state > 1 AS down,
[...]
                   state
                FROM
                    icinga_statehistory
                WHERE
                    object_id = id

However, for icinga_objects.objecttype_id = 1 (i.e. Hosts, not Services), state = 1 is DOWN, so those are not accounted for. The code needs to distinguish between Hosts (where state > 0 AS down) and Services (where state > 1 AS down).

CC: @bluthg

bluthg commented 4 years ago

IIRC, we were only looking for hard states, which is why I settled on "> 1". Is that correct, @lippserd?

mbanck commented 4 years ago

The "Runtime Attributes" table of https://icinga.com/docs/icinga2/latest/doc/09-object-types/#host does not make it look like state type (hard or soft) has a bearing on the state value (which has as values "The current state (0 = UP, 1 = DOWN)." according to it). There is a different column state_type in icinga_statehistory that defines whether the row is about a hard or a soft state.

I have no real opinion on whether a soft state should be considered a downtime as far as SLA is concerned, I guess it makes sense to just use the same as mysql.

bluthg commented 4 years ago

23 now also incorporates that.

Would love to see this run against some real life data!

mbanck commented 4 years ago

This issue has been fixed in c63672e83 and since been merged into the feature/postgresql branch.