--- ./src/zabbix_agent/logfiles.c.orig	2015-08-10 10:56:48.000000000 +0200
+++ ./src/zabbix_agent/logfiles.c	2015-10-05 14:17:17.000000000 +0200
@@ -1523,7 +1523,7 @@
 static int	zbx_read2(int fd, zbx_uint64_t *lastlogsize, int *mtime, int *big_rec, int *incomplete, char **err_msg,
 		const char *encoding, zbx_vector_ptr_t *regexps, const char *pattern, const char *output_template,
 		int *p_count, int *s_count, zbx_process_value_func_t process_value, const char *server,
-		unsigned short port, const char *hostname, const char *key)
+		unsigned short port, const char *hostname, const char *key, int logproc_type, unsigned int *m_count)
 {
 	ZBX_THREAD_LOCAL static char	*buf = NULL;
 
@@ -1688,8 +1688,18 @@
 					if (SUCCEED == regexp_sub_ex(regexps, value, pattern, ZBX_CASE_SENSITIVE,
 							output_template, &item_value))
 					{
-						send_err = process_value(server, port, hostname, key, item_value, ITEM_STATE_NORMAL,
+
+						if (0 == logproc_type)
+						{
+							send_err = process_value(server, port, hostname, key, item_value, ITEM_STATE_NORMAL,
 								&lastlogsize1, mtime, NULL, NULL, NULL, NULL, 1);
+						}
+						else
+						{
+							(*m_count)++;
+							*lastlogsize = lastlogsize1;
+						}
+
 
 						zbx_free(item_value);
 
@@ -1801,7 +1811,7 @@
 		int *big_rec, int *incomplete, char **err_msg, const char *encoding, zbx_vector_ptr_t *regexps,
 		const char *pattern, const char *output_template, int *p_count, int *s_count,
 		zbx_process_value_func_t process_value, const char *server, unsigned short port, const char *hostname,
-		const char *key)
+		const char *key, int logproc_type, unsigned int *m_count)
 {
 	const char	*__function_name = "process_log";
 
@@ -1854,7 +1864,7 @@
 		*skip_old_data = 0;
 
 		ret = zbx_read2(f, lastlogsize, mtime, big_rec, incomplete, err_msg, encoding, regexps, pattern,
-				output_template, p_count, s_count, process_value, server, port, hostname, key);
+				output_template, p_count, s_count, process_value, server, port, hostname, key, logproc_type, m_count);
 	}
 	else
 	{
@@ -1930,7 +1940,7 @@
 		int *big_rec, int *use_ino, int *error_count, char **err_msg, struct st_logfile **logfiles_old,
 		int *logfiles_num_old, const char *encoding, zbx_vector_ptr_t *regexps, const char *pattern,
 		const char *output_template, int *p_count, int *s_count, zbx_process_value_func_t process_value,
-		const char *server, unsigned short port, const char *hostname, const char *key)
+		const char *server, unsigned short port, const char *hostname, const char *key, int logproc_type, unsigned int *m_count)
 {
 	const char		*__function_name = "process_logrt";
 	int			i, j, start_idx, ret = FAIL, logfiles_num = 0, logfiles_alloc = 0, seq = 1,
@@ -2096,7 +2106,7 @@
 			ret = process_log(logfiles[i].filename, lastlogsize, (1 == is_logrt) ? mtime : NULL,
 					skip_old_data, big_rec, &logfiles[i].incomplete, err_msg, encoding, regexps,
 					pattern, output_template, p_count, s_count, process_value, server, port,
-					hostname, key);
+					hostname, key, logproc_type, m_count);
 
 			/* process_log() advances 'lastlogsize' only on success therefore */
 			/* we do not check for errors here */
--- ./src/zabbix_agent/active.c.orig	2015-08-10 10:56:48.000000000 +0200
+++ ./src/zabbix_agent/active.c	2015-10-05 15:13:49.000000000 +0200
@@ -888,6 +888,9 @@
 #endif
 	char		encoding[32];
 	char		tmp[16];
+	unsigned int	m_count = 0;
+	char		match_count[21];
+	int		logproc_type;
 
 	AGENT_RESULT	result;
 
@@ -933,7 +936,7 @@
 					break;
 				}
 
-				if (6 < num_param(params))
+				if (7 < num_param(params))
 				{
 					err_msg = "Too many parameters.";
 					break;
@@ -979,6 +982,19 @@
 				if (0 != get_param(params, 6, output_template, sizeof(output_template)))
 					*output_template = '\0';
 
+				if (0 != get_param(params, 7, tmp, sizeof(tmp)))
+					*tmp = '\0';
+
+				if ('\0' == *tmp || 0 == strcmp(tmp, "standard"))
+					logproc_type = 0;
+				else if (0 == strcmp(tmp, "count"))
+					logproc_type = 1;
+				else
+				{
+					err_msg = "Invalid seventh parameter.";
+					break;
+				}
+
 				/* do not flood Zabbix server if file grows too fast */
 				s_count = maxlines_persec * active_metrics[i].refresh;
 
@@ -993,7 +1009,16 @@
 						&active_metrics[i].error_count, &err_msg_dyn,
 						&active_metrics[i].logfiles, &active_metrics[i].logfiles_num, encoding,
 						&regexps, pattern, output_template, &p_count, &s_count, process_value,
-						server, port, CONFIG_HOSTNAME, active_metrics[i].key_orig);
+						server, port, CONFIG_HOSTNAME, active_metrics[i].key_orig, logproc_type, &m_count);
+
+				if (0 != logproc_type)
+				{
+					zbx_snprintf(match_count, sizeof(match_count), "%d", m_count); 
+					process_value(server, port, CONFIG_HOSTNAME, active_metrics[i].key_orig, match_count, ITEM_STATE_NORMAL,
+						&active_metrics[i].lastlogsize, &active_metrics[i].mtime, NULL, NULL, NULL, NULL, 1);
+					m_count = 0;
+
+				}
 
 				/* reset errors if things have improved */
 				if (0 < active_metrics[i].error_count && SUCCEED == ret
--- ./src/zabbix_agent/logfiles.h.orig	2015-08-10 10:56:48.000000000 +0200
+++ ./src/zabbix_agent/logfiles.h	2015-10-05 13:37:07.000000000 +0200
@@ -44,6 +44,6 @@
 		int *big_rec, int *use_ino, int *error_count, char **err_msg, struct st_logfile **logfiles_old,
 		int *logfiles_num_old, const char *encoding, zbx_vector_ptr_t *regexps, const char *pattern,
 		const char *output_template, int *p_count, int *s_count, zbx_process_value_func_t process_value,
-		const char *server, unsigned short port, const char *hostname, const char *key);
+		const char *server, unsigned short port, const char *hostname, const char *key, int logproc_type, unsigned int *match_count);
 
 #endif
