- reordered functions VM_MEMORY_* to put them in the order as they are used in
  VM_MEMORY_SIZE()
- added vm.memory.size[] key new parameters:
  - vm.memory.size[active]
  - vm.memory.size[anon]
  - vm.memory.size[inactive]
  - vm.memory.size[slabs]
- added new function VM_MEMORY_PROC_MEMINFO() which is used to handle new
  vm.memory.size[] parameters
- use VM_MEMORY_PROC_MEMINFO() to havndle:
  - vm.memory.size[cached]
Index: 3.4/src/libs/zbxsysinfo/linux/memory.c
===================================================================
--- 3.4/src/libs/zbxsysinfo/linux/memory.c	(revision 76237)
+++ 3.4/src/libs/zbxsysinfo/linux/memory.c	(working copy)
@@ -37,38 +37,8 @@
 	return SYSINFO_RET_OK;
 }
 
-static int	VM_MEMORY_FREE(AGENT_RESULT *result)
+static int	VM_MEMORY_PROC_MEMINFO(const char *meminfo_entry, AGENT_RESULT *result)
 {
-	struct sysinfo	info;
-
-	if (0 != sysinfo(&info))
-	{
-		SET_MSG_RESULT(result, zbx_dsprintf(NULL, "Cannot obtain system information: %s", zbx_strerror(errno)));
-		return SYSINFO_RET_FAIL;
-	}
-
-	SET_UI64_RESULT(result, (zbx_uint64_t)info.freeram * info.mem_unit);
-
-	return SYSINFO_RET_OK;
-}
-
-static int	VM_MEMORY_BUFFERS(AGENT_RESULT *result)
-{
-	struct sysinfo	info;
-
-	if (0 != sysinfo(&info))
-	{
-		SET_MSG_RESULT(result, zbx_dsprintf(NULL, "Cannot obtain system information: %s", zbx_strerror(errno)));
-		return SYSINFO_RET_FAIL;
-	}
-
-	SET_UI64_RESULT(result, (zbx_uint64_t)info.bufferram * info.mem_unit);
-
-	return SYSINFO_RET_OK;
-}
-
-static int	VM_MEMORY_CACHED(AGENT_RESULT *result)
-{
 	FILE		*f;
 	zbx_uint64_t	value;
 	int		res;
@@ -79,9 +49,9 @@
 		return SYSINFO_RET_FAIL;
 	}
 
-	if (FAIL == (res = byte_value_from_proc_file(f, "Cached:", NULL, &value)))
+	if (FAIL == (res = byte_value_from_proc_file(f, meminfo_entry, NULL, &value)))
 	{
-		SET_MSG_RESULT(result, zbx_strdup(NULL, "Cannot obtain the value of Cached from /proc/meminfo."));
+		SET_MSG_RESULT(result, zbx_dsprintf(NULL, "Cannot obtain the value of %f from /proc/meminfo.", meminfo_entry));
 		goto close;
 	}
 
@@ -95,42 +65,6 @@
 	return SYSINFO_RET_OK;
 }
 
-static int	VM_MEMORY_USED(AGENT_RESULT *result)
-{
-	struct sysinfo	info;
-
-	if (0 != sysinfo(&info))
-	{
-		SET_MSG_RESULT(result, zbx_dsprintf(NULL, "Cannot obtain system information: %s", zbx_strerror(errno)));
-		return SYSINFO_RET_FAIL;
-	}
-
-	SET_UI64_RESULT(result, (zbx_uint64_t)(info.totalram - info.freeram) * info.mem_unit);
-
-	return SYSINFO_RET_OK;
-}
-
-static int	VM_MEMORY_PUSED(AGENT_RESULT *result)
-{
-	struct sysinfo	info;
-
-	if (0 != sysinfo(&info))
-	{
-		SET_MSG_RESULT(result, zbx_dsprintf(NULL, "Cannot obtain system information: %s", zbx_strerror(errno)));
-		return SYSINFO_RET_FAIL;
-	}
-
-	if (0 == info.totalram)
-	{
-		SET_MSG_RESULT(result, zbx_strdup(NULL, "Cannot calculate percentage because total is zero."));
-		return SYSINFO_RET_FAIL;
-	}
-
-	SET_DBL_RESULT(result, (info.totalram - info.freeram) / (double)info.totalram * 100);
-
-	return SYSINFO_RET_OK;
-}
-
 static int	VM_MEMORY_AVAILABLE(AGENT_RESULT *result)
 {
 	FILE		*f;
@@ -182,6 +116,36 @@
 	return ret;
 }
 
+static int	VM_MEMORY_BUFFERS(AGENT_RESULT *result)
+{
+	struct sysinfo	info;
+
+	if (0 != sysinfo(&info))
+	{
+		SET_MSG_RESULT(result, zbx_dsprintf(NULL, "Cannot obtain system information: %s", zbx_strerror(errno)));
+		return SYSINFO_RET_FAIL;
+	}
+
+	SET_UI64_RESULT(result, (zbx_uint64_t)info.bufferram * info.mem_unit);
+
+	return SYSINFO_RET_OK;
+}
+
+static int	VM_MEMORY_FREE(AGENT_RESULT *result)
+{
+	struct sysinfo	info;
+
+	if (0 != sysinfo(&info))
+	{
+		SET_MSG_RESULT(result, zbx_dsprintf(NULL, "Cannot obtain system information: %s", zbx_strerror(errno)));
+		return SYSINFO_RET_FAIL;
+	}
+
+	SET_UI64_RESULT(result, (zbx_uint64_t)info.freeram * info.mem_unit);
+
+	return SYSINFO_RET_OK;
+}
+
 static int	VM_MEMORY_PAVAILABLE(AGENT_RESULT *result)
 {
 	struct sysinfo	info;
@@ -222,6 +186,27 @@
 	return ret;
 }
 
+static int	VM_MEMORY_PUSED(AGENT_RESULT *result)
+{
+	struct sysinfo	info;
+
+	if (0 != sysinfo(&info))
+	{
+		SET_MSG_RESULT(result, zbx_dsprintf(NULL, "Cannot obtain system information: %s", zbx_strerror(errno)));
+		return SYSINFO_RET_FAIL;
+	}
+
+	if (0 == info.totalram)
+	{
+		SET_MSG_RESULT(result, zbx_strdup(NULL, "Cannot calculate percentage because total is zero."));
+		return SYSINFO_RET_FAIL;
+	}
+
+	SET_DBL_RESULT(result, (info.totalram - info.freeram) / (double)info.totalram * 100);
+
+	return SYSINFO_RET_OK;
+}
+
 static int	VM_MEMORY_SHARED(AGENT_RESULT *result)
 {
 #ifdef KERNEL_2_4
@@ -242,6 +227,21 @@
 #endif
 }
 
+static int	VM_MEMORY_USED(AGENT_RESULT *result)
+{
+	struct sysinfo	info;
+
+	if (0 != sysinfo(&info))
+	{
+		SET_MSG_RESULT(result, zbx_dsprintf(NULL, "Cannot obtain system information: %s", zbx_strerror(errno)));
+		return SYSINFO_RET_FAIL;
+	}
+
+	SET_UI64_RESULT(result, (zbx_uint64_t)(info.totalram - info.freeram) * info.mem_unit);
+
+	return SYSINFO_RET_OK;
+}
+
 int	VM_MEMORY_SIZE(AGENT_REQUEST *request, AGENT_RESULT *result)
 {
 	char	*mode;
@@ -257,22 +257,30 @@
 
 	if (NULL == mode || '\0' == *mode || 0 == strcmp(mode, "total"))
 		ret = VM_MEMORY_TOTAL(result);
-	else if (0 == strcmp(mode, "free"))
-		ret = VM_MEMORY_FREE(result);
+	else if (0 == strcmp(mode, "active"))
+		ret = VM_MEMORY_PROC_MEMINFO("Active:", result);
+	else if (0 == strcmp(mode, "anon"))
+		ret = VM_MEMORY_PROC_MEMINFO("AnonPages:", result);
+	else if (0 == strcmp(mode, "available"))
+		VM_MEMORY_AVAILABLE(result);
 	else if (0 == strcmp(mode, "buffers"))
 		ret = VM_MEMORY_BUFFERS(result);
 	else if (0 == strcmp(mode, "cached"))
-		ret = VM_MEMORY_CACHED(result);
-	else if (0 == strcmp(mode, "used"))
-		ret = VM_MEMORY_USED(result);
+		ret = VM_MEMORY_PROC_MEMINFO("Cached:", result);
+	else if (0 == strcmp(mode, "free"))
+		ret = VM_MEMORY_FREE(result);
+	else if (0 == strcmp(mode, "inactive"))
+		ret = VM_MEMORY_PROC_MEMINFO("Inactive:", result);
+	else if (0 == strcmp(mode, "pavailable"))
+		ret = VM_MEMORY_PAVAILABLE(result);
 	else if (0 == strcmp(mode, "pused"))
 		ret = VM_MEMORY_PUSED(result);
-	else if (0 == strcmp(mode, "available"))
-		ret = VM_MEMORY_AVAILABLE(result);
-	else if (0 == strcmp(mode, "pavailable"))
-		ret = VM_MEMORY_PAVAILABLE(result);
 	else if (0 == strcmp(mode, "shared"))
 		ret = VM_MEMORY_SHARED(result);
+	else if (0 == strcmp(mode, "slab"))
+		ret = VM_MEMORY_PROC_MEMINFO("Slab:", result);
+	else if (0 == strcmp(mode, "used"))
+		ret = VM_MEMORY_USED(result);
 	else
 	{
 		SET_MSG_RESULT(result, zbx_strdup(NULL, "Invalid first parameter."));
