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/aix/inodes.c')
-rw-r--r--src/libs/zbxsysinfo/aix/inodes.c37
1 files changed, 34 insertions, 3 deletions
diff --git a/src/libs/zbxsysinfo/aix/inodes.c b/src/libs/zbxsysinfo/aix/inodes.c
index a505199ad9b..a2b9814993d 100644
--- a/src/libs/zbxsysinfo/aix/inodes.c
+++ b/src/libs/zbxsysinfo/aix/inodes.c
@@ -19,14 +19,23 @@
#include "common.h"
#include "sysinfo.h"
+#include "log.h"
int VFS_FS_INODE(AGENT_REQUEST *request, AGENT_RESULT *result)
{
#ifdef HAVE_SYS_STATVFS_H
-# define ZBX_STATFS statvfs
+# ifdef HAVE_SYS_STATVFS64
+# define ZBX_STATFS statvfs64
+# else
+# define ZBX_STATFS statvfs
+# endif
# define ZBX_FFREE f_favail
#else
-# define ZBX_STATFS statfs
+# ifdef HAVE_SYS_STATFS64
+# define ZBX_STATFS statfs64
+# else
+# define ZBX_STATFS statfs
+# endif
# define ZBX_FFREE f_ffree
#endif
char *fsname, *mode;
@@ -34,13 +43,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 */
SET_UI64_RESULT(result, s.f_files);
@@ -57,7 +79,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"))
{
@@ -68,10 +93,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;
}