diff options
| author | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-03-12 15:24:16 +0000 |
|---|---|---|
| committer | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-03-12 15:24:16 +0000 |
| commit | 883163bc42892ffe0885e94b701ef9da4da3cf70 (patch) | |
| tree | d9b8592102201e0396de3807a223d5b87c72f1bd /src/libs/zbxsysinfo/linux/boottime.c | |
| parent | e929cc4053168b46b81475715e98230eed01badc (diff) | |
| download | zabbix-883163bc42892ffe0885e94b701ef9da4da3cf70.tar.gz zabbix-883163bc42892ffe0885e94b701ef9da4da3cf70.tar.xz zabbix-883163bc42892ffe0885e94b701ef9da4da3cf70.zip | |
- fixed system.cpu.util[] (Eugene)
- improved configuration script (Eugene)
- fixed floats values (Eugene)
- developed agent result convertion (Eugene)
- more fixes
- TODO: WinXX agent \!\!\!
git-svn-id: svn://svn.zabbix.com/trunk@3886 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src/libs/zbxsysinfo/linux/boottime.c')
| -rw-r--r-- | src/libs/zbxsysinfo/linux/boottime.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/libs/zbxsysinfo/linux/boottime.c b/src/libs/zbxsysinfo/linux/boottime.c index 1f7cee0e..1fff9ddb 100644 --- a/src/libs/zbxsysinfo/linux/boottime.c +++ b/src/libs/zbxsysinfo/linux/boottime.c @@ -22,6 +22,68 @@ #include "common.h" #include "sysinfo.h" +static int getPROC2(char *file, char *param, int fieldno, unsigned flags, int type, AGENT_RESULT *result) +{ + + FILE *f; + char *res; + char buf[MAX_STRING_LEN]; + int i; + int found; + unsigned long uValue; + double fValue; + + if (NULL == (f = fopen(file,"r"))) + { + return SYSINFO_RET_FAIL; + } + + /* find line */ + found = 0; + while ( fgets(buf, MAX_STRING_LEN, f) != NULL ) + { + if (strncmp(buf, "btime", 5) == 0) + { + found = 1; + break; + } + } + + if (!found) return SYSINFO_RET_FAIL; + + /* find field */ + res = (char *)strtok(buf, " "); /* btime field1 field2 */ + for(i=1; i<=fieldno; i++) + { + res = (char *)strtok(NULL," "); + } + + zbx_fclose(f); + + if ( res == NULL ) + { + return SYSINFO_RET_FAIL; + } + + /* convert field to right type */ + switch (type) + { + case AR_UINT64: + sscanf(res, "%lu", &uValue); + SET_UI64_RESULT(result, uValue); + break; + case AR_DOUBLE: + sscanf(res, "%lf", &fValue); + SET_DBL_RESULT(result, fValue); + break; + case AR_STRING: default: + SET_STR_RESULT(result, buf); + break; + } + + return SYSINFO_RET_OK; +} + int SYSTEM_BOOTTIME(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) { assert(result); |
