Index: include/common.h
===================================================================
--- include/common.h	(revision 45774)
+++ include/common.h	(working copy)
@@ -849,7 +849,8 @@
 int	num_key_param(char *param);
 size_t	zbx_get_escape_string_len(const char *src, const char *charlist);
 char	*zbx_dyn_escape_string(const char *src, const char *charlist);
-int	calculate_item_nextcheck(zbx_uint64_t seed, int item_type, int delay, const char *flex_intervals, time_t now);
+int	calculate_item_nextcheck(zbx_uint64_t seed, int item_type, int delay, const char *flex_intervals, time_t now,
+		zbx_uint64_t itemid);
 time_t	calculate_proxy_nextcheck(zbx_uint64_t hostid, unsigned int delay, time_t now);
 int	check_time_period(const char *period, time_t now);
 char	zbx_num2hex(u_char c);
@@ -1063,4 +1064,6 @@
 #define ZBX_SESSION_ACTIVE	0
 #define ZBX_SESSION_PASSIVE	1
 
+const char	*zbx_debug_time(time_t now);
+
 #endif
Index: src/libs/zbxcommon/misc.c
===================================================================
--- src/libs/zbxcommon/misc.c	(revision 45774)
+++ src/libs/zbxcommon/misc.c	(working copy)
@@ -588,6 +588,25 @@
 	return 0 != next ? SUCCEED : FAIL;
 }
 
+const char	*zbx_debug_time(time_t now)
+{
+	static int	n = 0;
+	static char	buffer[4][64];
+
+	int		m = n;
+	struct tm	*tm;
+
+	tm = localtime(&now);
+
+	zbx_snprintf(buffer[m], sizeof(buffer[m]), "%d,%04d.%02d.%02d %02d:%02d:%02d",
+			(int)now, 1900 + tm->tm_year, tm->tm_mon + 1, tm->tm_mday,
+			tm->tm_hour, tm->tm_min, tm->tm_sec);
+
+	n = (n + 1) % 4;
+
+	return buffer[m];
+}
+
 /******************************************************************************
  *                                                                            *
  * Function: calculate_item_nextcheck                                         *
@@ -614,7 +633,8 @@
  *           !!! Don't forget to sync code with PHP !!!                       *
  *                                                                            *
  ******************************************************************************/
-int	calculate_item_nextcheck(zbx_uint64_t seed, int item_type, int delay, const char *flex_intervals, time_t now)
+int	calculate_item_nextcheck(zbx_uint64_t seed, int item_type, int delay, const char *flex_intervals, time_t now,
+		zbx_uint64_t itemid)
 {
 	int	nextcheck = 0;
 
@@ -676,6 +696,14 @@
 		}
 	}
 
+	if (0 != itemid)
+	{
+		zabbix_log(LOG_LEVEL_DEBUG, "calculate_item_nextcheck() itemid:" ZBX_FS_UI64
+				" delay:%d flex_intervals:'%s' now:'%s' nextcheck:'%s'",
+				itemid, delay, ZBX_NULL2STR(flex_intervals),
+				zbx_debug_time(now), zbx_debug_time(nextcheck));
+	}
+
 	return nextcheck;
 }
 
Index: src/libs/zbxdbcache/dbconfig.c
===================================================================
--- src/libs/zbxdbcache/dbconfig.c	(revision 45774)
+++ src/libs/zbxdbcache/dbconfig.c	(working copy)
@@ -506,12 +506,13 @@
 
 static int	DCget_reachable_nextcheck(const ZBX_DC_ITEM *item, int now)
 {
-	int	nextcheck;
+	int		nextcheck;
+	zbx_uint64_t	id = (0 == strcmp(item->key, "agent.ping") ? item->itemid : 0);
 
 	if (ITEM_STATE_NOTSUPPORTED == item->state)
 	{
 		nextcheck = calculate_item_nextcheck(get_item_nextcheck_seed(item), item->type,
-				config->config->refresh_unsupported, NULL, now);
+				config->config->refresh_unsupported, NULL, now, id);
 	}
 	else
 	{
@@ -519,7 +520,7 @@
 
 		flexitem = zbx_hashset_search(&config->flexitems, &item->itemid);
 		nextcheck = calculate_item_nextcheck(get_item_nextcheck_seed(item), item->type,
-				item->delay, NULL != flexitem ? flexitem->delay_flex : NULL, now);
+				item->delay, NULL != flexitem ? flexitem->delay_flex : NULL, now, id);
 	}
 
 	return nextcheck;
@@ -674,6 +675,37 @@
 {
 	zbx_binary_heap_elem_t	elem;
 
+	if (0 == strcmp(item->key, "agent.ping"))
+	{
+		if (ZBX_NO_POLLER != old_poller_type)
+		{
+			zbx_binary_heap_t	*heap = &config->queues[old_poller_type];
+
+			int		index = zbx_hashmap_get(heap->key_index, item->itemid);
+			ZBX_DC_ITEM	*min_item = (ZBX_DC_ITEM *)(0 == heap->elems_num ? NULL : heap->elems[0].data);
+
+			zabbix_log(LOG_LEVEL_DEBUG, "DCupdate_item_queue() itemid:" ZBX_FS_UI64 " state:%d"
+					" old_index_in_heap:%d old_itemid_at_index:" ZBX_FS_UI64
+					" old_size_of_heap:%d old_min_nextcheck_in_heap:'%s'"
+					" location:%d poller_type:%d nextcheck:'%s'"
+					" old_poller_type:%d old_nextcheck:'%s'",
+					item->itemid, (int)item->state,
+					index, FAIL == index ? __UINT64_C(0) : heap->elems[index].key,
+					heap->elems_num, NULL == min_item ? "(null)" : zbx_debug_time(min_item->nextcheck),
+					(int)item->location, (int)item->poller_type, zbx_debug_time(item->nextcheck),
+					old_poller_type, zbx_debug_time(old_nextcheck));
+		}
+		else
+		{
+			zabbix_log(LOG_LEVEL_DEBUG, "DCupdate_item_queue() itemid:" ZBX_FS_UI64 " state:%d"
+					" location:%d poller_type:%d nextcheck:'%s'"
+					" old_poller_type:%d old_nextcheck:'%s'",
+					item->itemid, (int)item->state,
+					(int)item->location, (int)item->poller_type, zbx_debug_time(item->nextcheck),
+					old_poller_type, zbx_debug_time(old_nextcheck));
+		}
+	}
+
 	if (ZBX_LOC_POLLER == item->location)
 		return;
 
@@ -699,6 +731,20 @@
 	}
 	else
 		zbx_binary_heap_update_direct(&config->queues[item->poller_type], &elem);
+
+	if (0 == strcmp(item->key, "agent.ping"))
+	{
+		zbx_binary_heap_t	*heap = &config->queues[item->poller_type];
+
+		int		index = zbx_hashmap_get(heap->key_index, item->itemid);
+		ZBX_DC_ITEM	*min_item = (ZBX_DC_ITEM *)(0 == heap->elems_num ? NULL : heap->elems[0].data);
+
+		zabbix_log(LOG_LEVEL_DEBUG, "DCupdate_item_queue() itemid:" ZBX_FS_UI64
+				" new_index_in_heap:%d new_itemid_at_index:" ZBX_FS_UI64
+				" new_size_of_heap:%d new_min_nextcheck_in_heap:'%s'",
+				item->itemid, index, FAIL == index ? __UINT64_C(0) : heap->elems[index].key,
+				heap->elems_num, NULL == min_item ? "(null)" : zbx_debug_time(min_item->nextcheck));
+	}
 }
 
 static void	DCupdate_proxy_queue(ZBX_DC_PROXY *proxy)
@@ -877,6 +923,8 @@
 
 	while (NULL != (row = DBfetch(result)))
 	{
+		zbx_uint64_t	id;
+
 		ZBX_STR2UINT64(itemid, row[0]);
 		ZBX_STR2UINT64(hostid, row[1]);
 		ZBX_DBROW2UINT64(proxy_hostid, row[2]);
@@ -926,6 +974,8 @@
 		item->flags = (unsigned char)atoi(row[26]);
 		ZBX_DBROW2UINT64(item->interfaceid, row[27]);
 
+		id = (0 == strcmp(item->key, "agent.ping") ? item->itemid : 0);
+
 		if (0 != (ZBX_FLAG_DISCOVERY_RULE & item->flags))
 			item->value_type = ITEM_VALUE_TYPE_TEXT;
 		else
@@ -985,12 +1035,12 @@
 			if (ITEM_STATE_NOTSUPPORTED == item->state)
 			{
 				item->nextcheck = calculate_item_nextcheck(get_item_nextcheck_seed(item),
-						item->type, config->config->refresh_unsupported, NULL, now);
+						item->type, config->config->refresh_unsupported, NULL, now, id);
 			}
 			else
 			{
 				item->nextcheck = calculate_item_nextcheck(get_item_nextcheck_seed(item),
-						item->type, delay, row[16], now);
+						item->type, delay, row[16], now, id);
 			}
 		}
 		else
@@ -1000,7 +1050,7 @@
 			if (ITEM_STATE_NORMAL == item->state && delay != item->delay)
 			{
 				item->nextcheck = calculate_item_nextcheck(get_item_nextcheck_seed(item),
-						item->type, delay, row[16], now);
+						item->type, delay, row[16], now, id);
 			}
 		}
 
@@ -1070,7 +1120,7 @@
 					ITEM_STATE_NOTSUPPORTED != item->state)
 			{
 				item->nextcheck = calculate_item_nextcheck(get_item_nextcheck_seed(item), item->type,
-						item->delay, flexitem->delay_flex, now);
+						item->delay, flexitem->delay_flex, now, id);
 			}
 		}
 		else if (NULL != (flexitem = zbx_hashset_search(&config->flexitems, &itemid)))
@@ -1083,7 +1133,7 @@
 			if (ITEM_STATE_NOTSUPPORTED != item->state)
 			{
 				item->nextcheck = calculate_item_nextcheck(get_item_nextcheck_seed(item), item->type,
-						item->delay, NULL, now);
+						item->delay, NULL, now, id);
 			}
 		}
 
@@ -4333,10 +4383,11 @@
 	int			now, num = 0, max_items;
 	zbx_binary_heap_t	*queue;
 
-	zabbix_log(LOG_LEVEL_DEBUG, "In %s() poller_type:%d", __function_name, (int)poller_type);
-
 	now = time(NULL);
 
+	zabbix_log(LOG_LEVEL_DEBUG, "In %s() poller_type:%d now:'%s'",
+			__function_name, (int)poller_type, zbx_debug_time(now));
+
 	queue = &config->queues[poller_type];
 
 	switch (poller_type)
@@ -4355,7 +4406,7 @@
 
 	while (num < max_items && FAIL == zbx_binary_heap_empty(queue))
 	{
-		int				disable_until, old_nextcheck;
+		int				disable_until, old_nextcheck, agent_ping;
 		unsigned char			old_poller_type;
 		const zbx_binary_heap_elem_t	*min;
 		ZBX_DC_HOST			*dc_host;
@@ -4365,6 +4416,12 @@
 		min = zbx_binary_heap_find_min(queue);
 		dc_item = (ZBX_DC_ITEM *)min->data;
 
+		if (1 == (agent_ping = (0 == strcmp(dc_item->key, "agent.ping"))))
+		{
+			zabbix_log(LOG_LEVEL_DEBUG, "%s() itemid:" ZBX_FS_UI64 " nextcheck:'%s'",
+					__function_name, dc_item->itemid, zbx_debug_time(dc_item->nextcheck));
+		}
+
 		if (dc_item->nextcheck > now)
 			break;
 
@@ -4386,10 +4443,26 @@
 		dc_item->location = ZBX_LOC_NOWHERE;
 
 		if (0 == config->config->refresh_unsupported && ITEM_STATE_NOTSUPPORTED == dc_item->state)
+		{
+			if (1 == agent_ping)
+			{
+				zabbix_log(LOG_LEVEL_DEBUG, "%s() itemid:" ZBX_FS_UI64
+						" skipping because of not supported state",
+						__function_name, dc_item->itemid);
+			}
 			continue;
+		}
 
 		if (NULL == (dc_host = zbx_hashset_search(&config->hosts, &dc_item->hostid)))
+		{
+			if (1 == agent_ping)
+			{
+				zabbix_log(LOG_LEVEL_DEBUG, "%s() itemid:" ZBX_FS_UI64
+						" skipping because host is not found",
+						__function_name, dc_item->itemid);
+			}
 			continue;
+		}
 
 		if (HOST_MAINTENANCE_STATUS_ON == dc_host->maintenance_status &&
 				MAINTENANCE_TYPE_NODATA == dc_host->maintenance_type)
@@ -4397,6 +4470,12 @@
 			old_nextcheck = dc_item->nextcheck;
 			dc_item->nextcheck = DCget_reachable_nextcheck(dc_item, now);
 
+			if (1 == agent_ping)
+			{
+				zabbix_log(LOG_LEVEL_DEBUG, "%s() itemid:" ZBX_FS_UI64
+						" skipping because host is in maintenance",
+						__function_name, dc_item->itemid);
+			}
 			DCupdate_item_queue(dc_item, dc_item->poller_type, old_nextcheck);
 			continue;
 		}
@@ -4412,6 +4491,13 @@
 				old_nextcheck = dc_item->nextcheck;
 				dc_item->nextcheck = DCget_reachable_nextcheck(dc_item, now);
 
+				if (1 == agent_ping)
+				{
+					zabbix_log(LOG_LEVEL_DEBUG, "%s() itemid:" ZBX_FS_UI64
+							" skipping because queue is changed from %d to %d",
+							__function_name, dc_item->itemid,
+							(int)old_poller_type, (int)dc_item->poller_type);
+				}
 				DCupdate_item_queue(dc_item, old_poller_type, old_nextcheck);
 				continue;
 			}
@@ -4429,6 +4515,13 @@
 				if (disable_until > now)
 					dc_item->nextcheck = DCget_unreachable_nextcheck(dc_item, dc_host);
 
+				if (1 == agent_ping)
+				{
+					zabbix_log(LOG_LEVEL_DEBUG, "%s() itemid:" ZBX_FS_UI64
+							" skipping because queue is changed from %d to %d",
+							__function_name, dc_item->itemid,
+							(int)old_poller_type, (int)dc_item->poller_type);
+				}
 				DCupdate_item_queue(dc_item, old_poller_type, old_nextcheck);
 				continue;
 			}
@@ -4437,6 +4530,12 @@
 				old_nextcheck = dc_item->nextcheck;
 				dc_item->nextcheck = DCget_unreachable_nextcheck(dc_item, dc_host);
 
+				if (1 == agent_ping)
+				{
+					zabbix_log(LOG_LEVEL_DEBUG, "%s() itemid:" ZBX_FS_UI64
+							" skipping because disable_until is in future",
+							__function_name, dc_item->itemid);
+				}
 				DCupdate_item_queue(dc_item, dc_item->poller_type, old_nextcheck);
 				continue;
 			}
@@ -4444,6 +4543,12 @@
 			DCincrease_disable_until(dc_item, dc_host, now);
 		}
 
+		if (1 == agent_ping)
+		{
+			zabbix_log(LOG_LEVEL_DEBUG, "%s() itemid:" ZBX_FS_UI64 " taking item for processing",
+					__function_name, dc_item->itemid);
+		}
+
 		dc_item_prev = dc_item;
 		dc_item->location = ZBX_LOC_POLLER;
 		DCget_host(&items[num].host, dc_host);
@@ -4744,7 +4849,10 @@
 			continue;
 
 		if (NULL == (dc_item = zbx_hashset_search(&config->items, &itemids[i])))
+		{
+			zabbix_log(LOG_LEVEL_DEBUG, "DCrequeue_items() cannot find itemid:" ZBX_FS_UI64, itemids[i]);
 			continue;
+		}
 
 		dc_item->state = states[i];
 		dc_item->lastclock = lastclocks[i];
