[ZBX-8379] Limit applied before filter on host.get apparently Created: 2014 Jun 20  Updated: 2017 May 30  Resolved: 2014 Jun 25

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: API (A)
Affects Version/s: 2.0.12
Fix Version/s: 2.3.2

Type: Incident report Priority: Major
Reporter: Volker Fröhlich Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: limits, maintenance
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

$filterOptions = array(
'maintenance_status' => HOST_MAINTENANCE_STATUS_ON,
'status' => HOST_STATUS_MONITORED
);

$hosts = API::Host()->get(array(
'output' => array('name', 'maintenanceid'),
'groupids' => $filter['groupids'],
'filter' => $filterOptions,
'sortfield' => 'name',
'limit' => isset($filter['limit']) ? $filter['limit'] : 10
));

Using a limit of 10 is getting me only 4 results, while I get 7 (the actual number!) when I remove the limit or raise it to say 100. I would expect 7 results with a limit of 10.



 Comments   
Comment by Oleksii Zagorskyi [ 2014 Jun 22 ]

Something similar for inventories reported in ZBX-4633

Comment by Volker Fröhlich [ 2014 Jun 23 ]

Changing the sortfield is affecting the result. The following query is the result of $this->createSelectQueryFromParts($sqlParts) in CHost.php. When reviewing the result it becomes clear why it is wrong:

zabbix20=# SELECT DISTINCT h.hostid,h.name,h.maintenanceid,hg.groupid FROM hosts h,hosts_groups hg WHERE (hg.groupid BETWEEN '4' AND '15' OR hg.groupid BETWEEN '18' AND '23' OR hg.groupid BETWEEN '28' AND '32' OR hg.groupid BETWEEN '34' AND '54' OR hg.groupid BETWEEN '56' AND '60' OR hg.groupid BETWEEN '63' AND '69' OR hg.groupid BETWEEN '73' AND '98' OR hg.groupid IN ('1','2','25','71','100','101','103','105','106','107','108')) AND hg.hostid=h.hostid AND h.status IN (0,1) AND h.maintenance_status='1' AND h.status='0' ORDER BY h.name;
hostid | name | maintenanceid | groupid
--------------------------------+--------
10794 | ex03.ex | 60 | 34
10794 | ex03.ex | 60 | 40
10795 | ex04.ex | 60 | 34
10795 | ex04.ex | 60 | 40
11830 | itscmgmt.srv | 13 | 36
11830 | itscmgmt.srv | 13 | 40
10818 | serus.srv | 13 | 31
10818 | serus.srv | 13 | 36
10818 | serus.srv | 13 | 40
10818 | serus.srv | 13 | 76
11012 | uni.sc | 13 | 57
11012 | uni.sc | 13 | 76
11013 | uli.sc | 13 | 57
11014 | uko.sc | 13 | 57
(14 rows)

When you now apply a limit of 10, you only catch 4 out of 7 hostnames, which exactly resembles the witnessed behaviour.

Comment by Krists Krigers (Inactive) [ 2014 Jun 25 ]

This was fixed in trunk some time back.

Comment by Pavels Jelisejevs (Inactive) [ 2014 Jul 22 ]

CLOSED.

Generated at Wed May 08 21:41:43 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.