[ZBX-8092] Zabbix server does not expand macro in notifications for disabled hosts Created: 2014 Apr 15  Updated: 2017 May 30  Resolved: 2014 Jun 20

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Server (S)
Affects Version/s: 2.2.3
Fix Version/s: 2.2.5rc1, 2.3.2

Type: Incident report Priority: Major
Reporter: Alexey Pustovalov Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: macros, notifications
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate

 Description   

Zabbix server does not expand macro in notifications for disabled hosts, which are used in trigger expressions. It happens because Zabbix get information about hosts from configuration cache. The configuration cache does not know anything about disabled hosts.



 Comments   
Comment by Aleksandrs Saveljevs [ 2014 Apr 16 ]

The same conceptual problem was discussed when developing ZBX-7887, which is still in progress (see (5) there). Not sure about the current bug, but the change in ZBX-7887 will be intentional: macros will not be resolved for disabled hosts or disabled items.

Comment by Igors Homjakovs (Inactive) [ 2014 May 07 ]

Fixed in svn://svn.zabbix.com/branches/dev/ZBX-8092

Comment by Igors Homjakovs (Inactive) [ 2014 May 07 ]

(1) Disabled hosts were added to the configuration cache

RESOLVED in r45135:r45136.

sasha REVIEWED. Please review my changes in r45301:45302.

igorsh Thank you. CLOSED.

Comment by Igors Homjakovs (Inactive) [ 2014 May 13 ]

(2) Disabled items and active items of disabled hosts were added to the configuration cache

RESOLVED in r45418.

asaveljevs (a) Please review r45571. Some checks for items being active were not needed. It also fixes several bugs. Please also take a look at r45575.

igorsh Thank you.

asaveljevs (b) Functions DCget_item_count(), DCget_item_unsupported_count(), and DCget_required_performance() do not check whether item hosts are actually monitored. REOPENED.

igorsh RESOLVED in r45712.

asaveljevs Optimized that a bit in r45725 by only searching in config->hosts if really needed. Please take a look. RESOLVED.

asaveljevs PS: Note that when merging into trunk function evaluate_NODATA() will need to be adjusted: the error message around DCget_data_expected_from() will need to be modified.

igorsh RESOLVED r45823 in svn://svn.zabbix.com/branches/dev/ZBX-8092-trunk

asaveljevs Looks good. Please review r45839 before merging. CLOSED.

Comment by richlv [ 2014 May 21 ]

(3) if we start including entities in the config cache, this must be documented in the upgrade notes and in some permanent location, too - it can have a significant impact on cache usage

igorsh RESOLVED in https://www.zabbix.com/documentation/2.2/manual/installation/upgrade_notes_224 and
https://www.zabbix.com/documentation/2.4/manual/installation/upgrade_notes_240

asaveljevs CLOSED.

Comment by Aleksandrs Saveljevs [ 2014 May 23 ]

(4) In ZBX_DC_HOST and ZBX_DC_ITEM, field "data_expected_from" should now be updated not only when the host or item appears in the cache for the first time, but also when it transitions from disabled state to enabled. Error message "item does not have enough data after server start/item creation" in evaluate_NODATA() should be updated accordingly.

igorsh RESOLVED in r45865 and r45872.

asaveljevs We discussed initialization of "data_expected_from" with sasha and decided to initialize it with "now" in r45880. Please take a look. RESOLVED.

igorsh Thank you. CLOSED.

Comment by Igors Homjakovs (Inactive) [ 2014 May 23 ]

Fixed in 2.2.4rc1 r45799 and 2.3.1 (trunk) r45855.

Comment by richlv [ 2014 May 24 ]

(5) changelog message does not even mention user-visible bugfix - resolving macros for disabled hosts. let's include that somehow

igorsh RESOLVED in r45857 and r45855.

asaveljevs CLOSED.

Comment by Igors Homjakovs (Inactive) [ 2014 May 28 ]

(6) Added triggers and functions of disabled items and of enabled items of disabled hosts to configuration cache

RESOLVED in r45940.

asaveljevs (a) I have removed unnecessary checks for items and hosts being enabled in r45959. The reason is that when these functions are called, we are already too deep in history syncing process (hence, we are trying to sync data for items and hosts that were enabled when we started the process) and by that time these checks are too late. Please take a look.

asaveljevs (b) Function DCget_trigger_count() returns the count of all triggers. REOPENED.

igorsh Thank you for your (a) modifications. (b) is RESOLVED in r46039.

There is only one small comment regarding counting the active triggers. For example, if we have two hosts and each host has a trigger that includes an item from the other host and if any of these hosts is disabled then the count returned by DCget_trigger_count() will be one trigger less.

asaveljevs Looks good, but please see r46073. RESOLVED.

igorsh Thank you. CLOSED.

Comment by Aleksandrs Saveljevs [ 2014 Jun 02 ]

(7) [F] The dashboard widget in the frontend currently counts enabled triggers with at least one enabled item on an enabled host.

It should be changed to count enabled triggers with all items enabled and on enabled hosts, so that zabbix[triggers] and the dashboard give the same count.

andrewtch my proposal is to refactor this SQL:

'SELECT COUNT(DISTINCT t.triggerid) AS cnt,t.status,t.value'.
			' FROM triggers t'.
			' INNER JOIN functions f ON t.triggerid=f.triggerid'.
			' INNER JOIN items i ON f.itemid=i.itemid'.
			' INNER JOIN hosts h ON i.hostid=h.hostid'.
			' WHERE i.status='.ITEM_STATUS_ACTIVE.
				' AND h.status='.HOST_STATUS_MONITORED.
				' AND t.flags IN ('.ZBX_FLAG_DISCOVERY_NORMAL.','.ZBX_FLAG_DISCOVERY_CREATED.')'.
			' GROUP BY t.status,t.value'

to this one:

'SELECT COUNT(DISTINCT t.triggerid) AS cnt,t.status,t.value
	FROM triggers t
	WHERE
		t.flags IN ('.ZBX_FLAG_DISCOVERY_NORMAL.','.ZBX_FLAG_DISCOVERY_CREATED.')
		AND NOT EXISTS (
			SELECT functionid FROM functions f
				JOIN items i ON f.itemid = i.itemid
				JOIN hosts h ON i.hostid = h.hostid
				WHERE h.status <> '.HOST_STATUS_MONITORED.' AND f.triggerid = t.triggerid AND i.status = '.ITEM_STATUS_ACTIVE.'
		)
	GROUP BY t.status,t.value'

does it violate any zabbix policy on SQL usage / dialects (although EXISTS / NOT EXISTS is supported throughout all major SQL servers)?

asaveljevs The proposed SQL statement seems to be OK with Zabbix policy on SQL usage - we do use "EXISTS".

asaveljevs However, it only checks for a case where a host is not monitored. It should also check for a case where a host is monitored, but an item is disabled.

asaveljevs Note also that if you check for "h.status" not being HOST_STATUS_MONITORED, then it can be one of HOST_STATUS_NOT_MONITORED, HOST_STATUS_TEMPLATE, HOST_STATUS_PROXY_ACTIVE, HOST_STATUS_PROXY_PASSIVE, which might or might not be what you want.

andrewtch RESOLVED, asaveljevs, please review r46217.

asaveljevs Looks good, but please see r46234. It styles the SQL query according to https://www.zabbix.org/wiki/SQL_coding_guidelines by removing spaces. RESOLVED.

andrewtch CLOSED by r46270 for 2.2, r46271 for trunk. Please update changelogs accordingly.

Comment by Alexander Vladishev [ 2014 Jun 03 ]

(8) Broken code in @2.2 and @trunk branches in function DCsync_items():

Conditional jump or move depends on uninitialised value(s). There old_poller_type can be uninitialised.

if (ZBX_POLLER_TYPE_UNREACHABLE == old_poller_type &&
        (ZBX_POLLER_TYPE_NORMAL == item->poller_type ||
        ZBX_POLLER_TYPE_IPMI == item->poller_type ||
        ZBX_POLLER_TYPE_JAVA == item->poller_type))
{
    item->poller_type = ZBX_POLLER_TYPE_UNREACHABLE;
}

igorsh RESOLVED in r46188.

asaveljevs The diff in r46188 is as follows:

Index: src/libs/zbxdbcache/dbconfig.c
===================================================================
--- src/libs/zbxdbcache/dbconfig.c	(revision 46187)
+++ src/libs/zbxdbcache/dbconfig.c	(revision 46188)
@@ -971,7 +971,9 @@
 			item->mtime = atoi(row[32]);
 			DCstrpool_replace(found, &item->db_error, row[41]);
 			item->data_expected_from = now;
+
 			item->location = ZBX_LOC_NOWHERE;
+			item->poller_type = ZBX_NO_POLLER;
 		}
 		else if (NULL != item->triggers && NULL == item->triggers[0])
 		{
@@ -1040,8 +1042,6 @@
 				}
 			}
 		}
-		else
-			item->poller_type = ZBX_NO_POLLER;
 
 		item->delay = delay;

I must admit I disagree with the second part, because the item should have no poller if it transitions from enabled status to disabled. REOPENED.

igorsh RESOLVED in r46200.

asaveljevs CLOSED.

Comment by Aleksandrs Saveljevs [ 2014 Jun 05 ]

Points (6) and (8) are fixed in pre-2.2.4 r46206 and pre-2.3.2 (trunk) r46207.

Comment by Aleksandrs Saveljevs [ 2014 Jun 05 ]

Note that when we merge the frontend part in (7), we should document the changes regarding zabbix[triggers] and the dashboard.

igorsh Documented in https://www.zabbix.com/documentation/2.2/manual/installation/upgrade_notes_224 and
https://www.zabbix.com/documentation/2.4/manual/installation/upgrade_notes_240

asaveljevs Looks great, but also remember to add a separate ChangeLog entry.

igorsh ChangeLog entry added in 2.2.4rc1 r46280 and 2.3.0(trunk) r46281.

asaveljevs Documentation improved further by martins-v. CLOSED.

Comment by Aleksandrs Saveljevs [ 2014 Jun 12 ]

(9) When a disabled host becomes enabled, all of its items are checked at the same time.

asaveljevs Also, items for a disabled host are put into the queue. They are not checked, because the host is disabled, but they should not be put into the queue in the first place.

asaveljevs Fixed in development branch svn://svn.zabbix.com/branches/dev/ZBX-8092 . RESOLVED.

Among other things, the fix adds only those items to the configuration cache for which host exists, too, by using the following check:

if (NULL == (host = zbx_hashset_search(&config->hosts, &hostid)))
	continue;

So what we can do additionally in this branch is to remove checks for host being NULL in other places where we search for host by item.

sasha CLOSED

Comment by Alexander Vladishev [ 2014 Jun 20 ]

(10) old_nextcheck can be uninitialized in function DCsync_items()

sasha it's not truth. WON'T FIX

Comment by Alexander Vladishev [ 2014 Jun 20 ]

(11) proxy_hostid should be removed from "select ... from items i, ..." statement. We can get it from ZBX_DC_HOST structure.

sasha RESOLVED in r46731.

asaveljevs CLOSED.

Comment by Alexander Vladishev [ 2014 Jun 20 ]

(12) item->poller_type is initialized twice for new items.

sasha RESOLVED in r46728.

asaveljevs CLOSED.

Comment by Alexander Vladishev [ 2014 Jun 20 ]

(13) item->nextcheck is calculated twice for items with a flexible intervals

sasha RESOLVED in r46729.

asaveljevs As discussed in the office, r46732 offers a couple of aesthetic improvements.

There is also a bug. When we search config->flexitems, we update "found" variable. However, that variable is used below and refers to the global "found"-ness. REOPENED.

sasha Fixed in r46734. RESOLVED.

asaveljevs CLOSED.

Comment by Aleksandrs Saveljevs [ 2014 Jun 20 ]

(14) Subissue (9) is fixed for trunk in development branch svn://svn.zabbix.com/branches/dev/ZBX-8092-trunk . It goes in two commits: r46748 manually ports r46674 from 2.2 (the one that moves DCsync_hosts() above DCsync_items()) due to conflicts. Commit r46750 is just a merge of the rest of the changes without any conflicts.

sasha Great! CLOSED

Comment by Aleksandrs Saveljevs [ 2014 Jun 25 ]

Issue (9) fixed in pre-2.2.5 r46784 and pre-2.3.2 (trunk) r46786.

Generated at Fri Apr 26 04:15:16 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.