From 2b0a2c57ce5d2aae2e87fb0578618a4178f8b4f3 Mon Sep 17 00:00:00 2001 From: osmiy Date: Mon, 12 Dec 2005 14:01:21 +0000 Subject: - added support of system.cpu.load for Tru64 (Eugene) - added support of system.cpu.util for Tru64 (Eugene) - added support of vm.memory.size for Tru64 (Eugene) - added support of proc.num for Tru64 (Eugene) git-svn-id: svn://svn.zabbix.com/trunk@2413 97f52cf1-0a1b-0410-bd0e-c28be96e8082 --- src/libs/zbxsysinfo/osf/memory.c | 214 +-------------------------------------- 1 file changed, 2 insertions(+), 212 deletions(-) (limited to 'src/libs/zbxsysinfo/osf/memory.c') diff --git a/src/libs/zbxsysinfo/osf/memory.c b/src/libs/zbxsysinfo/osf/memory.c index 31bef3e0..d2cff851 100644 --- a/src/libs/zbxsysinfo/osf/memory.c +++ b/src/libs/zbxsysinfo/osf/memory.c @@ -22,219 +22,13 @@ #include "common.h" #include "sysinfo.h" -static int VM_MEMORY_CACHED(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) -{ -#ifdef HAVE_PROC -/* Get CACHED memory in bytes */ -/* return getPROC("/proc/meminfo",8,2,msg,mlen_max);*/ -/* It does not work for both 2.4 and 2.6 */ -/* return getPROC("/proc/meminfo",2,7,msg,mlen_max);*/ - FILE *f; - char *t; - char c[MAX_STRING_LEN]; - double res = 0; - - assert(result); - - init_result(result); - - f=fopen("/proc/meminfo","r"); - if(NULL == f) - { - return SYSINFO_RET_FAIL; - } - while(NULL!=fgets(c,MAX_STRING_LEN,f)) - { - if(strncmp(c,"Cached:",7) == 0) - { - t=(char *)strtok(c," "); - t=(char *)strtok(NULL," "); - sscanf(t, "%lf", &res ); - break; - } - } - fclose(f); - - SET_UI64_RESULT(result, res); - return SYSINFO_RET_OK; -#else - assert(result); - - init_result(result); - - return SYSINFO_RET_FAIL; -#endif -} - -static int VM_MEMORY_BUFFERS(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) -{ -#ifdef HAVE_SYSINFO_BUFFERRAM - struct sysinfo info; - - assert(result); - - init_result(result); - - if( 0 == sysinfo(&info)) - { -#ifdef HAVE_SYSINFO_MEM_UNIT - SET_UI64_RESULT(result, info.bufferram * info.mem_unit); -#else - SET_UI64_RESULT(result, info.bufferram); -#endif - return SYSINFO_RET_OK; - } - else - { - return SYSINFO_RET_FAIL; - } -#else - assert(result); - - init_result(result); - - return SYSINFO_RET_FAIL; -#endif -} - -static int VM_MEMORY_SHARED(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) -{ -#ifdef HAVE_SYSINFO_SHAREDRAM - struct sysinfo info; - - assert(result); - - init_result(result); - - if( 0 == sysinfo(&info)) - { -#ifdef HAVE_SYSINFO_MEM_UNIT - SET_UI64_RESULT(result, info.sharedram * info.mem_unit); -#else - SET_UI64_RESULT(result, info.sharedram); -#endif - return SYSINFO_RET_OK; - } - else - { - return SYSINFO_RET_FAIL; - } -#elif defined(HAVE_SYS_VMMETER_VMTOTAL) - int mib[2],len; - struct vmtotal v; - - assert(result); - - init_result(result); - - len=sizeof(struct vmtotal); - mib[0]=CTL_VM; - mib[1]=VM_METER; - - sysctl(mib,2,&v,&len,NULL,0); - - SET_UI64_RESULT(result, v.t_armshr<<2); - return SYSINFO_RET_OK; -#else - return SYSINFO_RET_FAIL; -#endif -} - static int VM_MEMORY_TOTAL(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) { -/* Solaris */ -#ifdef HAVE_UNISTD_SYSCONF - assert(result); - - init_result(result); - - SET_UI64_RESULT(result, sysconf(_SC_PHYS_PAGES)*sysconf(_SC_PAGESIZE)); - return SYSINFO_RET_OK; -#elif defined(HAVE_SYS_PSTAT_H) - struct pst_static pst; - long page; - - assert(result); - - init_result(result); - - if(pstat_getstatic(&pst, sizeof(pst), (size_t)1, 0) == -1) - { - return SYSINFO_RET_FAIL; - } - else - { - /* Get page size */ - page = pst.page_size; - /* Total physical memory in bytes */ - SET_UI64_RESULT(result, page*pst.physical_memory); - return SYSINFO_RET_OK; - } -#elif defined(HAVE_SYSINFO_TOTALRAM) - struct sysinfo info; - assert(result); init_result(result); - - if( 0 == sysinfo(&info)) - { -#ifdef HAVE_SYSINFO_MEM_UNIT - SET_UI64_RESULT(result, info.totalram * info.mem_unit); -#else - SET_UI64_RESULT(result, info.totalram); -#endif - return SYSINFO_RET_OK; - } - else - { - return SYSINFO_RET_FAIL; - } -#elif defined(HAVE_SYS_VMMETER_VMTOTAL) - int mib[2],len; - struct vmtotal v; - - assert(result); - - init_result(result); - - len=sizeof(struct vmtotal); - mib[0]=CTL_VM; - mib[1]=VM_METER; - - sysctl(mib,2,&v,&len,NULL,0); - - SET_UI64_RESULT(result, v.t_rm<<2); - return SYSINFO_RET_OK; -#elif defined(HAVE_SYS_SYSCTL_H) - static int mib[] = { CTL_HW, HW_PHYSMEM }; - size_t len; - unsigned int memory; - int ret; - assert(result); - - init_result(result); - - len=sizeof(memory); - - if(0==sysctl(mib,2,&memory,&len,NULL,0)) - { - SET_UI64_RESULT(result, memory); - ret=SYSINFO_RET_OK; - } - else - { - ret=SYSINFO_RET_FAIL; - } - return ret; -#else - assert(result); - - init_result(result); - - return SYSINFO_RET_FAIL; -#endif + return EXECUTE(cmd,"vmstat -s | awk 'BEGIN{pages=0}{gsub(\"[()]\",\"\");if($4==\"pagesize\")pgsize=($6);if(($2==\"inactive\"||$2==\"active\"||$2==\"wired\")&&$3==\"pages\")pages+=$1}END{printf (pages*pgsize)}'", flags, result); } static int VM_MEMORY_FREE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) @@ -279,9 +73,8 @@ static int VM_MEMORY_FREE(const char *cmd, const char *param, unsigned flags, AG assert(result); init_result(result); - - return SYSINFO_RET_FAIL; + return EXECUTE(cmd, "vmstat -s | awk '{gsub(\"[()]\",\"\");if($4==\"pagesize\")pgsize=($6);if($2==\"free\"&&$3==\"pages\")pages=($1)}END{printf (pages*pgsize)}'", flags, result); } int VM_MEMORY_SIZE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) @@ -296,10 +89,7 @@ MEM_FNCLIST MEM_FNCLIST fl[] = { {"free", VM_MEMORY_FREE}, - {"shared", VM_MEMORY_SHARED}, {"total", VM_MEMORY_TOTAL}, - {"buffers", VM_MEMORY_BUFFERS}, - {"cached", VM_MEMORY_CACHED}, {0, 0} }; char mode[MAX_STRING_LEN]; -- cgit