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/freebsd/inodes.c')
-rw-r--r--src/libs/zbxsysinfo/freebsd/inodes.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/libs/zbxsysinfo/freebsd/inodes.c b/src/libs/zbxsysinfo/freebsd/inodes.c
index f6d50fa6615..049a12bd011 100644
--- a/src/libs/zbxsysinfo/freebsd/inodes.c
+++ b/src/libs/zbxsysinfo/freebsd/inodes.c
@@ -19,6 +19,7 @@
#include "common.h"
#include "sysinfo.h"
+#include "log.h"
int VFS_FS_INODE(AGENT_REQUEST *request, AGENT_RESULT *result)
{
@@ -34,13 +35,26 @@ int VFS_FS_INODE(AGENT_REQUEST *request, AGENT_RESULT *result)
struct ZBX_STATFS s;
if (2 < request->nparam)
+ {
+ SET_MSG_RESULT(result, zbx_strdup(NULL, "Too many parameters."));
return SYSINFO_RET_FAIL;
+ }
fsname = get_rparam(request, 0);
mode = get_rparam(request, 1);
- if (NULL == fsname || '\0' == *fsname || 0 != ZBX_STATFS(fsname, &s))
+ if (NULL == fsname || '\0' == *fsname)
+ {
+ SET_MSG_RESULT(result, zbx_strdup(NULL, "Invalid first parameter."));
+ return SYSINFO_RET_FAIL;
+ }
+
+ if (0 != ZBX_STATFS(fsname, &s))
+ {
+ SET_MSG_RESULT(result, zbx_dsprintf(NULL, "Cannot obtain filesystem information: %s",
+ zbx_strerror(errno)));
return SYSINFO_RET_FAIL;
+ }
if (NULL == mode || '\0' == *mode || 0 == strcmp(mode, "total")) /* default parameter */
{
@@ -63,7 +77,10 @@ int VFS_FS_INODE(AGENT_REQUEST *request, AGENT_RESULT *result)
if (0 != total)
SET_DBL_RESULT(result, (double)(100.0 * s.ZBX_FFREE) / total);
else
+ {
+ SET_MSG_RESULT(result, zbx_strdup(NULL, "Cannot calculate percentage because total is zero."));
return SYSINFO_RET_FAIL;
+ }
}
else if (0 == strcmp(mode, "pused"))
{
@@ -74,10 +91,16 @@ int VFS_FS_INODE(AGENT_REQUEST *request, AGENT_RESULT *result)
if (0 != total)
SET_DBL_RESULT(result, 100.0 - (double)(100.0 * s.ZBX_FFREE) / total);
else
+ {
+ SET_MSG_RESULT(result, zbx_strdup(NULL, "Cannot calculate percentage because total is zero."));
return SYSINFO_RET_FAIL;
+ }
}
else
+ {
+ SET_MSG_RESULT(result, zbx_strdup(NULL, "Invalid second parameter."));
return SYSINFO_RET_FAIL;
+ }
return SYSINFO_RET_OK;
}