diff options
| author | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2005-12-05 12:19:03 +0000 |
|---|---|---|
| committer | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2005-12-05 12:19:03 +0000 |
| commit | cfc9c55a936e4340ededa05de22c7918ee5777a9 (patch) | |
| tree | 813048c02cf6b0ddc86c5d903652aa90bf8a11f2 /src/libs/zbxsysinfo/common/file.c | |
| parent | bf285e4a15e9ea845eaf66c3cb9f389057c7ccee (diff) | |
| download | zabbix-cfc9c55a936e4340ededa05de22c7918ee5777a9.tar.gz zabbix-cfc9c55a936e4340ededa05de22c7918ee5777a9.tar.xz zabbix-cfc9c55a936e4340ededa05de22c7918ee5777a9.zip | |
- improved support vfs.file.time[filename,<access|modify|change>] (Eugene)
git-svn-id: svn://svn.zabbix.com/trunk@2395 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src/libs/zbxsysinfo/common/file.c')
| -rw-r--r-- | src/libs/zbxsysinfo/common/file.c | 77 |
1 files changed, 24 insertions, 53 deletions
diff --git a/src/libs/zbxsysinfo/common/file.c b/src/libs/zbxsysinfo/common/file.c index 2f05ebe9..2073b77d 100644 --- a/src/libs/zbxsysinfo/common/file.c +++ b/src/libs/zbxsysinfo/common/file.c @@ -50,16 +50,18 @@ int VFS_FILE_SIZE(const char *cmd, const char *param, unsigned flags, AGENT_RESU return SYSINFO_RET_FAIL; } -int VFS_FILE_ATIME(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) +int VFS_FILE_TIME(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) { struct stat buf; char filename[MAX_STRING_LEN]; + char type[MAX_STRING_LEN]; + int ret = SYSINFO_RET_FAIL; assert(result); init_result(result); - if(num_param(param) > 1) + if(num_param(param) > 2) { return SYSINFO_RET_FAIL; } @@ -69,66 +71,35 @@ int VFS_FILE_ATIME(const char *cmd, const char *param, unsigned flags, AGENT_RES return SYSINFO_RET_FAIL; } - if(stat(filename,&buf) == 0) - { - SET_UI64_RESULT(result, buf.st_atime); - return SYSINFO_RET_OK; - } - return SYSINFO_RET_FAIL; -} - -int VFS_FILE_CTIME(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) -{ - struct stat buf; - char filename[MAX_STRING_LEN]; - - assert(result); - - init_result(result); - - if(num_param(param) > 1) + if(get_param(param, 2, type, MAX_STRING_LEN) != 0) { - return SYSINFO_RET_FAIL; + type[0] = '\0'; } - if(get_param(param, 1, filename, MAX_STRING_LEN) != 0) - { - return SYSINFO_RET_FAIL; - } - - if(stat(filename,&buf) == 0) + if(type[0] == '\0') { - SET_UI64_RESULT(result, buf.st_ctime); - return SYSINFO_RET_OK; + strscpy(type, "modify"); } - return SYSINFO_RET_FAIL; -} - -int VFS_FILE_MTIME(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) -{ - struct stat buf; - char filename[MAX_STRING_LEN]; - - assert(result); - - init_result(result); - - if(num_param(param) > 1) - { - return SYSINFO_RET_FAIL; - } - - if(get_param(param, 1, filename, MAX_STRING_LEN) != 0) - { - return SYSINFO_RET_FAIL; - } if(stat(filename,&buf) == 0) { - SET_UI64_RESULT(result, buf.st_mtime); - return SYSINFO_RET_OK; + if(strcmp(type,"modify") == 0) + { + SET_UI64_RESULT(result, buf.st_mtime); + ret = SYSINFO_RET_OK; + } + else if(strcmp(type,"access") == 0) + { + SET_UI64_RESULT(result, buf.st_atime); + ret = SYSINFO_RET_OK; + } + else if(strcmp(type,"change") == 0) + { + SET_UI64_RESULT(result, buf.st_ctime); + ret = SYSINFO_RET_OK; + } } - return SYSINFO_RET_FAIL; + return ret; } int VFS_FILE_EXISTS(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) |
