#include "zbx_sysinfo_kstat.h"
#include "../common/stats.h"
int system_cpu_num(AGENT_REQUEST *request, AGENT_RESULT *result)
SET_MSG_RESULT(result, zbx_strdup(NULL, "Too many parameters."));
tmp = get_rparam(request, 0);
if (NULL == tmp || '\0' == *tmp || 0 == strcmp(tmp, "online"))
name = _SC_NPROCESSORS_ONLN;
else if (0 == strcmp(tmp, "max"))
name = _SC_NPROCESSORS_CONF;
SET_MSG_RESULT(result, zbx_strdup(NULL, "Invalid first parameter."));
if (-1 == (ncpu = sysconf(name)))
SET_MSG_RESULT(result, zbx_strdup(NULL, "Cannot obtain number of CPUs."));
SET_UI64_RESULT(result, ncpu);
int system_cpu_util(AGENT_REQUEST *request, AGENT_RESULT *result)
int cpu_num, state, mode;
SET_MSG_RESULT(result, zbx_strdup(NULL, "Too many parameters."));
tmp = get_rparam(request, 0);
if (NULL == tmp || '\0' == *tmp || 0 == strcmp(tmp, "all"))
cpu_num = ZBX_CPUNUM_ALL;
else if (SUCCEED != zbx_is_uint31_1(tmp, &cpu_num))
SET_MSG_RESULT(result, zbx_strdup(NULL, "Invalid first parameter."));
tmp = get_rparam(request, 1);
if (NULL == tmp || '\0' == *tmp || 0 == strcmp(tmp, "user"))
state = ZBX_CPU_STATE_USER;
else if (0 == strcmp(tmp, "iowait"))
state = ZBX_CPU_STATE_IOWAIT;
else if (0 == strcmp(tmp, "system"))
state = ZBX_CPU_STATE_SYSTEM;
else if (0 == strcmp(tmp, "idle"))
state = ZBX_CPU_STATE_IDLE;
SET_MSG_RESULT(result, zbx_strdup(NULL, "Invalid second parameter."));