Skip to content
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

Unhandled service count is wrong in host views when restrictions are used #2822

Closed
dgoetz opened this issue Apr 20, 2017 · 1 comment
Closed
Labels
bug Something isn't working
Milestone

Comments

@dgoetz
Copy link
Contributor

dgoetz commented Apr 20, 2017

With a user without any restrictions I get the correct count for unhandled service in host views, but if the user has restrictions the count varies. For example with my account I see 1 unhandled service, for the user with restrictions it is 0 if browsing the host view (so no filter) and 2 if coming from hostgroups (so filtered by a hostgroup value). For 5 unhandled, its 0 and 10.

I am not allowed to post screenshots because of hostnames, but I have the output of format=sql which hopefully helps to reproduce the problem also if it is not showing the service query.

Unrestricted /icingaweb2/monitoring/list/hosts?page=9&format=sql

QUERY
=====
SELECT h.icon_image AS host_icon_image, h.icon_image_alt AS
host_icon_image_alt, ho.name1 AS host_name, h.display_name COLLATE
latin1_general_ci AS host_display_name, CASE WHEN hs.has_been_checked = 0
OR hs.has_been_checked IS NULL THEN 99 ELSE hs.current_state END AS
host_state, hs.problem_has_been_acknowledged AS host_acknowledged,
hs.output AS host_output, hs.current_check_attempt || '/' ||
hs.max_check_attempts AS host_attempt, CASE WHEN
(hs.scheduled_downtime_depth = 0) THEN 0 ELSE 1 END AS host_in_downtime,
hs.is_flapping AS host_is_flapping, hs.state_type AS host_state_type, CASE
WHEN (hs.problem_has_been_acknowledged + hs.scheduled_downtime_depth) > 0
THEN 1 ELSE 0 END AS host_handled, UNIX_TIMESTAMP(hs.last_state_change) AS
host_last_state_change, hs.notifications_enabled AS
host_notifications_enabled, hs.active_checks_enabled AS
host_active_checks_enabled, hs.passive_checks_enabled AS
host_passive_checks_enabled FROM icinga_hosts AS h
 INNER JOIN icinga_objects AS ho ON ho.object_id = h.host_object_id AND
ho.is_active = 1 AND ho.objecttype_id = 1
 INNER JOIN icinga_hoststatus AS hs ON hs.host_object_id = ho.object_id
WHERE ( (TRUE) ) ORDER BY h.display_name COLLATE latin1_general_ci ASC

COUNT
=====
SELECT COUNT(*) AS cnt FROM icinga_hosts AS h
 INNER JOIN icinga_objects AS ho ON ho.object_id = h.host_object_id AND
ho.is_active = 1 AND ho.objecttype_id = 1
 INNER JOIN icinga_hoststatus AS hs ON hs.host_object_id = ho.object_id
WHERE ( (TRUE) )

Restricted /icingaweb2/monitoring/list/hosts?page=9&format=sql

QUERY
=====
SELECT h.icon_image AS host_icon_image, h.icon_image_alt AS
host_icon_image_alt, ho.name1 AS host_name, h.display_name COLLATE
latin1_general_ci AS host_display_name, CASE WHEN hs.has_been_checked = 0
OR hs.has_been_checked IS NULL THEN 99 ELSE hs.current_state END AS
host_state, hs.problem_has_been_acknowledged AS host_acknowledged,
hs.output AS host_output, hs.current_check_attempt || '/' ||
hs.max_check_attempts AS host_attempt, CASE WHEN
(hs.scheduled_downtime_depth = 0) THEN 0 ELSE 1 END AS host_in_downtime,
hs.is_flapping AS host_is_flapping, hs.state_type AS host_state_type, CASE
WHEN (hs.problem_has_been_acknowledged + hs.scheduled_downtime_depth) > 0
THEN 1 ELSE 0 END AS host_handled, UNIX_TIMESTAMP(hs.last_state_change) AS
host_last_state_change, hs.notifications_enabled AS
host_notifications_enabled, hs.active_checks_enabled AS
host_active_checks_enabled, hs.passive_checks_enabled AS
host_passive_checks_enabled FROM icinga_hosts AS h
 INNER JOIN icinga_objects AS ho ON ho.object_id = h.host_object_id AND
ho.is_active = 1 AND ho.objecttype_id = 1
 INNER JOIN icinga_hoststatus AS hs ON hs.host_object_id = ho.object_id
 LEFT JOIN icinga_hostgroup_members AS hgm ON hgm.host_object_id =
ho.object_id
 LEFT JOIN icinga_hostgroups AS hg ON hg.hostgroup_id = hgm.hostgroup_id
 LEFT JOIN icinga_objects AS hgo ON hgo.object_id = hg.hostgroup_object_id
AND hgo.is_active = 1 AND hgo.objecttype_id = 3 WHERE ( (TRUE OR 
(hgo.name1 = 'Etagen-Switches' OR hgo.name1 = 'Linux-Server' OR hgo.name1 =
'Netzwerk-Geraete' OR hgo.name1 = 'SAP-Server' OR hgo.name1 = 'Storage' OR
hgo.name1 = 'USV') ) ) GROUP BY ho.object_id,
	h.host_id ORDER BY h.display_name COLLATE latin1_general_ci ASC

COUNT
=====
SELECT COUNT(*) AS cnt FROM (SELECT h.icon_image AS host_icon_image,
h.icon_image_alt AS host_icon_image_alt, ho.name1 AS host_name,
h.display_name COLLATE latin1_general_ci AS host_display_name, CASE WHEN
hs.has_been_checked = 0 OR hs.has_been_checked IS NULL THEN 99 ELSE
hs.current_state END AS host_state, hs.problem_has_been_acknowledged AS
host_acknowledged, hs.output AS host_output, hs.current_check_attempt ||
'/' || hs.max_check_attempts AS host_attempt, CASE WHEN
(hs.scheduled_downtime_depth = 0) THEN 0 ELSE 1 END AS host_in_downtime,
hs.is_flapping AS host_is_flapping, hs.state_type AS host_state_type, CASE
WHEN (hs.problem_has_been_acknowledged + hs.scheduled_downtime_depth) > 0
THEN 1 ELSE 0 END AS host_handled, UNIX_TIMESTAMP(hs.last_state_change) AS
host_last_state_change, hs.notifications_enabled AS
host_notifications_enabled, hs.active_checks_enabled AS
host_active_checks_enabled, hs.passive_checks_enabled AS
host_passive_checks_enabled FROM icinga_hosts AS h
 INNER JOIN icinga_objects AS ho ON ho.object_id = h.host_object_id AND
ho.is_active = 1 AND ho.objecttype_id = 1
 INNER JOIN icinga_hoststatus AS hs ON hs.host_object_id = ho.object_id
 LEFT JOIN icinga_hostgroup_members AS hgm ON hgm.host_object_id =
ho.object_id
 LEFT JOIN icinga_hostgroups AS hg ON hg.hostgroup_id = hgm.hostgroup_id
 LEFT JOIN icinga_objects AS hgo ON hgo.object_id = hg.hostgroup_object_id
AND hgo.is_active = 1 AND hgo.objecttype_id = 3 WHERE ( (TRUE OR 
(hgo.name1 = 'Etagen-Switches' OR hgo.name1 = 'Linux-Server' OR hgo.name1 =
'Netzwerk-Geraete' OR hgo.name1 = 'SAP-Server' OR hgo.name1 = 'Storage' OR
hgo.name1 = 'USV') ) ) GROUP BY ho.object_id,
	h.host_id) AS t

Unrestricted /icingaweb2/monitoring/list/hosts?hostgroup_name=Toolineo-Systeme lf.net&format=sql

QUERY
=====
SELECT h.icon_image AS host_icon_image, h.icon_image_alt AS
host_icon_image_alt, ho.name1 AS host_name, h.display_name COLLATE
latin1_general_ci AS host_display_name, CASE WHEN hs.has_been_checked = 0
OR hs.has_been_checked IS NULL THEN 99 ELSE hs.current_state END AS
host_state, hs.problem_has_been_acknowledged AS host_acknowledged,
hs.output AS host_output, hs.current_check_attempt || '/' ||
hs.max_check_attempts AS host_attempt, CASE WHEN
(hs.scheduled_downtime_depth = 0) THEN 0 ELSE 1 END AS host_in_downtime,
hs.is_flapping AS host_is_flapping, hs.state_type AS host_state_type, CASE
WHEN (hs.problem_has_been_acknowledged + hs.scheduled_downtime_depth) > 0
THEN 1 ELSE 0 END AS host_handled, UNIX_TIMESTAMP(hs.last_state_change) AS
host_last_state_change, hs.notifications_enabled AS
host_notifications_enabled, hs.active_checks_enabled AS
host_active_checks_enabled, hs.passive_checks_enabled AS
host_passive_checks_enabled FROM icinga_hosts AS h
 INNER JOIN icinga_objects AS ho ON ho.object_id = h.host_object_id AND
ho.is_active = 1 AND ho.objecttype_id = 1
 INNER JOIN icinga_hoststatus AS hs ON hs.host_object_id = ho.object_id
 LEFT JOIN icinga_hostgroup_members AS hgm ON hgm.host_object_id =
ho.object_id
 LEFT JOIN icinga_hostgroups AS hg ON hg.hostgroup_id = hgm.hostgroup_id
 LEFT JOIN icinga_objects AS hgo ON hgo.object_id = hg.hostgroup_object_id
AND hgo.is_active = 1 AND hgo.objecttype_id = 3 WHERE ( (TRUE)  AND
hgo.name1 = 'Toolineo-Systeme lf.net') GROUP BY ho.object_id,
	h.host_id ORDER BY h.display_name COLLATE latin1_general_ci ASC

COUNT
=====
SELECT COUNT(*) AS cnt FROM (SELECT h.icon_image AS host_icon_image,
h.icon_image_alt AS host_icon_image_alt, ho.name1 AS host_name,
h.display_name COLLATE latin1_general_ci AS host_display_name, CASE WHEN
hs.has_been_checked = 0 OR hs.has_been_checked IS NULL THEN 99 ELSE
hs.current_state END AS host_state, hs.problem_has_been_acknowledged AS
host_acknowledged, hs.output AS host_output, hs.current_check_attempt ||
'/' || hs.max_check_attempts AS host_attempt, CASE WHEN
(hs.scheduled_downtime_depth = 0) THEN 0 ELSE 1 END AS host_in_downtime,
hs.is_flapping AS host_is_flapping, hs.state_type AS host_state_type, CASE
WHEN (hs.problem_has_been_acknowledged + hs.scheduled_downtime_depth) > 0
THEN 1 ELSE 0 END AS host_handled, UNIX_TIMESTAMP(hs.last_state_change) AS
host_last_state_change, hs.notifications_enabled AS
host_notifications_enabled, hs.active_checks_enabled AS
host_active_checks_enabled, hs.passive_checks_enabled AS
host_passive_checks_enabled FROM icinga_hosts AS h
 INNER JOIN icinga_objects AS ho ON ho.object_id = h.host_object_id AND
ho.is_active = 1 AND ho.objecttype_id = 1
 INNER JOIN icinga_hoststatus AS hs ON hs.host_object_id = ho.object_id
 LEFT JOIN icinga_hostgroup_members AS hgm ON hgm.host_object_id =
ho.object_id
 LEFT JOIN icinga_hostgroups AS hg ON hg.hostgroup_id = hgm.hostgroup_id
 LEFT JOIN icinga_objects AS hgo ON hgo.object_id = hg.hostgroup_object_id
AND hgo.is_active = 1 AND hgo.objecttype_id = 3 WHERE ( (TRUE)  AND
hgo.name1 = 'Toolineo-Systeme lf.net') GROUP BY ho.object_id,
	h.host_id) AS t

Restricted /icingaweb2/monitoring/list/hosts?hostgroup_name=Toolineo-Systeme lf.net&format=sql

QUERY
=====
SELECT h.icon_image AS host_icon_image, h.icon_image_alt AS
host_icon_image_alt, ho.name1 AS host_name, h.display_name COLLATE
latin1_general_ci AS host_display_name, CASE WHEN hs.has_been_checked = 0
OR hs.has_been_checked IS NULL THEN 99 ELSE hs.current_state END AS
host_state, hs.problem_has_been_acknowledged AS host_acknowledged,
hs.output AS host_output, hs.current_check_attempt || '/' ||
hs.max_check_attempts AS host_attempt, CASE WHEN
(hs.scheduled_downtime_depth = 0) THEN 0 ELSE 1 END AS host_in_downtime,
hs.is_flapping AS host_is_flapping, hs.state_type AS host_state_type, CASE
WHEN (hs.problem_has_been_acknowledged + hs.scheduled_downtime_depth) > 0
THEN 1 ELSE 0 END AS host_handled, UNIX_TIMESTAMP(hs.last_state_change) AS
host_last_state_change, hs.notifications_enabled AS
host_notifications_enabled, hs.active_checks_enabled AS
host_active_checks_enabled, hs.passive_checks_enabled AS
host_passive_checks_enabled FROM icinga_hosts AS h
 INNER JOIN icinga_objects AS ho ON ho.object_id = h.host_object_id AND
ho.is_active = 1 AND ho.objecttype_id = 1
 INNER JOIN icinga_hoststatus AS hs ON hs.host_object_id = ho.object_id
 LEFT JOIN icinga_hostgroup_members AS hgm ON hgm.host_object_id =
ho.object_id
 LEFT JOIN icinga_hostgroups AS hg ON hg.hostgroup_id = hgm.hostgroup_id
 LEFT JOIN icinga_objects AS hgo ON hgo.object_id = hg.hostgroup_object_id
AND hgo.is_active = 1 AND hgo.objecttype_id = 3 WHERE ( (TRUE OR 
(hgo.name1 = 'Etagen-Switches' OR hgo.name1 = 'Linux-Server' OR hgo.name1 =
'Netzwerk-Geraete' OR hgo.name1 = 'SAP-Server' OR hgo.name1 = 'Storage' OR
hgo.name1 = 'USV') )  AND hgo.name1 = 'Toolineo-Systeme lf.net') GROUP BY
ho.object_id,
	h.host_id ORDER BY h.display_name COLLATE latin1_general_ci ASC

COUNT
=====
SELECT COUNT(*) AS cnt FROM (SELECT h.icon_image AS host_icon_image,
h.icon_image_alt AS host_icon_image_alt, ho.name1 AS host_name,
h.display_name COLLATE latin1_general_ci AS host_display_name, CASE WHEN
hs.has_been_checked = 0 OR hs.has_been_checked IS NULL THEN 99 ELSE
hs.current_state END AS host_state, hs.problem_has_been_acknowledged AS
host_acknowledged, hs.output AS host_output, hs.current_check_attempt ||
'/' || hs.max_check_attempts AS host_attempt, CASE WHEN
(hs.scheduled_downtime_depth = 0) THEN 0 ELSE 1 END AS host_in_downtime,
hs.is_flapping AS host_is_flapping, hs.state_type AS host_state_type, CASE
WHEN (hs.problem_has_been_acknowledged + hs.scheduled_downtime_depth) > 0
THEN 1 ELSE 0 END AS host_handled, UNIX_TIMESTAMP(hs.last_state_change) AS
host_last_state_change, hs.notifications_enabled AS
host_notifications_enabled, hs.active_checks_enabled AS
host_active_checks_enabled, hs.passive_checks_enabled AS
host_passive_checks_enabled FROM icinga_hosts AS h
 INNER JOIN icinga_objects AS ho ON ho.object_id = h.host_object_id AND
ho.is_active = 1 AND ho.objecttype_id = 1
 INNER JOIN icinga_hoststatus AS hs ON hs.host_object_id = ho.object_id
 LEFT JOIN icinga_hostgroup_members AS hgm ON hgm.host_object_id =
ho.object_id
 LEFT JOIN icinga_hostgroups AS hg ON hg.hostgroup_id = hgm.hostgroup_id
 LEFT JOIN icinga_objects AS hgo ON hgo.object_id = hg.hostgroup_object_id
AND hgo.is_active = 1 AND hgo.objecttype_id = 3 WHERE ( (TRUE OR 
(hgo.name1 = 'Etagen-Switches' OR hgo.name1 = 'Linux-Server' OR hgo.name1 =
'Netzwerk-Geraete' OR hgo.name1 = 'SAP-Server' OR hgo.name1 = 'Storage' OR
hgo.name1 = 'USV') )  AND hgo.name1 = 'Toolineo-Systeme lf.net') GROUP BY
ho.object_id,
	h.host_id) AS t

Modules and versions in use are:
businessprocess 2.1.0
director 1.3.1
fileshipper 1.0.0
graphite 0.0.0
monitoring 2.4.1
puppetdb 0.0.0

Icinga 2 version is r2.6.3-1

@lippserd
Copy link
Member

Hi Dirk,

Thanks for the report. We'll fix that.

Cheers,
Eric

@lippserd lippserd added the bug Something isn't working label Sep 21, 2017
@lippserd lippserd added this to the 2.5.0 milestone Nov 10, 2017
lippserd added a commit that referenced this issue Nov 10, 2017
…e used

The query for fetching the unhandled services count utilises the hosts query as subquery.
Restrictions are applied to both the hosts query and the query for the unhandled services count.
This leads to wrong results since the restrictions are already in place for the unhandled services count because we're using the hosts query as subquery.

refs #2822
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants