diff options
Diffstat (limited to 'src/libs/zbxsysinfo/freebsd/swap.c')
-rw-r--r-- | src/libs/zbxsysinfo/freebsd/swap.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/libs/zbxsysinfo/freebsd/swap.c b/src/libs/zbxsysinfo/freebsd/swap.c index db5aba02b5e..883ca444555 100644 --- a/src/libs/zbxsysinfo/freebsd/swap.c +++ b/src/libs/zbxsysinfo/freebsd/swap.c @@ -19,6 +19,7 @@ #include "common.h" #include "sysinfo.h" +#include "log.h" int SYSTEM_SWAP_SIZE(AGENT_REQUEST *request, AGENT_RESULT *result) { @@ -33,14 +34,21 @@ int SYSTEM_SWAP_SIZE(AGENT_REQUEST *request, AGENT_RESULT *result) zbx_uint64_t total = 0, used = 0; if (2 < request->nparam) + { + SET_MSG_RESULT(result, zbx_strdup(NULL, "Too many parameters.")); return SYSINFO_RET_FAIL; + } swapdev = get_rparam(request, 0); mode = get_rparam(request, 1); sz = ARRSIZE(mib); if (-1 == sysctlnametomib("vm.swap_info", mib, &sz)) - return FAIL; + { + SET_MSG_RESULT(result, zbx_dsprintf(NULL, "Cannot obtain \"vm.swap_info\" system parameter: %s", + zbx_strerror(errno))); + return SYSINFO_RET_FAIL; + } mib_sz = sz + 1; mib_dev = &(mib[sz]); @@ -70,10 +78,14 @@ int SYSTEM_SWAP_SIZE(AGENT_REQUEST *request, AGENT_RESULT *result) else if (0 == strcmp(mode, "pused")) SET_DBL_RESULT(result, total ? ((double)used * 100.0 / (double)total) : 0.0); else + { + SET_MSG_RESULT(result, zbx_strdup(NULL, "Invalid second parameter.")); return SYSINFO_RET_FAIL; + } return SYSINFO_RET_OK; #else + SET_MSG_RESULT(result, zbx_strdup(NULL, "Agent was compiled without support for \"xswdev\" structure.")); return SYSINFO_RET_FAIL; #endif } |