Package: zabbix Severity: wishlist Function vm.memory.size[free] shows free system memory which is calculated like this: free = total - (buffers + cached +used) So, it shows real free memory during short period after system start only. Here's my system:
[EMAIL PROTECTED]:~ $ free -m total used free shared buffers cached Mem: 2026 1976 50 0 269 1382 -/+ buffers/cache: 324 1702 Swap: 2047 0 2047 vm.memory.size[free] shows, that I've got only 50 MB of free memory, and zabbix activates warning trigger. I found a patch on Zabbix Forum (http://www.zabbix.com/forum/showthread.php?t=2405), which add new 'available' functionality to vm.memory.size[] function. It calculates available memory as below: avaliable = total - used omitting buffers and cached. Now I've got 1702 MB of available memory, and no triggers activated. It applies cleanly to zabbix-1.1. Can it be applied to Debian version too? -- Krzysztof Raczkowski Rzeszow University of Technology System Administrator of CZ RMSK tel.: (017) 865-13-93; e-mail: [EMAIL PROTECTED]
--- zabbix-1.1beta7.orig/src/libs/zbxsysinfo/linux/memory.c 2005-12-15 03:11:02.000000000 -0600 +++ zabbix-1.1beta7/src/libs/zbxsysinfo/linux/memory.c 2006-03-14 16:13:47.000000000 -0600 @@ -22,17 +22,13 @@ #include "common.h" #include "sysinfo.h" -static int VM_MEMORY_CACHED(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) +zbx_uint64_t vm_cached_internal(void) { FILE *f; char *t; char c[MAX_STRING_LEN]; zbx_uint64_t res = 0; - assert(result); - - init_result(result); - f=fopen("/proc/meminfo","r"); if(NULL == f) { @@ -56,8 +52,39 @@ } } fclose(f); + return res; +} + +static int VM_MEMORY_AVAILABLE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) +{ + struct sysinfo info; + + assert(result); + + init_result(result); + + if( 0 == sysinfo(&info)) + { +#ifdef HAVE_SYSINFO_MEM_UNIT + SET_UI64_RESULT(result, ((zbx_uint64_t)(info.freeram + info.bufferram) * (zbx_uint64_t)info.mem_unit) + vm_cached_internal()); +#else + SET_UI64_RESULT(result, (info.freeram + info.sharedram + vm_cached_internal())); +#endif + return SYSINFO_RET_OK; + } + else + { + return SYSINFO_RET_FAIL; + } +} + +static int VM_MEMORY_CACHED(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) +{ + assert(result); + + init_result(result); - SET_UI64_RESULT(result, res); + SET_UI64_RESULT(result, vm_cached_internal()); return SYSINFO_RET_OK; } @@ -169,6 +196,7 @@ {"total", VM_MEMORY_TOTAL}, {"buffers", VM_MEMORY_BUFFERS}, {"cached", VM_MEMORY_CACHED}, + {"available", VM_MEMORY_AVAILABLE}, {0, 0} }; char mode[MAX_STRING_LEN];