--- ./include/log.h.orig	2015-08-10 10:56:47.000000000 +0200
+++ ./include/log.h	2015-10-07 13:36:07.000000000 +0200
@@ -33,6 +33,10 @@
 #define LOG_TYPE_SYSLOG		1
 #define LOG_TYPE_FILE		2
 
+#define LOG_PROC_STANDARD	0
+#define LOG_PROC_COUNT		1
+#define LOG_PROC_RATELIMIT	2
+
 typedef enum
 {
 	ERR_Z3001 = 3001,
--- ./src/zabbix_agent/logfiles.c.orig	2015-08-10 10:56:48.000000000 +0200
+++ ./src/zabbix_agent/logfiles.c	2015-10-07 13:39:01.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 log_proc_type, unsigned int *m_count)
 {
 	ZBX_THREAD_LOCAL static char	*buf = NULL;
 
@@ -1664,7 +1664,7 @@
 
 			for (;;)
 			{
-				if (0 >= *p_count || 0 >= *s_count)
+				if (0 >= *p_count || 0 >= *s_count && LOG_PROC_STANDARD == log_proc_type)
 				{
 					/* limit on number of processed or sent-to-server lines reached */
 					ret = SUCCEED;
@@ -1688,8 +1688,22 @@
 					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 (LOG_PROC_COUNT == log_proc_type)
+						{
+							(*m_count)++;
+							(*s_count)++;
+						}
+						else if (LOG_PROC_RATELIMIT == log_proc_type && 0 == *s_count)
+						{
+							zabbix_log(LOG_LEVEL_WARNING, "Rate limit reached for key '%s'. "
+								"Skipping data until parsing limit reached or EOF.", key);
+						}
+						else if (0 < *s_count)
+						{
+							send_err = process_value(server, port, hostname, key, item_value, ITEM_STATE_NORMAL,
 								&lastlogsize1, mtime, NULL, NULL, NULL, NULL, 1);
+						}
 
 						zbx_free(item_value);
 
@@ -1801,7 +1815,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 log_proc_type, unsigned int *m_count)
 {
 	const char	*__function_name = "process_log";
 
@@ -1854,7 +1868,8 @@
 		*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,
+				log_proc_type, m_count);
 	}
 	else
 	{
@@ -1930,7 +1945,8 @@
 		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 log_proc_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 +2112,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, log_proc_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-07 13:38:01.000000000 +0200
@@ -888,6 +888,10 @@
 #endif
 	char		encoding[32];
 	char		tmp[16];
+	unsigned int	m_count = 0;
+	char		match_count[21];
+	int		log_proc_type;
+	int		p_factor = 4;
 
 	AGENT_RESULT	result;
 
@@ -933,7 +937,7 @@
 					break;
 				}
 
-				if (6 < num_param(params))
+				if (7 < num_param(params))
 				{
 					err_msg = "Too many parameters.";
 					break;
@@ -979,11 +983,36 @@
 				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"))
+					log_proc_type = LOG_PROC_STANDARD;
+				else if (0 == strcmp(tmp, "count"))
+					log_proc_type = LOG_PROC_COUNT;
+				else if (0 == strcmp(tmp, "ratelimit") || 0 == strcmp(tmp, "ratelimit4"))
+					log_proc_type = LOG_PROC_RATELIMIT;
+				else if (0 == strcmp(tmp, "ratelimit8"))
+				{
+					log_proc_type = LOG_PROC_RATELIMIT;
+					p_factor = 8;
+				}
+				else if (0 == strcmp(tmp, "ratelimit16"))
+				{
+					log_proc_type = LOG_PROC_RATELIMIT;
+					p_factor = 16;
+				}
+				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;
 
 				/* do not flood local system if file grows too fast */
-				p_count = 4 * maxlines_persec * active_metrics[i].refresh;
+				p_count = p_factor * maxlines_persec * active_metrics[i].refresh;
 
 				err = active_metrics[i].error_count;
 
@@ -993,7 +1022,17 @@
 						&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, log_proc_type,
+						&m_count);
+
+				if (LOG_PROC_COUNT == log_proc_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-06 23:56:51.000000000 +0200
@@ -44,6 +44,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);
 
 #endif
