Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/zabbix/zabbix.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/zbxsysinfo/osx/memory.c')
-rw-r--r--src/libs/zbxsysinfo/osx/memory.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/libs/zbxsysinfo/osx/memory.c b/src/libs/zbxsysinfo/osx/memory.c
index f0435e2d8ea..c27da56141b 100644
--- a/src/libs/zbxsysinfo/osx/memory.c
+++ b/src/libs/zbxsysinfo/osx/memory.c
@@ -19,6 +19,7 @@
#include "common.h"
#include "sysinfo.h"
+#include "log.h"
static vm_size_t pagesize = 0;
@@ -29,7 +30,10 @@ static mach_msg_type_number_t count;
\
count = HOST_VM_INFO_COUNT; \
if (KERN_SUCCESS != host_statistics(mach_host_self(), HOST_VM_INFO, (host_info_t)&value, &count)) \
- return SYSINFO_RET_FAIL
+ { \
+ SET_MSG_RESULT(result, zbx_strdup(NULL, "Cannot obtain host statistics.")); \
+ return SYSINFO_RET_FAIL; \
+ }
static int mib[] = {CTL_HW, HW_MEMSIZE};
static size_t len;
@@ -39,7 +43,11 @@ static zbx_uint64_t memsize;
\
len = sizeof(value); \
if (0 != sysctl(mib, 2, &value, &len, NULL, 0)) \
- return SYSINFO_RET_FAIL
+ { \
+ SET_MSG_RESULT(result, zbx_dsprintf(NULL, "Cannot obtain system information: %s", \
+ zbx_strerror(errno))); \
+ return SYSINFO_RET_FAIL; \
+ }
static int VM_MEMORY_TOTAL(AGENT_RESULT *result)
{
@@ -102,7 +110,10 @@ static int VM_MEMORY_PUSED(AGENT_RESULT *result)
ZBX_SYSCTL(memsize);
if (0 == memsize)
+ {
+ SET_MSG_RESULT(result, zbx_strdup(NULL, "Cannot calculate percentage because total is zero."));
return SYSINFO_RET_FAIL;
+ }
ZBX_HOST_STATISTICS(vm);
@@ -129,7 +140,10 @@ static int VM_MEMORY_PAVAILABLE(AGENT_RESULT *result)
ZBX_SYSCTL(memsize);
if (0 == memsize)
+ {
+ SET_MSG_RESULT(result, zbx_strdup(NULL, "Cannot calculate percentage because total is zero."));
return SYSINFO_RET_FAIL;
+ }
ZBX_HOST_STATISTICS(vm);
@@ -146,12 +160,18 @@ int VM_MEMORY_SIZE(AGENT_REQUEST *request, AGENT_RESULT *result)
int ret = SYSINFO_RET_FAIL;
if (1 < request->nparam)
+ {
+ SET_MSG_RESULT(result, zbx_strdup(NULL, "Too many parameters."));
return SYSINFO_RET_FAIL;
+ }
if (0 == pagesize)
{
if (KERN_SUCCESS != host_page_size(mach_host_self(), &pagesize))
+ {
+ SET_MSG_RESULT(result, zbx_strdup(NULL, "Cannot obtain host page size."));
return SYSINFO_RET_FAIL;
+ }
}
mode = get_rparam(request, 0);
@@ -174,6 +194,11 @@ int VM_MEMORY_SIZE(AGENT_REQUEST *request, AGENT_RESULT *result)
ret = VM_MEMORY_AVAILABLE(result);
else if (0 == strcmp(mode, "pavailable"))
ret = VM_MEMORY_PAVAILABLE(result);
+ else
+ {
+ SET_MSG_RESULT(result, zbx_strdup(NULL, "Invalid first parameter."));
+ return SYSINFO_RET_FAIL;
+ }
return ret;
}