#include "zbxsysinfo.h"
#include "../sysinfo.h"
#include "zbxregexp.h"
#include "zbxstr.h"
static int check_procstate(struct procentry64 *procentry, int zbx_proc_stat)
{
if (ZBX_PROC_STAT_ALL == zbx_proc_stat)
return SUCCEED;
switch (zbx_proc_stat)
{
case ZBX_PROC_STAT_RUN:
return SACTIVE == procentry->pi_state && 0 != procentry->pi_cpu ? SUCCEED : FAIL;
case ZBX_PROC_STAT_SLEEP:
return SACTIVE == procentry->pi_state && 0 == procentry->pi_cpu ? SUCCEED : FAIL;
case ZBX_PROC_STAT_ZOMB:
return SZOMB == procentry->pi_state ? SUCCEED : FAIL;
}
return FAIL;
}
static int match_procargs(struct procentry64 *procentry, const zbx_regexp_t *proccomm_rxp)
{
unsigned int i;
char procargs[MAX_BUFFER_LEN];
if (0 != getargs(procentry, (int)sizeof(*procentry), procargs, (int)sizeof(procargs)))
return FAIL;
for (i = 0; i < sizeof(procargs) - 1; i++)
{
if ('\0' == procargs[i])
{
if ('\0' == procargs[i + 1])
break;
procargs[i] = ' ';
}
}
if (i == sizeof(procargs) - 1)
procargs[i] = '\0';
return 0 == zbx_regexp_match_precompiled(procargs, proccomm_rxp) ? SUCCEED : FAIL;
}
int proc_mem(AGENT_REQUEST *request, AGENT_RESULT *result)
{
#define ZBX_VSIZE 0
#define ZBX_RSS 1
#define ZBX_PMEM 2
#define ZBX_SIZE 3
#define ZBX_DSIZE 4
#define ZBX_TSIZE 5
#define ZBX_SDSIZE 6
#define ZBX_DRSS 7
#define ZBX_TRSS 8
#ifdef _AIX61
# define ZBX_L2PSIZE(field) field
#else
# define ZBX_L2PSIZE(field) 12
#endif
char *param, *procname, *proccomm, *mem_type = NULL, *rxp_error = NULL;
struct passwd *usrinfo;
struct procentry64 procentry;
pid_t pid = 0;
int do_task, mem_type_code, proccount = 0, invalid_user = 0;
zbx_uint64_t mem_size = 0, byte_value = 0;
double pct_size = 0.0, pct_value = 0.0;