--- zabbix-2.4.2/src/libs/zbxserver/expression.c	2014-11-05 13:01:42.000000000 +0500
+++ zabbix-2.4.2-mod/src/libs/zbxserver/expression.c	2014-11-19 10:04:02.675034742 +0500
@@ -56,6 +56,12 @@
 #define ZBX_REQUEST_ITEM_LOG_NSEVERITY	206
 #define ZBX_REQUEST_ITEM_LOG_EVENTID	207
 
+/* DBget_interface_value() filter definitions */
+#define FILTER_DISABLE			0
+#define FILTER_AGENT_ONLY		1
+#define FILTER_SNMP_ONLY		2
+
+
 /******************************************************************************
  *                                                                            *
  * Function: get_N_functionid                                                 *
@@ -736,7 +742,7 @@
  * Comments:                                                                  *
  *                                                                            *
  ******************************************************************************/
-static int	DBget_interface_value(zbx_uint64_t hostid, char **replace_to, int request, unsigned char agent_only)
+static int	DBget_interface_value(zbx_uint64_t hostid, char **replace_to, int request, unsigned char filter)
 {
 	DB_RESULT	result;
 	DB_ROW		row;
@@ -744,13 +750,15 @@
 	char		sql[14];
 	int		ret = FAIL;
 
-	if (0 == agent_only)
+	if (filter == FILTER_AGENT_ONLY)
+		zbx_snprintf(sql, sizeof(sql), "=%d", INTERFACE_TYPE_AGENT);
+	else if (filter == FILTER_SNMP_ONLY)
+		zbx_snprintf(sql, sizeof(sql), "=%d", INTERFACE_TYPE_SNMP);
+	else
 	{
 		zbx_snprintf(sql, sizeof(sql), " in (%d,%d,%d,%d)",
 				INTERFACE_TYPE_AGENT, INTERFACE_TYPE_SNMP, INTERFACE_TYPE_IPMI, INTERFACE_TYPE_JMX);
 	}
-	else
-		zbx_snprintf(sql, sizeof(sql), "=%d", INTERFACE_TYPE_AGENT);
 
 	result = DBselect(
 			"select type,useip,ip,dns,port"
@@ -846,7 +854,7 @@
 			case ZBX_REQUEST_HOST_CONN:
 			case ZBX_REQUEST_HOST_PORT:
 				ZBX_STR2UINT64(hostid, row[0]);
-				ret = DBget_interface_value(hostid, replace_to, request, 0);
+				ret = DBget_interface_value(hostid, replace_to, request, FILTER_DISABLE);
 				break;
 			case ZBX_REQUEST_ITEM_ID:
 				*replace_to = zbx_strdup(*replace_to, row[5]);
@@ -1672,6 +1680,8 @@
 #define MVAR_TRIGGER_VALUE		"{TRIGGER.VALUE}"
 #define MVAR_TRIGGER_URL		"{TRIGGER.URL}"
 
+#define MVAR_SNMP_COMMUNITY		"{SNMP.COMMUNITY}"
+
 #define MVAR_TRIGGER_EVENTS_ACK			"{TRIGGER.EVENTS.ACK}"
 #define MVAR_TRIGGER_EVENTS_UNACK		"{TRIGGER.EVENTS.UNACK}"
 #define MVAR_TRIGGER_EVENTS_PROBLEM_ACK		"{TRIGGER.EVENTS.PROBLEM.ACK}"
@@ -1814,6 +1824,7 @@
 	MVAR_HOST_CONN, MVAR_HOST_DNS, MVAR_HOST_IP, MVAR_HOST_PORT, MVAR_IPADDRESS,
 	MVAR_ITEM_ID, MVAR_ITEM_NAME, MVAR_ITEM_NAME_ORIG, MVAR_ITEM_DESCRIPTION,
 	MVAR_ITEM_KEY, MVAR_ITEM_KEY_ORIG, MVAR_TRIGGER_KEY,
+	MVAR_SNMP_COMMUNITY,
 	MVAR_ITEM_LASTVALUE,
 	MVAR_ITEM_STATE,
 	MVAR_ITEM_VALUE,
@@ -3260,6 +3271,8 @@
 				else
 					ret = FAIL;
 			}
+			else if (0 == strcmp(m, MVAR_SNMP_COMMUNITY))
+				ret = DBget_interface_value(dc_item->host.hostid, &replace_to, ZBX_REQUEST_HOST_DNS, FILTER_SNMP_ONLY);
 		}
 		else if (0 != (macro_type & MACRO_TYPE_INTERFACE_ADDR))
 		{
@@ -3303,11 +3316,11 @@
 			else if (0 == strcmp(m, MVAR_HOST_NAME))
 				replace_to = zbx_strdup(replace_to, dc_host->name);
 			else if (0 == strcmp(m, MVAR_HOST_IP) || 0 == strcmp(m, MVAR_IPADDRESS))
-				ret = DBget_interface_value(dc_host->hostid, &replace_to, ZBX_REQUEST_HOST_IP, 1);
+				ret = DBget_interface_value(dc_host->hostid, &replace_to, ZBX_REQUEST_HOST_IP, FILTER_AGENT_ONLY);
 			else if	(0 == strcmp(m, MVAR_HOST_DNS))
-				ret = DBget_interface_value(dc_host->hostid, &replace_to, ZBX_REQUEST_HOST_DNS, 1);
+				ret = DBget_interface_value(dc_host->hostid, &replace_to, ZBX_REQUEST_HOST_DNS, FILTER_AGENT_ONLY);
 			else if (0 == strcmp(m, MVAR_HOST_CONN))
-				ret = DBget_interface_value(dc_host->hostid, &replace_to, ZBX_REQUEST_HOST_CONN, 1);
+				ret = DBget_interface_value(dc_host->hostid, &replace_to, ZBX_REQUEST_HOST_CONN, FILTER_AGENT_ONLY);
 		}
 		else if (0 != (macro_type & (MACRO_TYPE_COMMON | MACRO_TYPE_SNMP_OID)))
 		{
@@ -3337,11 +3350,11 @@
 			else if (0 == strcmp(m, MVAR_HOST_NAME))
 				replace_to = zbx_strdup(replace_to, dc_host->name);
 			else if (0 == strcmp(m, MVAR_HOST_IP) || 0 == strcmp(m, MVAR_IPADDRESS))
-				ret = DBget_interface_value(dc_host->hostid, &replace_to, ZBX_REQUEST_HOST_IP, 0);
+				ret = DBget_interface_value(dc_host->hostid, &replace_to, ZBX_REQUEST_HOST_IP, FILTER_DISABLE);
 			else if	(0 == strcmp(m, MVAR_HOST_DNS))
-				ret = DBget_interface_value(dc_host->hostid, &replace_to, ZBX_REQUEST_HOST_DNS, 0);
+				ret = DBget_interface_value(dc_host->hostid, &replace_to, ZBX_REQUEST_HOST_DNS, FILTER_DISABLE);
 			else if (0 == strcmp(m, MVAR_HOST_CONN))
-				ret = DBget_interface_value(dc_host->hostid, &replace_to, ZBX_REQUEST_HOST_CONN, 0);
+				ret = DBget_interface_value(dc_host->hostid, &replace_to, ZBX_REQUEST_HOST_CONN, FILTER_DISABLE);
 		}
 		else if (0 != (macro_type & MACRO_TYPE_HTTPTEST_FIELD))
 		{
@@ -3352,11 +3365,11 @@
 			else if (0 == strcmp(m, MVAR_HOST_NAME))
 				replace_to = zbx_strdup(replace_to, dc_host->name);
 			else if (0 == strcmp(m, MVAR_HOST_IP) || 0 == strcmp(m, MVAR_IPADDRESS))
-				ret = DBget_interface_value(dc_host->hostid, &replace_to, ZBX_REQUEST_HOST_IP, 0);
+				ret = DBget_interface_value(dc_host->hostid, &replace_to, ZBX_REQUEST_HOST_IP, FILTER_DISABLE);
 			else if	(0 == strcmp(m, MVAR_HOST_DNS))
-				ret = DBget_interface_value(dc_host->hostid, &replace_to, ZBX_REQUEST_HOST_DNS, 0);
+				ret = DBget_interface_value(dc_host->hostid, &replace_to, ZBX_REQUEST_HOST_DNS, FILTER_DISABLE);
 			else if (0 == strcmp(m, MVAR_HOST_CONN))
-				ret = DBget_interface_value(dc_host->hostid, &replace_to, ZBX_REQUEST_HOST_CONN, 0);
+				ret = DBget_interface_value(dc_host->hostid, &replace_to, ZBX_REQUEST_HOST_CONN, FILTER_DISABLE);
 		}
 
 		if (FAIL == ret)
