static vm_size_t pagesize = 0;
static struct vm_statistics vm;
static mach_msg_type_number_t count;
#define ZBX_HOST_STATISTICS(value) \
count = HOST_VM_INFO_COUNT; \
if (KERN_SUCCESS != host_statistics(mach_host_self(), HOST_VM_INFO, (host_info_t)&value, &count)) \
SET_MSG_RESULT(result, zbx_strdup(NULL, "Cannot obtain host statistics.")); \
return SYSINFO_RET_FAIL; \
static int mib[] = {CTL_HW, HW_MEMSIZE};
static zbx_uint64_t memsize;
#define ZBX_SYSCTL(value) \
if (0 != sysctl(mib, 2, &value, &len, NULL, 0)) \
SET_MSG_RESULT(result, zbx_dsprintf(NULL, "Cannot obtain system information: %s", \
return SYSINFO_RET_FAIL; \
static int vm_memory_total(AGENT_RESULT *result)
SET_UI64_RESULT(result, memsize);
static int vm_memory_active(AGENT_RESULT *result)
SET_UI64_RESULT(result, (zbx_uint64_t)vm.active_count * pagesize);