Index: src/zabbix_server/poller/checks_snmp.c
===================================================================
--- src/zabbix_server/poller/checks_snmp.c	(revision 48134)
+++ src/zabbix_server/poller/checks_snmp.c	(working copy)
@@ -880,6 +880,66 @@
 	return ret;
 }
 
+static void	print_pdu(netsnmp_pdu *pdu)
+{
+	int q;
+	struct variable_list	*pdu_var;
+
+	if (NULL == pdu)
+	{
+		zabbix_log(LOG_LEVEL_ERR, "pdu is NULL!");
+		return;
+	}
+
+	zabbix_log(LOG_LEVEL_ERR, "pdu:\n "
+			"version=%ld, command=%d, reqid=%ld, "
+			"msgid=%ld, transid=%ld, sessid=%ld, "
+			"errstat=%ld, errindex=%ld, time="ZBX_FS_UI64", "
+			"flags="ZBX_FS_UI64", securityModel=%d, securityLevel=%d, "
+			"msgParseModel=%d, transport_data=%p, "
+			"transport_data_length=%d, tDomain=%p, "
+			"tDomainLen=%u, variables=%p, community=%p, "
+			"community_len=%u, enterprise=%p, enterprise_length=%u, "
+			"trap_type="ZBX_FS_UI64", specific_type="ZBX_FS_UI64", "
+			"agent_addr=%u.%u.%u.%u, "
+			"contextEngineID=%p, contextEngineIDLen=%u, contextName=%p, "
+			"contextNameLen=%u, securityEngineID=%p, securityEngineIDLen=%u,"
+			"securityName=%p, securityNameLen=%u, priority=%d, "
+			"range_subid=%d, securityStateRef=%p",
+			pdu->version, pdu->command, pdu->reqid,
+			pdu->msgid, pdu->transid, pdu->sessid,
+			pdu->errstat, pdu->errindex, pdu->time,
+			pdu->flags, pdu->securityModel, pdu->securityLevel,
+			pdu->msgParseModel, pdu->transport_data,
+			pdu->transport_data_length, pdu->tDomain,
+			pdu->tDomainLen, pdu->variables, pdu->community,
+			pdu->community_len, pdu->enterprise, pdu->enterprise_length,
+			pdu->trap_type, pdu->specific_type,
+			pdu->agent_addr[0], pdu->agent_addr[1], pdu->agent_addr[2], pdu->agent_addr[3],
+			pdu->contextEngineID, pdu->contextEngineIDLen, pdu->contextName,
+			pdu->contextNameLen, pdu->securityEngineID, pdu->securityEngineIDLen,
+			pdu->securityName, pdu->securityNameLen, pdu->priority,
+			pdu->range_subid, pdu->securityStateRef);
+
+	zabbix_log(LOG_LEVEL_ERR, "pdu variables:");
+	for (q = 0, pdu_var = pdu->variables;
+			pdu_var != NULL && q < MAX_SNMP_ITEMS;
+			q++, pdu_var = pdu_var->next_variable)
+	{
+		zabbix_log(LOG_LEVEL_ERR,
+				"this variable=%p, next_variable=%p, name="ZBX_FS_UI64", "
+				"name_length=%d, type=%u, "
+				"val.data=%p, val_len=%u, "
+				"name_loc=%p, buf=%p, "
+				"data=%p, index=%d",
+				pdu_var, pdu_var->next_variable, pdu_var->name,
+				pdu_var->name_length, pdu_var->type,
+				pdu_var->val.integer, pdu_var->val_len,
+				pdu_var->name_loc, pdu_var->buf,
+				pdu_var->data, pdu_var->index);
+	}
+}
+
 static int	zbx_snmp_get_values(struct snmp_session *ss, const DC_ITEM *items, char oids[][ITEM_SNMP_OID_LEN_MAX],
 		AGENT_RESULT *results, int *errcodes, unsigned char *query_and_ignore_type, int num, int level,
 		char *error, int max_error_len, int *max_succeed, int *min_fail)
@@ -949,6 +1009,39 @@
 		{
 			j = mapping[i];
 
+			/* XXX: additional log for ZBX-8621 */
+			if ( i > mapping_num || j > MAX_SNMP_ITEMS )
+			{
+				int q;
+				char *mapping_buffer = NULL;
+
+				for (q = 0; q < MAX_SNMP_ITEMS; q++)
+					mapping_buffer = zbx_strdcatf(mapping_buffer, "[%d]%d\t", q, mapping[q]);
+
+				zabbix_log(LOG_LEVEL_ERR, "-----------ZBX-8621-----------");
+				zabbix_log(LOG_LEVEL_ERR, "zbx_snmp_get_values() parameters: "
+						"ss=%p, items=%p, oids=%p, results=%p, errcodes=%p, "
+						"query_and_ignore_type=%p, num=%d, level=%d, error=%p "
+						"max_error_len=%d, max_succeed=%p, min_fail=%p",
+						ss, items, oids, results, errcodes,
+						query_and_ignore_type, num, level, error,
+						max_error_len, max_succeed, min_fail);
+
+				zabbix_log(LOG_LEVEL_ERR, "internal variables:\n i=%d, j=%d, mapping_num=%d",
+						i, j, mapping_num);
+				zabbix_log(LOG_LEVEL_ERR, "mapping[]:%s", mapping_buffer);
+
+				zabbix_log(LOG_LEVEL_ERR, "---pdu response:---");
+				print_pdu(response);
+
+				zabbix_log(LOG_LEVEL_ERR, "-----------ZBX-8621-end-----------");
+
+				zbx_free(mapping_buffer);
+
+				zbx_on_exit();
+			}
+
+
 			if (NULL != query_and_ignore_type && 1 == query_and_ignore_type[j])
 			{
 				(void)zbx_snmp_set_result(var, ITEM_VALUE_TYPE_STR, 0, &results[j]);
