summaryrefslogtreecommitdiffstats
path: root/src/libs/zbxsysinfo/linux
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/zbxsysinfo/linux')
-rw-r--r--src/libs/zbxsysinfo/linux/cpu.c34
-rw-r--r--src/libs/zbxsysinfo/linux/diskio.c6
-rw-r--r--src/libs/zbxsysinfo/linux/diskspace.c323
-rw-r--r--src/libs/zbxsysinfo/linux/inodes.c200
-rw-r--r--src/libs/zbxsysinfo/linux/memory.c38
-rw-r--r--src/libs/zbxsysinfo/linux/net.c4
-rw-r--r--src/libs/zbxsysinfo/linux/proc.c4
-rw-r--r--src/libs/zbxsysinfo/linux/sensors.c8
-rw-r--r--src/libs/zbxsysinfo/linux/swap.c16
-rw-r--r--src/libs/zbxsysinfo/linux/uptime.c8
10 files changed, 218 insertions, 423 deletions
diff --git a/src/libs/zbxsysinfo/linux/cpu.c b/src/libs/zbxsysinfo/linux/cpu.c
index ca161e58..529737f6 100644
--- a/src/libs/zbxsysinfo/linux/cpu.c
+++ b/src/libs/zbxsysinfo/linux/cpu.c
@@ -46,7 +46,7 @@ CPU_FNCLIST
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
if(num_param(param) > 2)
{
@@ -122,7 +122,7 @@ CPU_FNCLIST
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
if(num_param(param) > 3)
{
@@ -283,7 +283,7 @@ int SYSTEM_CPU_LOAD1(const char *cmd, const char *param, unsigned flags, AGENT_R
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
if(getloadavg(load, 3))
{
@@ -301,7 +301,7 @@ int SYSTEM_CPU_LOAD1(const char *cmd, const char *param, unsigned flags, AGENT_R
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
if (pstat_getdynamic(&dyn, sizeof(dyn), 1, 0) == -1)
{
@@ -324,7 +324,7 @@ int SYSTEM_CPU_LOAD1(const char *cmd, const char *param, unsigned flags, AGENT_R
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
if (!kc && !(kc = kstat_open()))
{
@@ -345,7 +345,7 @@ int SYSTEM_CPU_LOAD1(const char *cmd, const char *param, unsigned flags, AGENT_R
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
if(getloadavg_kmem(loadavg,3) == FAIL)
{
@@ -358,7 +358,7 @@ int SYSTEM_CPU_LOAD1(const char *cmd, const char *param, unsigned flags, AGENT_R
#else
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
return SYSINFO_RET_FAIL;
#endif
#endif
@@ -374,7 +374,7 @@ int SYSTEM_CPU_LOAD5(const char *cmd, const char *param, unsigned flags, AGENT_R
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
if(getloadavg(load, 3))
{
@@ -392,7 +392,7 @@ int SYSTEM_CPU_LOAD5(const char *cmd, const char *param, unsigned flags, AGENT_R
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
if (pstat_getdynamic(&dyn, sizeof(dyn), 1, 0) == -1)
{
@@ -415,7 +415,7 @@ int SYSTEM_CPU_LOAD5(const char *cmd, const char *param, unsigned flags, AGENT_R
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
if (!kc && !(kc = kstat_open()))
{
@@ -436,7 +436,7 @@ int SYSTEM_CPU_LOAD5(const char *cmd, const char *param, unsigned flags, AGENT_R
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
if(getloadavg_kmem(loadavg,3) == FAIL)
{
@@ -449,7 +449,7 @@ int SYSTEM_CPU_LOAD5(const char *cmd, const char *param, unsigned flags, AGENT_R
#else
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
return SYSINFO_RET_FAIL;
#endif
#endif
@@ -465,7 +465,7 @@ int SYSTEM_CPU_LOAD15(const char *cmd, const char *param, unsigned flags, AGENT_
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
if(getloadavg(load, 3))
{
@@ -483,7 +483,7 @@ int SYSTEM_CPU_LOAD15(const char *cmd, const char *param, unsigned flags, AGENT_
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
if (pstat_getdynamic(&dyn, sizeof(dyn), 1, 0) == -1)
{
@@ -506,7 +506,7 @@ int SYSTEM_CPU_LOAD15(const char *cmd, const char *param, unsigned flags, AGENT_
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
if (!kc && !(kc = kstat_open()))
{
@@ -527,7 +527,7 @@ int SYSTEM_CPU_LOAD15(const char *cmd, const char *param, unsigned flags, AGENT_
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
if(getloadavg_kmem(loadavg,3) == FAIL)
{
@@ -540,7 +540,7 @@ int SYSTEM_CPU_LOAD15(const char *cmd, const char *param, unsigned flags, AGENT_
#else
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
return SYSINFO_RET_FAIL;
#endif
#endif
diff --git a/src/libs/zbxsysinfo/linux/diskio.c b/src/libs/zbxsysinfo/linux/diskio.c
index 328dceb3..a761187e 100644
--- a/src/libs/zbxsysinfo/linux/diskio.c
+++ b/src/libs/zbxsysinfo/linux/diskio.c
@@ -51,7 +51,7 @@ DEV_FNCLIST
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
if(num_param(param) > 3)
{
@@ -127,7 +127,7 @@ DEV_FNCLIST
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
if(num_param(param) > 3)
{
@@ -334,7 +334,7 @@ int OLD_IO(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *res
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
if(num_param(param) > 1)
{
diff --git a/src/libs/zbxsysinfo/linux/diskspace.c b/src/libs/zbxsysinfo/linux/diskspace.c
index 9db5895a..3fde0069 100644
--- a/src/libs/zbxsysinfo/linux/diskspace.c
+++ b/src/libs/zbxsysinfo/linux/diskspace.c
@@ -48,7 +48,7 @@ FS_FNCLIST
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
if(num_param(param) > 2)
{
@@ -81,316 +81,165 @@ FS_FNCLIST
return SYSINFO_RET_FAIL;
}
-int VFS_FS_FREE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+int get_fs_size_stat(char *fs, double *total, double *free, double *usage)
{
#ifdef HAVE_SYS_STATVFS_H
- struct statvfs s;
- char mountPoint[MAX_STRING_LEN];
-
- assert(result);
-
- memset(result, 0, sizeof(AGENT_RESULT));
-
- if(num_param(param) > 1)
- {
- return SYSINFO_RET_FAIL;
- }
-
- if(get_param(param, 1, mountPoint, MAX_STRING_LEN) != 0)
- {
- return SYSINFO_RET_FAIL;
- }
-
- if ( statvfs( (char *)mountPoint, &s) != 0 )
- {
- return SYSINFO_RET_FAIL;
- }
-
- result->type |= AR_DOUBLE;
- result->dbl = (double)(s.f_bavail * (s.f_frsize / 1024.0));
- return SYSINFO_RET_OK;
+ struct statvfs s;
#else
- struct statfs s;
- long blocks_used;
- long blocks_percent_used;
- char mountPoint[MAX_STRING_LEN];
-
- assert(result);
+ struct statfs s;
+#endif
- memset(result, 0, sizeof(AGENT_RESULT));
+ assert(fs);
- if(num_param(param) > 1)
+#ifdef HAVE_SYS_STATVFS_H
+ if ( statvfs( fs, &s) != 0 )
+#else
+ if ( statfs( fs, &s) != 0 )
+#endif
{
- return SYSINFO_RET_FAIL;
+ return SYSINFO_RET_FAIL;
}
- if(get_param(param, 1, mountPoint, MAX_STRING_LEN) != 0)
- {
- return SYSINFO_RET_FAIL;
- }
-
- if ( statfs( (char *)mountPoint, &s) != 0 )
- {
- return SYSINFO_RET_FAIL;
- }
-
- if ( s.f_blocks > 0 ) {
- blocks_used = s.f_blocks - s.f_bfree;
- blocks_percent_used = (long)
- (blocks_used * 100.0 / (blocks_used + s.f_bavail) + 0.5);
-
-/* printf(
- "%7.0f %7.0f %7.0f %5ld%% %s\n"
- ,s.f_blocks * (s.f_bsize / 1024.0)
- ,(s.f_blocks - s.f_bfree) * (s.f_bsize / 1024.0)
- ,s.f_bavail * (s.f_bsize / 1024.0)
- ,blocks_percent_used
- ,mountPoint);
-*/
- result->type |= AR_DOUBLE;
- result->dbl = (double)(s.f_bavail * (s.f_bsize / 1024.0));
- return SYSINFO_RET_OK;
-
- }
-
- return SYSINFO_RET_FAIL;
+#ifdef HAVE_SYS_STATVFS_H
+ if(total)
+ (*total) = (double)(s.f_blocks * (s.f_frsize / 1024.0));
+ if(free)
+ (*free) = (double)(s.f_bavail * (s.f_frsize / 1024.0));
+ if(usage)
+ (*usage) = (double)((s.f_blocks - s.f_bavail) * (s.f_frsize / 1024.0));
+#else
+ if(total)
+ (*total) = (double)(s.f_blocks * (s.f_bsize / 1024.0));
+ if(free)
+ (*free) = (double)(s.f_bfree * (s.f_bsize / 1024.0));
+ if(usage)
+ (*usage) = (double)((s.f_blocks - s.f_bfree) * (s.f_bsize / 1024.0));
#endif
+ return SYSINFO_RET_OK;
}
int VFS_FS_USED(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
-#ifdef HAVE_SYS_STATVFS_H
- struct statvfs s;
- char mountPoint[MAX_STRING_LEN];
-
- assert(result);
+ char mountPoint[MAX_STRING_LEN];
+ double value = 0;
- memset(result, 0, sizeof(AGENT_RESULT));
+ assert(result);
+
+ clean_result(result);
if(num_param(param) > 1)
- {
return SYSINFO_RET_FAIL;
- }
if(get_param(param, 1, mountPoint, MAX_STRING_LEN) != 0)
- {
return SYSINFO_RET_FAIL;
- }
- if ( statvfs( (char *)mountPoint, &s) != 0 )
- {
- return SYSINFO_RET_FAIL;
- }
+ if(get_fs_size_stat(mountPoint, NULL, NULL, &value) != SYSINFO_RET_OK)
+ return SYSINFO_RET_FAIL;
- result->type |= AR_DOUBLE;
- result->dbl = (double)((s.f_blocks-s.f_bavail) * (s.f_frsize / 1024.0));
- return SYSINFO_RET_OK;
-#else
- struct statfs s;
- long blocks_used;
- long blocks_percent_used;
- char mountPoint[MAX_STRING_LEN];
-
- assert(result);
+ result->type |= AR_DOUBLE;
+ result->dbl = value;
+
+ return SYSINFO_RET_OK;
+}
+
+int VFS_FS_FREE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ char mountPoint[MAX_STRING_LEN];
+ double value = 0;
- memset(result, 0, sizeof(AGENT_RESULT));
+ assert(result);
+
+ clean_result(result);
if(num_param(param) > 1)
- {
return SYSINFO_RET_FAIL;
- }
if(get_param(param, 1, mountPoint, MAX_STRING_LEN) != 0)
- {
return SYSINFO_RET_FAIL;
- }
- if ( statfs( (char *)mountPoint, &s) != 0 )
- {
- return SYSINFO_RET_FAIL;
- }
-
- if ( s.f_blocks > 0 ) {
- blocks_used = s.f_blocks - s.f_bfree;
- blocks_percent_used = (long)
- (blocks_used * 100.0 / (blocks_used + s.f_bavail) + 0.5);
-
-/* printf(
- "%7.0f %7.0f %7.0f %5ld%% %s\n"
- ,s.f_blocks * (s.f_bsize / 1024.0)
- ,(s.f_blocks - s.f_bfree) * (s.f_bsize / 1024.0)
- ,s.f_bavail * (s.f_bsize / 1024.0)
- ,blocks_percent_used
- ,mountPoint);
-*/
- result->type |= AR_DOUBLE;
- result->dbl = (double)(blocks_used * (s.f_bsize / 1024.0));
- return SYSINFO_RET_OK;
+ if(get_fs_size_stat(mountPoint, NULL, &value, NULL) != SYSINFO_RET_OK)
+ return SYSINFO_RET_FAIL;
- }
+ result->type |= AR_DOUBLE;
+ result->dbl = value;
- return SYSINFO_RET_FAIL;
-#endif
+ return SYSINFO_RET_OK;
}
int VFS_FS_TOTAL(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
-#ifdef HAVE_SYS_STATVFS_H
- struct statvfs s;
- char mountPoint[MAX_STRING_LEN];
-
- assert(result);
+ char mountPoint[MAX_STRING_LEN];
+ double value = 0;
- memset(result, 0, sizeof(AGENT_RESULT));
+ assert(result);
+
+ clean_result(result);
if(num_param(param) > 1)
- {
return SYSINFO_RET_FAIL;
- }
if(get_param(param, 1, mountPoint, MAX_STRING_LEN) != 0)
{
return SYSINFO_RET_FAIL;
- }
-
- if ( statvfs( (char *)mountPoint, &s) != 0 )
- {
- return SYSINFO_RET_FAIL;
- }
-
-/* return s.f_blocks * (s.f_bsize / 1024.0);*/
- result->type |= AR_DOUBLE;
- result->dbl = (double)(s.f_blocks * (s.f_frsize / 1024.0));
- return SYSINFO_RET_OK;
-#else
- struct statfs s;
- long blocks_used;
- long blocks_percent_used;
- char mountPoint[MAX_STRING_LEN];
-
- assert(result);
-
- memset(result, 0, sizeof(AGENT_RESULT));
-
- if(num_param(param) > 1)
- {
- return SYSINFO_RET_FAIL;
}
- if(get_param(param, 1, mountPoint, MAX_STRING_LEN) != 0)
- {
- return SYSINFO_RET_FAIL;
- }
+ if(get_fs_size_stat(mountPoint, &value, NULL, NULL) != SYSINFO_RET_OK)
+ return SYSINFO_RET_FAIL;
- if ( statfs( (char *)mountPoint, &s) != 0 )
- {
- return SYSINFO_RET_FAIL;
- }
-
- if ( s.f_blocks > 0 ) {
- blocks_used = s.f_blocks - s.f_bfree;
- blocks_percent_used = (long)
- (blocks_used * 100.0 / (blocks_used + s.f_bavail) + 0.5);
-
-/* printf(
- "%7.0f %7.0f %7.0f %5ld%% %s\n"
- ,s.f_blocks * (s.f_bsize / 1024.0)
- ,(s.f_blocks - s.f_bfree) * (s.f_bsize / 1024.0)
- ,s.f_bavail * (s.f_bsize / 1024.0)
- ,blocks_percent_used
- ,mountPoint);
-*/
- result->type |= AR_DOUBLE;
- result->dbl = (double)(s.f_blocks * (s.f_bsize / 1024.0));
- return SYSINFO_RET_OK;
+ result->type |= AR_DOUBLE;
+ result->dbl = value;
- }
+ return SYSINFO_RET_OK;
- return SYSINFO_RET_FAIL;
-#endif
}
-int VFS_FS_PUSED(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+int VFS_FS_PFREE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
- AGENT_RESULT total_result;
- AGENT_RESULT used_result;
- char mountPoint[MAX_STRING_LEN];
-
- assert(result);
+ char mountPoint[MAX_STRING_LEN];
+ double tot_val = 0;
+ double free_val = 0;
+
+ assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
if(num_param(param) > 1)
- {
return SYSINFO_RET_FAIL;
- }
if(get_param(param, 1, mountPoint, MAX_STRING_LEN) != 0)
- {
return SYSINFO_RET_FAIL;
- }
-
- if(SYSINFO_RET_OK != VFS_FS_TOTAL(cmd, mountPoint, flags, &total_result))
- {
- memcpy(result, &total_result, sizeof(AGENT_RESULT));
- return SYSINFO_RET_FAIL;
- }
- if(SYSINFO_RET_OK != VFS_FS_USED(cmd, mountPoint, flags, &used_result))
- {
- memcpy(result, &used_result, sizeof(AGENT_RESULT));
- return SYSINFO_RET_FAIL;
- }
+ if(get_fs_size_stat(mountPoint, &tot_val, &free_val, NULL) != SYSINFO_RET_OK)
+ return SYSINFO_RET_FAIL;
- if(total_result.dbl == 0)
- {
- return SYSINFO_RET_FAIL;
- }
+ result->type |= AR_DOUBLE;
+ result->dbl = (100.0 * free_val) / tot_val;
- result->type |= AR_DOUBLE;
- result->dbl = (double)(100.0 * used_result.dbl / total_result.dbl);
- return SYSINFO_RET_OK;
+ return SYSINFO_RET_OK;
}
-int VFS_FS_PFREE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+int VFS_FS_PUSED(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
- AGENT_RESULT total_result;
- AGENT_RESULT free_result;
- char mountPoint[MAX_STRING_LEN];
-
- assert(result);
+ char mountPoint[MAX_STRING_LEN];
+ double tot_val = 0;
+ double usg_val = 0;
+
+ assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
if(num_param(param) > 1)
- {
return SYSINFO_RET_FAIL;
- }
if(get_param(param, 1, mountPoint, MAX_STRING_LEN) != 0)
- {
return SYSINFO_RET_FAIL;
- }
- if(SYSINFO_RET_OK != VFS_FS_TOTAL(cmd, mountPoint, flags, &total_result))
- {
- memcpy(result, &total_result, sizeof(AGENT_RESULT));
- return SYSINFO_RET_FAIL;
- }
+ if(get_fs_size_stat(mountPoint, &tot_val, NULL, &usg_val) != SYSINFO_RET_OK)
+ return SYSINFO_RET_FAIL;
- if(SYSINFO_RET_OK != VFS_FS_FREE(cmd, mountPoint, flags, &free_result))
- {
- memcpy(result, &free_result, sizeof(AGENT_RESULT));
- return SYSINFO_RET_FAIL;
- }
-
- if(total_result.dbl == 0)
- {
- return SYSINFO_RET_FAIL;
- }
+ result->type |= AR_DOUBLE;
+ result->dbl = (100.0 * usg_val) / tot_val;
- result->type |= AR_DOUBLE;
- result->dbl = (double)(100.0 * free_result.dbl / total_result.dbl);
- return SYSINFO_RET_OK;
+ return SYSINFO_RET_OK;
}
diff --git a/src/libs/zbxsysinfo/linux/inodes.c b/src/libs/zbxsysinfo/linux/inodes.c
index 2def25a0..d6b124eb 100644
--- a/src/libs/zbxsysinfo/linux/inodes.c
+++ b/src/libs/zbxsysinfo/linux/inodes.c
@@ -50,7 +50,7 @@ FS_FNCLIST
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
if(num_param(param) > 2)
{
@@ -83,216 +83,162 @@ FS_FNCLIST
return SYSINFO_RET_FAIL;
}
-int VFS_FS_INODE_FREE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+int get_fs_inodes_stat(char *fs, double *total, double *free, double *usage)
{
- char mountPoint[MAX_STRING_LEN];
#ifdef HAVE_SYS_STATVFS_H
struct statvfs s;
#else
struct statfs s;
#endif
- assert(result);
-
- memset(result, 0, sizeof(AGENT_RESULT));
-
- if(num_param(param) > 1)
- {
- return SYSINFO_RET_FAIL;
- }
-
- if(get_param(param, 1, mountPoint, MAX_STRING_LEN) != 0)
- {
- return SYSINFO_RET_FAIL;
- }
-
+ assert(fs);
+
#ifdef HAVE_SYS_STATVFS_H
- if ( statvfs( (char *)mountPoint, &s) != 0 )
+ if ( statvfs( fs, &s) != 0 )
#else
- if ( statfs( (char *)mountPoint, &s) != 0 )
+ if ( statfs( fs, &s) != 0 )
#endif
{
return SYSINFO_RET_FAIL;
}
- if ( s.f_blocks > 0 ) {
- result->type |= AR_DOUBLE;
+ if(total)
+ (*total) = (double)(s.f_files);
#ifdef HAVE_SYS_STATVFS_H
- result->dbl = (double)(s.f_favail);
+ if(free)
+ (*free) = (double)(s.f_favail);
+ if(usage)
+ (*usage) = (double)(s.f_files - s.f_favail);
#else
- result->dbl = (double)(s.f_ffree);
+ if(free)
+ (*free) = (double)(s.ffree);
+ if(usage)
+ (*usage) = (double)(s.f_files - s.f_ffree);
#endif
- return SYSINFO_RET_OK;
- }
- return SYSINFO_RET_FAIL;
+ return SYSINFO_RET_OK;
}
int VFS_FS_INODE_USED(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
char mountPoint[MAX_STRING_LEN];
-#ifdef HAVE_SYS_STATVFS_H
- struct statvfs s;
-#else
- struct statfs s;
-#endif
+ double value = 0;
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
if(num_param(param) > 1)
- {
return SYSINFO_RET_FAIL;
- }
if(get_param(param, 1, mountPoint, MAX_STRING_LEN) != 0)
- {
return SYSINFO_RET_FAIL;
- }
-#ifdef HAVE_SYS_STATVFS_H
- if ( statvfs( (char *)mountPoint, &s) != 0 )
-#else
- if ( statfs( (char *)mountPoint, &s) != 0 )
-#endif
- {
- return SYSINFO_RET_FAIL;
- }
-
- if ( s.f_blocks > 0 ) {
- result->type |= AR_DOUBLE;
-#ifdef HAVE_SYS_STATVFS_H
- struct statvfs s;
- result->dbl = (double)(s.f_files - s.f_favail);
-#else
- result->dbl = (double)(s.f_files - s.f_ffree);
-#endif
- return SYSINFO_RET_OK;
- }
- return SYSINFO_RET_FAIL;
+ if(get_fs_inodes_stat(mountPoint, NULL, NULL, &value) != SYSINFO_RET_OK)
+ return SYSINFO_RET_FAIL;
+
+ result->type |= AR_DOUBLE;
+ result->dbl = value;
+
+ return SYSINFO_RET_OK;
}
-int VFS_FS_INODE_TOTAL(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+int VFS_FS_INODE_FREE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
char mountPoint[MAX_STRING_LEN];
-#ifdef HAVE_SYS_STATVFS_H
- struct statvfs s;
-#else
- struct statfs s;
-#endif
+ double value = 0;
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
if(num_param(param) > 1)
- {
return SYSINFO_RET_FAIL;
- }
if(get_param(param, 1, mountPoint, MAX_STRING_LEN) != 0)
- {
return SYSINFO_RET_FAIL;
- }
-#ifdef HAVE_SYS_STATVFS_H
- if ( statvfs( (char *)mountPoint, &s) != 0 )
-#else
- if ( statfs( (char *)mountPoint, &s) != 0 )
-#endif
- {
- return SYSINFO_RET_FAIL;
- }
-
- if ( s.f_blocks > 0 ) {
- result->type |= AR_DOUBLE;
- result->dbl = (double)(s.f_files);
- return SYSINFO_RET_OK;
- }
- return SYSINFO_RET_FAIL;
+ if(get_fs_inodes_stat(mountPoint, NULL, &value, NULL) != SYSINFO_RET_OK)
+ return SYSINFO_RET_FAIL;
+
+ result->type |= AR_DOUBLE;
+ result->dbl = value;
+
+ return SYSINFO_RET_OK;
}
-int VFS_FS_INODE_PFREE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+int VFS_FS_INODE_TOTAL(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
- AGENT_RESULT total_result;
- AGENT_RESULT free_result;
char mountPoint[MAX_STRING_LEN];
+ double value = 0;
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
if(num_param(param) > 1)
- {
return SYSINFO_RET_FAIL;
- }
if(get_param(param, 1, mountPoint, MAX_STRING_LEN) != 0)
{
return SYSINFO_RET_FAIL;
}
- if(SYSINFO_RET_OK != VFS_FS_INODE_TOTAL(cmd, mountPoint, flags, &total_result))
- {
- memcpy(result, &total_result, sizeof(AGENT_RESULT));
- return SYSINFO_RET_FAIL;
- }
+ if(get_fs_inodes_stat(mountPoint, &value, NULL, NULL) != SYSINFO_RET_OK)
+ return SYSINFO_RET_FAIL;
+
+ result->type |= AR_DOUBLE;
+ result->dbl = value;
+
+ return SYSINFO_RET_OK;
+}
- if(SYSINFO_RET_OK != VFS_FS_INODE_FREE(cmd, mountPoint, flags, &free_result))
- {
- memcpy(result, &free_result, sizeof(AGENT_RESULT));
- return SYSINFO_RET_FAIL;
- }
+int VFS_FS_INODE_PFREE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ char mountPoint[MAX_STRING_LEN];
+ double tot_val = 0;
+ double free_val = 0;
+
+ assert(result);
- if(total_result.dbl == 0)
- {
- return SYSINFO_RET_FAIL;
- }
+ clean_result(result);
+
+ if(num_param(param) > 1)
+ return SYSINFO_RET_FAIL;
+
+ if(get_param(param, 1, mountPoint, MAX_STRING_LEN) != 0)
+ return SYSINFO_RET_FAIL;
+
+ if(get_fs_inodes_stat(mountPoint, &tot_val, &free_val, NULL) != SYSINFO_RET_OK)
+ return SYSINFO_RET_FAIL;
result->type |= AR_DOUBLE;
- result->dbl = 100.0 * free_result.dbl / total_result.dbl;
+ result->dbl = (100.0 * free_val) / tot_val;
+
return SYSINFO_RET_OK;
}
int VFS_FS_INODE_PUSED(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
- AGENT_RESULT total_result;
- AGENT_RESULT used_result;
char mountPoint[MAX_STRING_LEN];
+ double tot_val = 0;
+ double usg_val = 0;
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
if(num_param(param) > 1)
- {
return SYSINFO_RET_FAIL;
- }
if(get_param(param, 1, mountPoint, MAX_STRING_LEN) != 0)
- {
return SYSINFO_RET_FAIL;
- }
-
- if(SYSINFO_RET_OK != VFS_FS_INODE_TOTAL(cmd, mountPoint, flags, &total_result))
- {
- memcpy(result, &total_result, sizeof(AGENT_RESULT));
- return SYSINFO_RET_FAIL;
- }
-
- if(SYSINFO_RET_OK != VFS_FS_INODE_USED(cmd, mountPoint, flags, &used_result))
- {
- memcpy(result, &used_result, sizeof(AGENT_RESULT));
- return SYSINFO_RET_FAIL;
- }
- if(total_result.dbl == 0)
- {
- return SYSINFO_RET_FAIL;
- }
+ if(get_fs_inodes_stat(mountPoint, &tot_val, NULL, &usg_val) != SYSINFO_RET_OK)
+ return SYSINFO_RET_FAIL;
result->type |= AR_DOUBLE;
- result->dbl = 100.0 * used_result.dbl / total_result.dbl;
+ result->dbl = (100.0 * usg_val) / tot_val;
+
return SYSINFO_RET_OK;
}
diff --git a/src/libs/zbxsysinfo/linux/memory.c b/src/libs/zbxsysinfo/linux/memory.c
index 92db6809..6bf06827 100644
--- a/src/libs/zbxsysinfo/linux/memory.c
+++ b/src/libs/zbxsysinfo/linux/memory.c
@@ -46,7 +46,7 @@ MEM_FNCLIST
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
if(num_param(param) > 1)
{
@@ -89,7 +89,7 @@ int VM_MEMORY_CACHED(const char *cmd, const char *param, unsigned flags, AGENT_R
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
f=fopen("/proc/meminfo","r");
if(NULL == f)
@@ -114,7 +114,7 @@ int VM_MEMORY_CACHED(const char *cmd, const char *param, unsigned flags, AGENT_R
#else
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
return SYSINFO_RET_FAIL;
#endif
@@ -127,7 +127,7 @@ int VM_MEMORY_BUFFERS(const char *cmd, const char *param, unsigned flags, AGENT_
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
if( 0 == sysinfo(&info))
{
@@ -146,7 +146,7 @@ int VM_MEMORY_BUFFERS(const char *cmd, const char *param, unsigned flags, AGENT_
#else
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
return SYSINFO_RET_FAIL;
#endif
@@ -159,7 +159,7 @@ int VM_MEMORY_SHARED(const char *cmd, const char *param, unsigned flags, AGENT_R
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
if( 0 == sysinfo(&info))
{
@@ -182,7 +182,7 @@ int VM_MEMORY_SHARED(const char *cmd, const char *param, unsigned flags, AGENT_R
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
len=sizeof(struct vmtotal);
mib[0]=CTL_VM;
@@ -205,7 +205,7 @@ int VM_MEMORY_TOTAL(const char *cmd, const char *param, unsigned flags, AGENT_RE
#ifdef HAVE_UNISTD_SYSCONF
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
result->type |= AR_DOUBLE;
result->dbl=(double)sysconf(_SC_PHYS_PAGES)*sysconf(_SC_PAGESIZE);
@@ -217,7 +217,7 @@ int VM_MEMORY_TOTAL(const char *cmd, const char *param, unsigned flags, AGENT_RE
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
if(pstat_getstatic(&pst, sizeof(pst), (size_t)1, 0) == -1)
{
@@ -238,7 +238,7 @@ int VM_MEMORY_TOTAL(const char *cmd, const char *param, unsigned flags, AGENT_RE
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
if( 0 == sysinfo(&info))
{
@@ -261,7 +261,7 @@ int VM_MEMORY_TOTAL(const char *cmd, const char *param, unsigned flags, AGENT_RE
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
len=sizeof(struct vmtotal);
mib[0]=CTL_VM;
@@ -281,7 +281,7 @@ int VM_MEMORY_TOTAL(const char *cmd, const char *param, unsigned flags, AGENT_RE
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
len=sizeof(memory);
@@ -299,7 +299,7 @@ int VM_MEMORY_TOTAL(const char *cmd, const char *param, unsigned flags, AGENT_RE
#else
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
return SYSINFO_RET_FAIL;
#endif
@@ -315,7 +315,7 @@ int VM_MEMORY_FREE(const char *cmd, const char *param, unsigned flags, AGENT_RES
#ifdef HAVE_UNISTD_SYSCONF
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
result->type |= AR_DOUBLE;
result->dbl=(double)sysconf(_SC_AVPHYS_PAGES)*sysconf(_SC_PAGESIZE);
@@ -328,7 +328,7 @@ int VM_MEMORY_FREE(const char *cmd, const char *param, unsigned flags, AGENT_RES
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
if(pstat_getstatic(&pst, sizeof(pst), (size_t)1, 0) == -1)
{
@@ -369,7 +369,7 @@ int VM_MEMORY_FREE(const char *cmd, const char *param, unsigned flags, AGENT_RES
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
if( 0 == sysinfo(&info))
{
@@ -392,7 +392,7 @@ int VM_MEMORY_FREE(const char *cmd, const char *param, unsigned flags, AGENT_RES
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
len=sizeof(struct vmtotal);
mib[0]=CTL_VM;
@@ -414,7 +414,7 @@ int VM_MEMORY_FREE(const char *cmd, const char *param, unsigned flags, AGENT_RES
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
pagesize = 0;
kret = host_page_size (mach_host_self(), &pagesize);
@@ -445,7 +445,7 @@ int VM_MEMORY_FREE(const char *cmd, const char *param, unsigned flags, AGENT_RES
#else
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
return SYSINFO_RET_FAIL;
#endif
diff --git a/src/libs/zbxsysinfo/linux/net.c b/src/libs/zbxsysinfo/linux/net.c
index accddb18..49867845 100644
--- a/src/libs/zbxsysinfo/linux/net.c
+++ b/src/libs/zbxsysinfo/linux/net.c
@@ -27,7 +27,7 @@ int NET_IF_IN(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
return SYSINFO_RET_FAIL;
}
@@ -37,7 +37,7 @@ int NET_IF_OUT(const char *cmd, const char *param, unsigned flags, AGENT_RESULT
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
return SYSINFO_RET_FAIL;
}
diff --git a/src/libs/zbxsysinfo/linux/proc.c b/src/libs/zbxsysinfo/linux/proc.c
index 57be6272..d80dac13 100644
--- a/src/libs/zbxsysinfo/linux/proc.c
+++ b/src/libs/zbxsysinfo/linux/proc.c
@@ -59,7 +59,7 @@ int PROC_MEMORY(const char *cmd, const char *param, unsigned flags, AGENT_RE
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
if(num_param(param) > 3)
{
@@ -312,7 +312,7 @@ int PROC_NUM(const char *cmd, const char *param, unsigned flags, AGENT_RESUL
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
int proccount = 0;
diff --git a/src/libs/zbxsysinfo/linux/sensors.c b/src/libs/zbxsysinfo/linux/sensors.c
index 234efefa..8620f12d 100644
--- a/src/libs/zbxsysinfo/linux/sensors.c
+++ b/src/libs/zbxsysinfo/linux/sensors.c
@@ -37,7 +37,7 @@ int SENSOR_TEMP1(const char *cmd, const char *param, unsigned flags, AGENT_RESUL
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
dir=opendir("/proc/sys/dev/sensors");
if(NULL == dir)
@@ -92,7 +92,7 @@ int SENSOR_TEMP2(const char *cmd, const char *param, unsigned flags, AGENT_RESUL
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
dir=opendir("/proc/sys/dev/sensors");
if(NULL == dir)
@@ -147,7 +147,7 @@ int SENSOR_TEMP3(const char *cmd, const char *param, unsigned flags, AGENT_RESUL
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
dir=opendir("/proc/sys/dev/sensors");
if(NULL == dir)
@@ -196,7 +196,7 @@ int OLD_SENSOR(const char *cmd, const char *param, unsigned flags, AGENT_RES
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
if(num_param(param) > 1)
{
diff --git a/src/libs/zbxsysinfo/linux/swap.c b/src/libs/zbxsysinfo/linux/swap.c
index c86a2e46..f24cc3f0 100644
--- a/src/libs/zbxsysinfo/linux/swap.c
+++ b/src/libs/zbxsysinfo/linux/swap.c
@@ -48,7 +48,7 @@ SWP_FNCLIST
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
if(num_param(param) > 2)
{
@@ -100,7 +100,7 @@ int OLD_SWAP(const char *cmd, const char *param, unsigned flags, AGENT_RESUL
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
if(num_param(param) > 1)
{
@@ -201,7 +201,7 @@ int SYSTEM_SWAP_FREE(const char *cmd, const char *param, unsigned flags, AGENT_R
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
if( 0 == sysinfo(&info))
{
@@ -224,7 +224,7 @@ int SYSTEM_SWAP_FREE(const char *cmd, const char *param, unsigned flags, AGENT_R
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
get_swapinfo(&swaptotal,&swapfree);
@@ -234,7 +234,7 @@ int SYSTEM_SWAP_FREE(const char *cmd, const char *param, unsigned flags, AGENT_R
#else
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
return SYSINFO_RET_FAIL;
#endif
@@ -248,7 +248,7 @@ int SYSTEM_SWAP_TOTAL(const char *cmd, const char *param, unsigned flags, AGENT_
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
if( 0 == sysinfo(&info))
{
@@ -271,7 +271,7 @@ int SYSTEM_SWAP_TOTAL(const char *cmd, const char *param, unsigned flags, AGENT_
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
get_swapinfo(&swaptotal,&swapfree);
@@ -281,7 +281,7 @@ int SYSTEM_SWAP_TOTAL(const char *cmd, const char *param, unsigned flags, AGENT_
#else
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
return SYSINFO_RET_FAIL;
#endif
diff --git a/src/libs/zbxsysinfo/linux/uptime.c b/src/libs/zbxsysinfo/linux/uptime.c
index 52a38653..a38b2bd7 100644
--- a/src/libs/zbxsysinfo/linux/uptime.c
+++ b/src/libs/zbxsysinfo/linux/uptime.c
@@ -29,7 +29,7 @@ int SYSTEM_UPTIME(const char *cmd, const char *param, unsigned flags, AGENT_RESU
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
if( 0 == sysinfo(&info))
{
@@ -49,7 +49,7 @@ int SYSTEM_UPTIME(const char *cmd, const char *param, unsigned flags, AGENT_RESU
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
mib[0]=CTL_KERN;
mib[1]=KERN_BOOTTIME;
@@ -78,7 +78,7 @@ int SYSTEM_UPTIME(const char *cmd, const char *param, unsigned flags, AGENT_RESU
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
hz = sysconf(_SC_CLK_TCK);
@@ -113,7 +113,7 @@ int SYSTEM_UPTIME(const char *cmd, const char *param, unsigned flags, AGENT_RESU
#else
assert(result);
- memset(result, 0, sizeof(AGENT_RESULT));
+ clean_result(result);
return SYSINFO_RET_FAIL;
#endif