diff options
| author | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2005-11-25 15:56:33 +0000 |
|---|---|---|
| committer | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2005-11-25 15:56:33 +0000 |
| commit | f34eb9596b1831eff096a3518097a1edb18ccff0 (patch) | |
| tree | fb58f192c886cced768c88deb20247f410d63c09 /src/libs/zbxsysinfo/openbsd | |
| parent | 5e31f8a01e418799fb7840db0abfd36c8b5281f8 (diff) | |
| download | zabbix-f34eb9596b1831eff096a3518097a1edb18ccff0.tar.gz zabbix-f34eb9596b1831eff096a3518097a1edb18ccff0.tar.xz zabbix-f34eb9596b1831eff096a3518097a1edb18ccff0.zip | |
- added "SET_<TYPE>_RESULT" macross (Eugene)
git-svn-id: svn://svn.zabbix.com/trunk@2369 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src/libs/zbxsysinfo/openbsd')
| -rw-r--r-- | src/libs/zbxsysinfo/openbsd/cpu.c | 12 | ||||
| -rw-r--r-- | src/libs/zbxsysinfo/openbsd/diskio.c | 12 | ||||
| -rw-r--r-- | src/libs/zbxsysinfo/openbsd/diskspace.c | 15 | ||||
| -rw-r--r-- | src/libs/zbxsysinfo/openbsd/inodes.c | 16 | ||||
| -rw-r--r-- | src/libs/zbxsysinfo/openbsd/kernel.c | 6 | ||||
| -rw-r--r-- | src/libs/zbxsysinfo/openbsd/memory.c | 6 | ||||
| -rw-r--r-- | src/libs/zbxsysinfo/openbsd/net.c | 21 | ||||
| -rw-r--r-- | src/libs/zbxsysinfo/openbsd/proc.c | 12 | ||||
| -rw-r--r-- | src/libs/zbxsysinfo/openbsd/sensors.c | 123 | ||||
| -rw-r--r-- | src/libs/zbxsysinfo/openbsd/swap.c | 12 | ||||
| -rw-r--r-- | src/libs/zbxsysinfo/openbsd/uptime.c | 3 |
11 files changed, 46 insertions, 192 deletions
diff --git a/src/libs/zbxsysinfo/openbsd/cpu.c b/src/libs/zbxsysinfo/openbsd/cpu.c index 55150ee6..998d998c 100644 --- a/src/libs/zbxsysinfo/openbsd/cpu.c +++ b/src/libs/zbxsysinfo/openbsd/cpu.c @@ -143,8 +143,7 @@ CPU_PARAMLIST if (interval_size > 0) { - result->type |= AR_DOUBLE; - result->dbl = (cpu_val[pl[i].id] * 100.0)/interval_size; + SET_DBL_RESULT(result, ((double)cpu_val[pl[i].id] * 100.0)/(double)interval_size); ret = SYSINFO_RET_OK; } @@ -167,8 +166,7 @@ int SYSTEM_CPU_LOAD1(const char *cmd, const char *param, unsigned flags, AGENT_R if(getloadavg(load, 3)) { - result->type |= AR_DOUBLE; - result->dbl = load[0]; + SET_DBL_RESULT(result, load[0]); ret = SYSINFO_RET_OK; } @@ -186,8 +184,7 @@ int SYSTEM_CPU_LOAD5(const char *cmd, const char *param, unsigned flags, AGENT_R if(getloadavg(load, 3)) { - result->type |= AR_DOUBLE; - result->dbl = load[1]; + SET_DBL_RESULT(result, load[1]); ret = SYSINFO_RET_OK; } @@ -205,8 +202,7 @@ int SYSTEM_CPU_LOAD15(const char *cmd, const char *param, unsigned flags, AGENT_ if(getloadavg(load, 3)) { - result->type |= AR_DOUBLE; - result->dbl = load[2]; + SET_DBL_RESULT(result, load[2]); ret = SYSINFO_RET_OK; } diff --git a/src/libs/zbxsysinfo/openbsd/diskio.c b/src/libs/zbxsysinfo/openbsd/diskio.c index 0135e100..41bc7bbc 100644 --- a/src/libs/zbxsysinfo/openbsd/diskio.c +++ b/src/libs/zbxsysinfo/openbsd/diskio.c @@ -88,8 +88,7 @@ static int VFS_DEV_READ_BYTES(const char *cmd, const char *param, unsigned flags if(get_disk_stats(devname, &ds) == SYSINFO_RET_OK) { - result->type |= AR_DOUBLE; - result->dbl = ds.ds_rbytes; + SET_UI64_RESULT(result, ds.ds_rbytes); ret = SYSINFO_RET_OK; } */ @@ -118,8 +117,7 @@ static int VFS_DEV_READ_OPERATIONS(const char *cmd, const char *param, unsigned if(get_disk_stats(devname, &ds) == SYSINFO_RET_OK) { - result->type |= AR_DOUBLE; - result->dbl = ds.ds_rxfer; + SET_UI64_RESULT(result, ds.ds_rxfer); ret = SYSINFO_RET_OK; } */ @@ -148,8 +146,7 @@ static int VFS_DEV_WRITE_BYTES(const char *cmd, const char *param, unsigned flag if(get_disk_stats(devname, &ds) == SYSINFO_RET_OK) { - result->type |= AR_DOUBLE; - result->dbl = ds.ds_wbytes; + SET_UI64_RESULT(result, ds.ds_wbytes); ret = SYSINFO_RET_OK; } */ @@ -178,8 +175,7 @@ static int VFS_DEV_WRITE_OPERATIONS(const char *cmd, const char *param, unsigned if(get_disk_stats(devname, &ds) == SYSINFO_RET_OK) { - result->type |= AR_DOUBLE; - result->dbl = ds.ds_wxfer; + SET_UI64_RESULT(result, ds.ds_wxfer); ret = SYSINFO_RET_OK; } */ diff --git a/src/libs/zbxsysinfo/openbsd/diskspace.c b/src/libs/zbxsysinfo/openbsd/diskspace.c index 81fd7e8e..fd89f469 100644 --- a/src/libs/zbxsysinfo/openbsd/diskspace.c +++ b/src/libs/zbxsysinfo/openbsd/diskspace.c @@ -77,8 +77,7 @@ static int VFS_FS_USED(const char *cmd, const char *param, unsigned flags, AGENT if(get_fs_size_stat(mountPoint, NULL, NULL, &value) != SYSINFO_RET_OK) return SYSINFO_RET_FAIL; - result->type |= AR_DOUBLE; - result->dbl = value; + SET_UI64_RESULT(result, value); return SYSINFO_RET_OK; } @@ -101,8 +100,7 @@ static int VFS_FS_FREE(const char *cmd, const char *param, unsigned flags, AGENT if(get_fs_size_stat(mountPoint, NULL, &value, NULL) != SYSINFO_RET_OK) return SYSINFO_RET_FAIL; - result->type |= AR_DOUBLE; - result->dbl = value; + SET_UI64_RESULT(result, value); return SYSINFO_RET_OK; } @@ -127,8 +125,7 @@ static int VFS_FS_TOTAL(const char *cmd, const char *param, unsigned flags, AGEN if(get_fs_size_stat(mountPoint, &value, NULL, NULL) != SYSINFO_RET_OK) return SYSINFO_RET_FAIL; - result->type |= AR_DOUBLE; - result->dbl = value; + SET_UI64_RESULT(result, value); return SYSINFO_RET_OK; @@ -153,8 +150,7 @@ static int VFS_FS_PFREE(const char *cmd, const char *param, unsigned flags, AGEN if(get_fs_size_stat(mountPoint, &tot_val, &free_val, NULL) != SYSINFO_RET_OK) return SYSINFO_RET_FAIL; - result->type |= AR_DOUBLE; - result->dbl = (100.0 * free_val) / tot_val; + SET_DBL_RESULT(result, (100.0 * free_val) / tot_val); return SYSINFO_RET_OK; } @@ -178,8 +174,7 @@ static int VFS_FS_PUSED(const char *cmd, const char *param, unsigned flags, AGEN if(get_fs_size_stat(mountPoint, &tot_val, NULL, &usg_val) != SYSINFO_RET_OK) return SYSINFO_RET_FAIL; - result->type |= AR_DOUBLE; - result->dbl = (100.0 * usg_val) / tot_val; + SET_DBL_RESULT(result, (100.0 * usg_val) / tot_val); return SYSINFO_RET_OK; } diff --git a/src/libs/zbxsysinfo/openbsd/inodes.c b/src/libs/zbxsysinfo/openbsd/inodes.c index 16966cde..a27e8644 100644 --- a/src/libs/zbxsysinfo/openbsd/inodes.c +++ b/src/libs/zbxsysinfo/openbsd/inodes.c @@ -63,8 +63,7 @@ static int VFS_FS_INODE_USED(const char *cmd, const char *param, unsigned flags, if(get_fs_inodes_stat(mountPoint, NULL, NULL, &value) != SYSINFO_RET_OK) return SYSINFO_RET_FAIL; - result->type |= AR_DOUBLE; - result->dbl = value; + SET_UI64_RESULT(result, value); return SYSINFO_RET_OK; } @@ -87,8 +86,7 @@ static int VFS_FS_INODE_FREE(const char *cmd, const char *param, unsigned flags, if(get_fs_inodes_stat(mountPoint, NULL, &value, NULL) != SYSINFO_RET_OK) return SYSINFO_RET_FAIL; - result->type |= AR_DOUBLE; - result->dbl = value; + SET_UI64_RESULT(result, value); return SYSINFO_RET_OK; } @@ -113,8 +111,7 @@ static int VFS_FS_INODE_TOTAL(const char *cmd, const char *param, unsigned flags if(get_fs_inodes_stat(mountPoint, &value, NULL, NULL) != SYSINFO_RET_OK) return SYSINFO_RET_FAIL; - result->type |= AR_DOUBLE; - result->dbl = value; + SET_UI64_RESULT(result, value); return SYSINFO_RET_OK; } @@ -138,8 +135,7 @@ static int VFS_FS_INODE_PFREE(const char *cmd, const char *param, unsigned flags 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_val) / tot_val; + SET_DBL_RESULT(result, (100.0 * free_val) / tot_val); return SYSINFO_RET_OK; } @@ -163,8 +159,7 @@ static int VFS_FS_INODE_PUSED(const char *cmd, const char *param, unsigned flags 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 * usg_val) / tot_val; + SET_DBL_RESULT(result, (100.0 * usg_val) / tot_val); return SYSINFO_RET_OK; } @@ -227,4 +222,3 @@ FS_FNCLIST return SYSINFO_RET_FAIL; } - diff --git a/src/libs/zbxsysinfo/openbsd/kernel.c b/src/libs/zbxsysinfo/openbsd/kernel.c index a680d121..630c025f 100644 --- a/src/libs/zbxsysinfo/openbsd/kernel.c +++ b/src/libs/zbxsysinfo/openbsd/kernel.c @@ -41,8 +41,7 @@ int KERNEL_MAXFILES(const char *cmd, const char *param, unsigned flags, AGENT_RE return SYSINFO_RET_FAIL; } - result->type |= AR_DOUBLE; - result->dbl = (double)(maxfiles); + SET_UI64_RESULT(result, maxfiles); return SYSINFO_RET_OK; } @@ -66,8 +65,7 @@ int KERNEL_MAXPROC(const char *cmd, const char *param, unsigned flags, AGENT_RES /* printf("Errno [%m]");*/ } - result->type |= AR_DOUBLE; - result->dbl = (double)(maxproc); + SET_UI64_RESULT(result, maxproc); return SYSINFO_RET_OK; } diff --git a/src/libs/zbxsysinfo/openbsd/memory.c b/src/libs/zbxsysinfo/openbsd/memory.c index 6bc3931b..caecfa3a 100644 --- a/src/libs/zbxsysinfo/openbsd/memory.c +++ b/src/libs/zbxsysinfo/openbsd/memory.c @@ -39,8 +39,7 @@ static int VM_MEMORY_TOTAL(const char *cmd, const char *param, unsigned flags, A if(0==sysctl(mib,2,&v,&len,NULL,0)) { - result->type |= AR_DOUBLE; - result->dbl=(double)((v.t_rm+v.t_free) * sysconf(_SC_PAGESIZE)); + SET_UI64_RESULT(result, (v.t_rm+v.t_free) * sysconf(_SC_PAGESIZE)); ret=SYSINFO_RET_OK; } return ret; @@ -63,8 +62,7 @@ static int VM_MEMORY_FREE(const char *cmd, const char *param, unsigned flags, AG if(0==sysctl(mib,2,&v,&len,NULL,0)) { - result->type |= AR_DOUBLE; - result->dbl=(double)(v.t_free * sysconf(_SC_PAGESIZE)); + SET_UI64_RESULT(result, v.t_free * sysconf(_SC_PAGESIZE)); ret=SYSINFO_RET_OK; } return ret; diff --git a/src/libs/zbxsysinfo/openbsd/net.c b/src/libs/zbxsysinfo/openbsd/net.c index bfb96ad3..2adb526b 100644 --- a/src/libs/zbxsysinfo/openbsd/net.c +++ b/src/libs/zbxsysinfo/openbsd/net.c @@ -109,8 +109,7 @@ static int NET_IF_IN_BYTES(const char *cmd, const char *param, unsigned fla if(ret == SYSINFO_RET_OK) { - result->type |= AR_DOUBLE; - result->dbl = value.if_ibytes; + SET_UI64_RESULT(result, value.if_ibytes); ret = SYSINFO_RET_OK; } @@ -141,8 +140,7 @@ static int NET_IF_IN_PACKETS(const char *cmd, const char *param, unsigned f if(ret == SYSINFO_RET_OK) { - result->type |= AR_DOUBLE; - result->dbl = value.if_ipackets; + SET_UI64_RESULT(result, value.if_ipackets); ret = SYSINFO_RET_OK; } @@ -173,8 +171,7 @@ static int NET_IF_IN_ERRORS(const char *cmd, const char *param, unsigned fl if(ret == SYSINFO_RET_OK) { - result->type |= AR_DOUBLE; - result->dbl = value.if_ierrors; + SET_UI64_RESULT(result, value.if_ierrors); ret = SYSINFO_RET_OK; } @@ -261,8 +258,7 @@ static int NET_IF_OUT_BYTES(const char *cmd, const char *param, unsigned fl if(ret == SYSINFO_RET_OK) { - result->type |= AR_DOUBLE; - result->dbl = value.if_obytes; + SET_UI64_RESULT(result, value.if_obytes); ret = SYSINFO_RET_OK; } @@ -293,8 +289,7 @@ static int NET_IF_OUT_PACKETS(const char *cmd, const char *param, unsigned if(ret == SYSINFO_RET_OK) { - result->type |= AR_DOUBLE; - result->dbl = value.if_opackets; + SET_UI64_RESULT(result, value.if_opackets); ret = SYSINFO_RET_OK; } @@ -325,8 +320,7 @@ static int NET_IF_OUT_ERRORS(const char *cmd, const char *param, unsigned f if(ret == SYSINFO_RET_OK) { - result->type |= AR_DOUBLE; - result->dbl = value.if_oerrors; + SET_UI64_RESULT(result, value.if_oerrors); ret = SYSINFO_RET_OK; } @@ -422,8 +416,7 @@ int NET_IF_COLLISIONS(const char *cmd, const char *param, unsigned flags, AG if(ret == SYSINFO_RET_OK) { - result->type |= AR_DOUBLE; - result->dbl = value.if_collisions; + SET_UI64_RESULT(result, value.if_collisions); ret = SYSINFO_RET_OK; } diff --git a/src/libs/zbxsysinfo/openbsd/proc.c b/src/libs/zbxsysinfo/openbsd/proc.c index ba158c1b..331f9fd0 100644 --- a/src/libs/zbxsysinfo/openbsd/proc.c +++ b/src/libs/zbxsysinfo/openbsd/proc.c @@ -192,11 +192,12 @@ int PROC_MEMORY(const char *cmd, const char *param, unsigned flags, AGENT_RE if(do_task == DO_AVG) { - memsize /= (double)proccount; + SET_DBL_RESULT(result, proccount == 0 ? 0 : ((double)memsize/(double)proccount)); + } + else + { + SET_UI64_RESULT(result, memsize); } - - result->type |= AR_DOUBLE; - result->dbl = memsize; ret = SYSINFO_RET_OK; } return ret; @@ -345,8 +346,7 @@ int PROC_NUM(const char *cmd, const char *param, unsigned flags, AGENT_RESUL } kvm_close(kp); - result->type |= AR_DOUBLE; - result->dbl = (double) proccount; + SET_UI64_RESULT(result, proccount); ret = SYSINFO_RET_OK; } diff --git a/src/libs/zbxsysinfo/openbsd/sensors.c b/src/libs/zbxsysinfo/openbsd/sensors.c index 4ef03c39..cc5a3af8 100644 --- a/src/libs/zbxsysinfo/openbsd/sensors.c +++ b/src/libs/zbxsysinfo/openbsd/sensors.c @@ -24,7 +24,7 @@ #include "md5.h" -static int SENSOR_TEMP1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) +static int get_sensor(const char *name, unsigned flags, AGENT_RESULT *result) { DIR *dir; struct dirent *entries; @@ -49,7 +49,7 @@ static int SENSOR_TEMP1(const char *cmd, const char *param, unsigned flags, AGEN { strscpy(filename,"/proc/sys/dev/sensors/"); strncat(filename,entries->d_name,MAX_STRING_LEN); - strncat(filename,"/temp1",MAX_STRING_LEN); + strncat(filename,name,MAX_STRING_LEN); if(stat(filename,&buf)==0) { @@ -64,118 +64,7 @@ static int SENSOR_TEMP1(const char *cmd, const char *param, unsigned flags, AGEN if(sscanf(line,"%lf\t%lf\t%lf\n",&d1, &d2, &d3) == 3) { closedir(dir); - result->type |= AR_DOUBLE; - result->dbl = d3; - return SYSINFO_RET_OK; - } - else - { - closedir(dir); - return SYSINFO_RET_FAIL; - } - } - } - closedir(dir); - return SYSINFO_RET_FAIL; -} - -static int SENSOR_TEMP2(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) -{ - DIR *dir; - struct dirent *entries; - struct stat buf; - char filename[MAX_STRING_LEN]; - char line[MAX_STRING_LEN]; - double d1,d2,d3; - - FILE *f; - - assert(result); - - init_result(result); - - dir=opendir("/proc/sys/dev/sensors"); - if(NULL == dir) - { - return SYSINFO_RET_FAIL; - } - - while((entries=readdir(dir))!=NULL) - { - strscpy(filename,"/proc/sys/dev/sensors/"); - strncat(filename,entries->d_name,MAX_STRING_LEN); - strncat(filename,"/temp2",MAX_STRING_LEN); - - if(stat(filename,&buf)==0) - { - f=fopen(filename,"r"); - if(f==NULL) - { - continue; - } - fgets(line,MAX_STRING_LEN,f); - fclose(f); - - if(sscanf(line,"%lf\t%lf\t%lf\n",&d1, &d2, &d3) == 3) - { - closedir(dir); - result->type |= AR_DOUBLE; - result->dbl = d3; - return SYSINFO_RET_OK; - } - else - { - closedir(dir); - return SYSINFO_RET_FAIL; - } - } - } - closedir(dir); - return SYSINFO_RET_FAIL; -} - -static int SENSOR_TEMP3(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) -{ - DIR *dir; - struct dirent *entries; - struct stat buf; - char filename[MAX_STRING_LEN]; - char line[MAX_STRING_LEN]; - double d1,d2,d3; - - FILE *f; - - assert(result); - - init_result(result); - - dir=opendir("/proc/sys/dev/sensors"); - if(NULL == dir) - { - return SYSINFO_RET_FAIL; - } - - while((entries=readdir(dir))!=NULL) - { - strscpy(filename,"/proc/sys/dev/sensors/"); - strncat(filename,entries->d_name,MAX_STRING_LEN); - strncat(filename,"/temp3",MAX_STRING_LEN); - - if(stat(filename,&buf)==0) - { - f=fopen(filename,"r"); - if(f==NULL) - { - continue; - } - fgets(line,MAX_STRING_LEN,f); - fclose(f); - - if(sscanf(line,"%lf\t%lf\t%lf\n",&d1, &d2, &d3) == 3) - { - closedir(dir); - result->type |= AR_DOUBLE; - result->dbl = d3; + SET_DBL_RESULT(result, d3); return SYSINFO_RET_OK; } else @@ -210,15 +99,15 @@ int OLD_SENSOR(const char *cmd, const char *param, unsigned flags, AGENT_RES if(strcmp(key,"temp1") == 0) { - ret = SENSOR_TEMP1(cmd, param, flags, result); + ret = get_sensor("temp1", flags, result); } else if(strcmp(key,"temp2") == 0) { - ret = SENSOR_TEMP2(cmd, param, flags, result); + ret = get_sensor("temp2", flags, result); } else if(strcmp(key,"temp3") == 0) { - ret = SENSOR_TEMP3(cmd, param, flags, result); + ret = get_sensor("temp3", flags, result); } else { diff --git a/src/libs/zbxsysinfo/openbsd/swap.c b/src/libs/zbxsysinfo/openbsd/swap.c index 2d0533ec..10d096ac 100644 --- a/src/libs/zbxsysinfo/openbsd/swap.c +++ b/src/libs/zbxsysinfo/openbsd/swap.c @@ -72,8 +72,7 @@ static int SYSTEM_SWAP_FREE(const char *cmd, const char *param, unsigned flags, if(ret != SYSINFO_RET_OK) return ret; - result->type |= AR_DOUBLE; - result->dbl = value; + SET_UI64_RESULT(result, value); return ret; } @@ -91,8 +90,7 @@ static int SYSTEM_SWAP_TOTAL(const char *cmd, const char *param, unsigned flags, if(ret != SYSINFO_RET_OK) return ret; - result->type |= AR_DOUBLE; - result->dbl = value; + SET_UI64_RESULT(result, value); return ret; } @@ -292,8 +290,7 @@ int SYSTEM_SWAP_IN(const char *cmd, const char *param, unsigned flags, AGENT_RES if(ret != SYSINFO_RET_OK) return ret; - result->type |= AR_DOUBLE; - result->dbl = value; + SET_UI64_RESULT(result, value); return ret; } @@ -350,7 +347,6 @@ int SYSTEM_SWAP_OUT(const char *cmd, const char *param, unsigned flags, AGENT_RE if(ret != SYSINFO_RET_OK) return ret; - result->type |= AR_DOUBLE; - result->dbl = value; + SET_UI64_RESULT(result, value); return ret; } diff --git a/src/libs/zbxsysinfo/openbsd/uptime.c b/src/libs/zbxsysinfo/openbsd/uptime.c index 1c0f609e..c0491e9e 100644 --- a/src/libs/zbxsysinfo/openbsd/uptime.c +++ b/src/libs/zbxsysinfo/openbsd/uptime.c @@ -42,8 +42,7 @@ int SYSTEM_UPTIME(const char *cmd, const char *param, unsigned flags, AGENT_RESU { now=time(NULL); - result->type |= AR_DOUBLE; - result->dbl = (double)(now-uptime.tv_sec); + SET_UI64_RESULT(result, now - uptime.tv_sec); ret = SYSINFO_RET_OK; } |
