diff options
Diffstat (limited to 'src/libs/zbxsysinfo/linux/inodes.c')
-rw-r--r-- | src/libs/zbxsysinfo/linux/inodes.c | 130 |
1 files changed, 65 insertions, 65 deletions
diff --git a/src/libs/zbxsysinfo/linux/inodes.c b/src/libs/zbxsysinfo/linux/inodes.c index d6b124eb..c8109f28 100644 --- a/src/libs/zbxsysinfo/linux/inodes.c +++ b/src/libs/zbxsysinfo/linux/inodes.c @@ -24,66 +24,7 @@ #include "md5.h" -int VFS_FS_INODE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) -{ - -#define FS_FNCLIST struct fs_fnclist_s -FS_FNCLIST -{ - char *mode; - int (*function)(); -}; - - FS_FNCLIST fl[] = - { - {"free" , VFS_FS_INODE_FREE}, - {"total" , VFS_FS_INODE_TOTAL}, - {"used", VFS_FS_INODE_USED}, - {"pfree" , VFS_FS_INODE_PFREE}, - {"pused" , VFS_FS_INODE_PUSED}, - {0, 0} - }; - - char fsname[MAX_STRING_LEN]; - char mode[MAX_STRING_LEN]; - int i; - - assert(result); - - clean_result(result); - - if(num_param(param) > 2) - { - return SYSINFO_RET_FAIL; - } - - if(get_param(param, 1, fsname, MAX_STRING_LEN) != 0) - { - return SYSINFO_RET_FAIL; - } - - if(get_param(param, 2, mode, MAX_STRING_LEN) != 0) - { - mode[0] = '\0'; - } - if(mode[0] == '\0') - { - /* default parameter */ - sprintf(mode, "total"); - } - - for(i=0; fl[i].mode!=0; i++) - { - if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0) - { - return (fl[i].function)(cmd, fsname, flags, result); - } - } - - return SYSINFO_RET_FAIL; -} - -int get_fs_inodes_stat(char *fs, double *total, double *free, double *usage) +static int get_fs_inodes_stat(char *fs, double *total, double *free, double *usage) { #ifdef HAVE_SYS_STATVFS_H struct statvfs s; @@ -118,7 +59,7 @@ int get_fs_inodes_stat(char *fs, double *total, double *free, double *usage) return SYSINFO_RET_OK; } -int VFS_FS_INODE_USED(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) +static int VFS_FS_INODE_USED(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) { char mountPoint[MAX_STRING_LEN]; double value = 0; @@ -142,7 +83,7 @@ int VFS_FS_INODE_USED(const char *cmd, const char *param, unsigned flags, AGENT_ return SYSINFO_RET_OK; } -int VFS_FS_INODE_FREE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) +static int VFS_FS_INODE_FREE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) { char mountPoint[MAX_STRING_LEN]; double value = 0; @@ -166,7 +107,7 @@ int VFS_FS_INODE_FREE(const char *cmd, const char *param, unsigned flags, AGENT_ return SYSINFO_RET_OK; } -int VFS_FS_INODE_TOTAL(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) +static int VFS_FS_INODE_TOTAL(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) { char mountPoint[MAX_STRING_LEN]; double value = 0; @@ -192,7 +133,7 @@ int VFS_FS_INODE_TOTAL(const char *cmd, const char *param, unsigned flags, AGENT return SYSINFO_RET_OK; } -int VFS_FS_INODE_PFREE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) +static 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; @@ -217,7 +158,7 @@ int VFS_FS_INODE_PFREE(const char *cmd, const char *param, unsigned flags, AGENT return SYSINFO_RET_OK; } -int VFS_FS_INODE_PUSED(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) +static int VFS_FS_INODE_PUSED(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) { char mountPoint[MAX_STRING_LEN]; double tot_val = 0; @@ -242,3 +183,62 @@ int VFS_FS_INODE_PUSED(const char *cmd, const char *param, unsigned flags, AGENT return SYSINFO_RET_OK; } +int VFS_FS_INODE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) +{ + +#define FS_FNCLIST struct fs_fnclist_s +FS_FNCLIST +{ + char *mode; + int (*function)(); +}; + + FS_FNCLIST fl[] = + { + {"free" , VFS_FS_INODE_FREE}, + {"total" , VFS_FS_INODE_TOTAL}, + {"used", VFS_FS_INODE_USED}, + {"pfree" , VFS_FS_INODE_PFREE}, + {"pused" , VFS_FS_INODE_PUSED}, + {0, 0} + }; + + char fsname[MAX_STRING_LEN]; + char mode[MAX_STRING_LEN]; + int i; + + assert(result); + + clean_result(result); + + if(num_param(param) > 2) + { + return SYSINFO_RET_FAIL; + } + + if(get_param(param, 1, fsname, MAX_STRING_LEN) != 0) + { + return SYSINFO_RET_FAIL; + } + + if(get_param(param, 2, mode, MAX_STRING_LEN) != 0) + { + mode[0] = '\0'; + } + if(mode[0] == '\0') + { + /* default parameter */ + sprintf(mode, "total"); + } + + for(i=0; fl[i].mode!=0; i++) + { + if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0) + { + return (fl[i].function)(cmd, fsname, flags, result); + } + } + + return SYSINFO_RET_FAIL; +} + |