[ZBX-7872] NVPS calculation logic of frontend (PHP) is not syncing with server (C) Created: 2014 Feb 26  Updated: 2017 May 30  Resolved: 2014 Mar 10

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Frontend (F)
Affects Version/s: 2.0.11, 2.2.2
Fix Version/s: 2.0.12rc1, 2.2.3rc1, 2.3.0

Type: Incident report Priority: Trivial
Reporter: HAYASHI Kentaro Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: nvps
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File ignore-items-with-flags-discovery-prototype-for-qps-total.patch    

 Description   

It seems that NVPS calculation logic of frontend is not syncing with server.

Here is the current svn code in frontends/php/include/func.inc.php:

// comments: !!! Don't forget sync code with C !!!
$row = DBfetch(DBselect(
'SELECT SUM(1.0/i.delay) AS qps'.
' FROM items i,hosts h'.
' WHERE i.status='.ITEM_STATUS_ACTIVE.
' AND i.hostid=h.hostid'.
' AND h.status='.HOST_STATUS_MONITORED.
' AND i.delay<>0'
));

In above code, it doesn't care the value of flags column in items table.
It means that items.flags = ZBX_FLAG_DISCOVERY_PROTOTYPE is included in calculation and distort NVPS value.

Trapper just ignores ZBX_FLAG_DISCOVERY_PROTOTYPE when checking active items in C code, so need to
do same thing in frontend, doesn't it?

I've attached a patch to fix this glitch between C and PHP code for svn HEAD.



 Comments   
Comment by HAYASHI Kentaro [ 2014 Feb 26 ]

"do same thing in frontend" means adding following part to query.

' AND i.flags<>'.ZBX_FLAG_DISCOVERY_PROTOTYPE

Comment by Igors Homjakovs (Inactive) [ 2014 Mar 04 ]

Fixed in svn://svn.zabbix.com/branches/dev/ZBX-7872
and
svn://svn.zabbix.com/branches/dev/ZBX-7872-2.2

Comment by Aleksandrs Saveljevs [ 2014 Mar 05 ]

(1) We seem to prefer "flags<>ZBX_FLAG_DISCOVERY_PROTOTYPE" over "flags in (ZBX_FLAG_DISCOVERY_NORMAL,ZBX_FLAG_DISCOVERY_RULE,ZBX_FLAG_DISCOVERY_CREATED)". Why don't we do the same here for consistency?

igorsh RESOLVED in r43208.

asaveljevs The same needs to be done in 2.0 branch. REOPENED.

igorsh RESOLVED in r43295.

asaveljevs In 2.0 branch, there is an error in the frontend when opening the dashboard, REOPENED:

Use of undefined constant ZBX_FLAG_DISCOVERY_PROTOTYPE - assumed 'ZBX_FLAG_DISCOVERY_PROTOTYPE' [include/config.inc.php:677]
Error in query [SELECT SUM(1.0/i.delay) AS qps FROM items i,hosts h WHERE i.status=0 AND i.hostid=h.hostid AND h.status=0 AND i.delay<>0 AND i.flags<>ZBX_FLAG_DISCOVERY_PROTOTYPE] [Unknown column 'ZBX_FLAG_DISCOVERY_PROTOTYPE' in 'where clause']

igorsh RESOLVED in r43327.

asaveljevs In 2.0 branch, "flags<>ZBX_FLAG_DISCOVERY_CHILD" was only done in the frontend. How about the server side? REOPENED.

igorsh RESOLVED in r43333.

asaveljevs Looks good now. Its presence does not hurt, but you might or might not wish to remove unused constant ZBX_FLAG_DISCOVERY_NORMAL from C header when merging. CLOSED.

Comment by Aleksandrs Saveljevs [ 2014 Mar 05 ]

(2) dbconfig.c contains the following changes:

Index: src/libs/zbxdbcache/dbconfig.c
===================================================================
--- src/libs/zbxdbcache/dbconfig.c	(revision 43179)
+++ src/libs/zbxdbcache/dbconfig.c	(revision 43180)
@@ -5636,7 +5636,7 @@
 
 	while (NULL != (item = zbx_hashset_iter_next(&iter)))
 	{
-		if (0 != item->delay)
+		if (0 != item->delay && ZBX_FLAG_DISCOVERY_PROTOTYPE != item->flags)
 			nvps += 1.0 / item->delay;
 	}

Note that after ZBX-5778 is merged, this condition will no longer be necessary. So I am just adding a note so that we remember about it.

igorsh RESOLVED in r43355.

asaveljevs Looks good. CLOSED.

Comment by Igors Homjakovs (Inactive) [ 2014 Mar 10 ]

Fixed in version 2.0.12rc1 r43347, 2.2.3rc1 r43349 and r43372, 2.3.0 (trunk) r43350 and r43373.

Generated at Sat Apr 20 11:53:09 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.