diff -uNr zabbix-2.2.3-orig/src/libs/zbxsysinfo/aix/proc.c zabbix-2.2.3-prepatched/src/libs/zbxsysinfo/aix/proc.c
--- zabbix-2.2.3-orig/src/libs/zbxsysinfo/aix/proc.c	2014-04-07 11:03:41.000000000 +0200
+++ zabbix-2.2.3-prepatched/src/libs/zbxsysinfo/aix/proc.c	2014-04-14 09:56:22.000000000 +0200
@@ -21,17 +21,14 @@
 #include "sysinfo.h"
 #include "zbxregexp.h"
 
-#if !defined(HAVE_SYS_PROCFS_H)
-#	include "../common/common.h"
-#endif
+#include "../common/common.h"
 
 #define DO_SUM 0
 #define DO_MAX 1
 #define DO_MIN 2
 #define DO_AVG 3
 
-#ifdef HAVE_SYS_PROCFS_H
-static int	check_procstate(psinfo_t *psinfo, int zbx_proc_stat)
+static int	check_procstate(struct procsinfo64 *procsinfo, int zbx_proc_stat)
 {
 	if (zbx_proc_stat == ZBX_PROC_STAT_ALL)
 		return SUCCEED;
@@ -39,49 +36,25 @@
 	switch (zbx_proc_stat)
 	{
 		case ZBX_PROC_STAT_RUN:
-			return (psinfo->pr_lwp.pr_sname == PR_SNAME_TSRUN) ? SUCCEED : FAIL;
+		        /* if (procsinfo->pi_state == SACTIVE && procsinfo->pi_cpu > 0)
+        		        printf ("proc=%s\n", procsinfo->pi_comm); */
+			return (procsinfo->pi_state == SACTIVE && procsinfo->pi_cpu > 0) ? SUCCEED : FAIL;
 		case ZBX_PROC_STAT_SLEEP:
-			return (psinfo->pr_lwp.pr_sname == PR_SNAME_TSSLEEP) ? SUCCEED : FAIL;
-		case ZBX_PROC_STAT_ZOMB:
-			return (psinfo->pr_lwp.pr_sname == PR_SNAME_TSZOMB) ? SUCCEED : FAIL;
-	}
-
-	return FAIL;
-}
-#else
-static int	check_procstate(struct procsinfo *procsinfo, int zbx_proc_stat)
-{
-	if (zbx_proc_stat == ZBX_PROC_STAT_ALL)
-		return SUCCEED;
-
-	switch (zbx_proc_stat)
-	{
-		case ZBX_PROC_STAT_RUN:
-			return (procsinfo->pi_state == SRUN) ? SUCCEED : FAIL;
-		case ZBX_PROC_STAT_SLEEP:
-			return (procsinfo->pi_state == SSLEEP) ? SUCCEED : FAIL;
+		        /* if (procsinfo->pi_state == SACTIVE && procsinfo->pi_cpu == 0)
+                	        printf ("proc=%s\n", procsinfo->pi_comm); */
+			return (procsinfo->pi_state == SACTIVE && procsinfo->pi_cpu == 0) ? SUCCEED : FAIL;
 		case ZBX_PROC_STAT_ZOMB:
 			return (procsinfo->pi_state == SZOMB) ? SUCCEED : FAIL;
 	}
-
 	return FAIL;
 }
-#endif /* HAVE_SYS_PROCFS_H */
 
 int	PROC_MEM(AGENT_REQUEST *request, AGENT_RESULT *result)
 {
-	char			tmp[MAX_STRING_LEN], *procname, *proccomm, *param;
-#ifdef HAVE_SYS_PROCFS_H
-	DIR			*dir;
-	struct dirent		*entries;
-	struct stat		buf;
-	struct psinfo		psinfo;
-	int			fd = -1;
-#else
-	struct procsinfo	procsinfo;
+	char			tmp[MAX_STRING_LEN], *procname, *proccomm, proccommargs[MAX_STRING_LEN], *param;
+	struct procsinfo64	procsinfo;
 	pid_t			pid = 0;
 	AGENT_RESULT		proc_args;
-#endif /* HAVE_SYS_PROCFS_H */
 	struct passwd		*usrinfo;
 	zbx_uint64_t		value = 0;
 	int			do_task;
@@ -117,59 +90,7 @@
 
 	proccomm = get_rparam(request, 3);
 
-#ifdef HAVE_SYS_PROCFS_H /* AIX 5.x */
-	if (NULL == (dir = opendir("/proc")))
-		return SYSINFO_RET_FAIL;
-
-	while (NULL != (entries = readdir(dir)))
-	{
-		if (-1 != fd)
-		{
-			close(fd);
-			fd = -1;
-		}
-
-		zbx_snprintf(tmp, sizeof(tmp), "/proc/%s/psinfo", entries->d_name);
-
-		if (0 != stat(tmp, &buf))
-			continue;
-
-		if (-1 == (fd = open(tmp, O_RDONLY)))
-			continue;
-
-		if (-1 == read(fd, &psinfo, sizeof(psinfo)))
-			continue;
-
-		if (NULL != procname && '\0' != *procname && 0 != strcmp(procname, psinfo.pr_fname))
-			continue;
-
-		if (NULL != usrinfo && usrinfo->pw_uid != psinfo.pr_uid)
-			continue;
-
-		if (NULL != proccomm && '\0' != *proccomm && NULL == zbx_regexp_match(psinfo.pr_psargs, proccomm, NULL))
-			continue;
-
-		value = psinfo.pr_size;
-		value <<= 10;	/* kB to Byte */
-
-		if (0 == proccount++)
-			memsize = value;
-		else
-		{
-			if (do_task == DO_MAX)
-				memsize = MAX(memsize, value);
-			else if (do_task == DO_MIN)
-				memsize = MIN(memsize, value);
-			else
-				memsize += value;
-		}
-	}
-
-	closedir(dir);
-	if (-1 != fd)
-		close(fd);
-#else
-	while (0 < getprocs(&procsinfo, (int)sizeof(struct procsinfo), NULL, 0, &pid, 1))
+	while (0 < getprocs(&procsinfo, (int)sizeof(struct procsinfo64), NULL, 0, &pid, 1))
 	{
 		if (NULL != procname && '\0' != *procname && 0 != strcmp(procname, procsinfo.pi_comm))
 			continue;
@@ -179,23 +100,25 @@
 
 		if (NULL != proccomm && '\0' != *proccomm)
 		{
-			init_result(&proc_args);
-
-			zbx_snprintf(tmp, sizeof(tmp), "ps -p %i -oargs=", procsinfo.pi_pid);
-
-			if (SYSINFO_RET_OK != EXECUTE_STR(tmp, &proc_args))
+			if (0 == getargs (&procsinfo, sizeof(procsinfo), &proccommargs[0], sizeof(proccommargs)))
 			{
-				free_result(&proc_args);
-				continue;
+				int i=0;
+				int sz = sizeof(proccommargs);
+				while (i < sz )
+				{
+					if (proccommargs[i] == 0 && proccommargs[i+1] == 0) break;
+					if (0 == proccommargs[i]) proccommargs[i] = ' ';
+					i++;
+				}
 			}
-			if (NULL == zbx_regexp_match(proc_args.str, proccomm, NULL))
+			else
+				*proccommargs = '\0'; /* case when process exited before we got to it*/
+			if (NULL == zbx_regexp_match(proccommargs,proccomm, NULL))
 			{
-				free_result(&proc_args);
 				continue;
 			}
-
-			free_result(&proc_args);
 		}
+ 
 
 		value = procsinfo.pi_size;
 		value <<= 12;	/* number of pages to bytes */
@@ -212,7 +135,6 @@
 				memsize += value;
 		}
         }
-#endif /* HAVE_SYS_PROCFS_H */
 
 	if (do_task == DO_AVG)
 	{
@@ -226,18 +148,10 @@
 
 int	PROC_NUM(AGENT_REQUEST *request, AGENT_RESULT *result)
 {
-	char			tmp[MAX_STRING_LEN], *procname, *proccomm, *param;
-#ifdef HAVE_SYS_PROCFS_H
-	DIR			*dir;
-	struct dirent		*entries;
-	struct stat		buf;
-	struct psinfo		psinfo;
-	int			fd = -1;
-#else
-	struct procsinfo	procsinfo;
+	char			tmp[MAX_STRING_LEN], *procname, *proccomm, proccommargs[MAX_STRING_LEN], *param;
+	struct procsinfo64	procsinfo;
 	pid_t			pid = 0;
 	AGENT_RESULT		proc_args;
-#endif /* HAVE_SYS_PROCFS_H */
 	struct passwd		*usrinfo;
 	int			zbx_proc_stat;
 	zbx_uint64_t		proccount = 0;
@@ -271,49 +185,7 @@
 
 	proccomm = get_rparam(request, 3);
 
-#ifdef HAVE_SYS_PROCFS_H /* AIX 5.x */
-	if (NULL == (dir = opendir("/proc")))
-		return SYSINFO_RET_FAIL;
-
-	while (NULL != (entries = readdir(dir)))
-	{
-		if (-1 != fd)
-		{
-			close(fd);
-			fd = -1;
-		}
-
-		zbx_snprintf(tmp, sizeof(tmp), "/proc/%s/psinfo", entries->d_name);
-
-		if (0 != stat(tmp, &buf))
-			continue;
-
-		if (-1 == (fd = open(tmp, O_RDONLY)))
-			continue;
-
-		if (-1 == read(fd, &psinfo, sizeof(psinfo)))
-			continue;
-
-		if (NULL != procname && '\0' != *procname && 0 != strcmp(procname, psinfo.pr_fname))
-			continue;
-
-		if (NULL != usrinfo && usrinfo->pw_uid != psinfo.pr_uid)
-			continue;
-
-		if (FAIL == check_procstate(&psinfo, zbx_proc_stat))
-			continue;
-
-		if (NULL != proccomm && '\0' != *proccomm && NULL == zbx_regexp_match(psinfo.pr_psargs, proccomm, NULL))
-			continue;
-
-		proccount++;
-	}
-
-	closedir(dir);
-	if (-1 != fd)
-		close(fd);
-#else
-	while (0 < getprocs(&procsinfo, (int)sizeof(struct procsinfo), NULL, 0, &pid, 1))
+	while (0 < getprocs(&procsinfo, (int)sizeof(struct procsinfo64), NULL, 0, &pid, 1))
 	{
 		if (NULL != procname && '\0' != *procname && 0 != strcmp(procname, procsinfo.pi_comm))
 			continue;
@@ -326,27 +198,26 @@
 
 		if (NULL != proccomm && '\0' != *proccomm)
 		{
-			init_result(&proc_args);
-
-			zbx_snprintf(tmp, sizeof(tmp), "ps -p %i -oargs=", procsinfo.pi_pid);
-
-			if (SYSINFO_RET_OK != EXECUTE_STR(tmp, &proc_args))
+			if (0 == getargs (&procsinfo, sizeof(procsinfo), &proccommargs[0], sizeof(proccommargs)))
 			{
-				free_result(&proc_args);
-				continue;
+				int i=0;
+				int sz = sizeof(proccommargs);
+				while (i < sz )
+				{
+					 if (proccommargs[i] == 0 && proccommargs[i+1] == 0) break;
+					 if (0 == proccommargs[i]) proccommargs[i] = ' ';
+					  i++;
+				}
 			}
-			if (NULL == zbx_regexp_match(proc_args.str, proccomm, NULL))
+			else
+				*proccommargs = '\0'; /* case when process exited before we got to it*/
+			if (NULL == zbx_regexp_match(proccommargs,proccomm, NULL))
 			{
-				free_result(&proc_args);
 				continue;
 			}
-
-			free_result(&proc_args);
 		}
-
 		proccount++;
         }
-#endif /* HAVE_SYS_PROCFS_H */
 
 	SET_UI64_RESULT(result, proccount);
 
