|
FreeBSD Ports and Packages Installation and upgrading of ports and packages on FreeBSD. |
|
Thread Tools | Display Modes |
|
|||
memory usage monitoring using net-snmp
Hello everybody. I've spent the last 2 or 3 (4?) days trying to figure out how to do accuratelly what's written on the subject. Hope will help someone. I have some questions, too
All was tested on 7.0-RELEASE, net-snmp-5.4.1.2_2. One of my goals was to find where the snmp values come from. You could use 2 subtrees to collect system memory information. These are HOST-RESOURCES-MIB and UCD-SNMP-MIB. HOST-RESOURCES-MIB::hrStorage* ============================== hw.(physmem/pagesize) ->hrStorageSize.1 (Physical memory) vm.vmtotal."Free Memory Pages"(t_free) ->hrStorageUsed.1 vm.vmtotal."Real Memory: total"(t_rm) ->hrStorageSize.2 (Real memory) vm.vmtotal."Real Memory: active"(t_arm) ->hrStorageUsed.2 vm.vmtotal."Virtual Memory: total"(t_vm) ->hrStorageSize.3 (Virtual memory) vm.vmtotal."Virtual Memory: active"(t_avm) ->hrStorageUsed.3 vfs.bufspace ->hrStorageSize.6 (Memory Buffer) vm.stats.vm.(v_cache_count + v_inactive_count) ->hrStorageSize.7 (Cached memory) vm.vmtotal."Shared Virtual Memory: total"(t_vmshr) ->hrStorageSize.8 (Shared virtual memory) vm.vmtotal."Shared Virtual Memory: active"(t_avmshr) ->hrStorageUsed.8 vm.vmtotal."Shared Real Memory: total"(t_rmshr) ->hrStorageSize.9 (Shared real memory) vm.vmtotal."Shared Real Memory: active"(t_armshr) ->hrStorageUsed.9 kvm_getswapinfo() ->hrStorage{Size, Used}.10 (Swap space) =============================== The '->' means the left side (sysctl oids) determines the right side (snmp oids) using simple arithmetics with hw.pagesize and the *Size preceding value (where applicable). (By the way, 'real' means 'resident'.) The kernel computes the free pages value like that: total.t_free = cnt.v_free_count + cnt.v_cache_count; as written in vm_meter.c. But, the "Free Memory Pages" values (from `sysctl vm.vmtotal`) is always different from the free physical memory value returned from HOST-RESOURCES-MIB (which equals, all the time, to UCD-SNMP-MIB::memAvailReal.0), which again is always equal to the sum of v_free_count and v_cache_count returned by `sysctl vm`, multiplied by 4 (page size in kB). So: free memory = vm.stats.vm.(free+cache)_page_count * hw.pagesize cached memory = vm.stats.vm.(cache+inactive)_page_count * hw.pagesize 1. Why is "Free Memory Pages" (?= t_free) from `sysctl vm.vmtotal` different from the free memory calculated as above? 2. Why counting v_cache_count twice: one time for the free memory and one time for the cached memory? Now we can not sum them (not many reasons to do that, but still). The UCD-SNMP-MIB returned values (although related to those from HOST-RESOURCES-MIB, except memTotalFree) remain a mistery to me even after reading memory_freebsd2.c from the net-snmp source tree. It seems they are computed somewhere else, but I could not figure where. From observations: memTotalSwap = 4 * hrStorageSize.3 memAvailSwap = 4* (hrStorageSize.3 - hrStorageUsed.3) memTotalReal = 4 * hrStorageSize.1 memAvailReal = 4 * (hrStorageSize.1 - hrStorageUsed.1) memTotalFree = ???? (have no ideea) memShared = 4 * hrStorageSize.8 memBuffer = 4 * hrStorageSize.6 memCached = 4 * hrStorageSize.7 '4' is the hrStorageAllocationUnits size in kB and 'Real' means 'physical' here. 3. Where are these values (UCD-SNMP-MIB::mem*) computed? |
|
|||
Quote:
- the 'cached' vm objects count as free memory because they could be immediately used for allocation, being clean; - the 'cached' vm objects count as cached memory because they contain data existing on the backing store (disk, etc.); - the 'inactive' vm objects are dirty (i.e their contents were not flushed to the backing store), so they _could not_ be used immediately for allocation but they count as cached memory, because they contain data which will exist (they _must_ be flushed) on the backing store. These being said, there is no reason to sum 'free memory' and 'cached memory' on FreeBSD. This is not the case under linux, where: available memory <- free pages + cached pages + buffer cache As far as I understood, in FreeBSD the vfs.bufspace could not be freed so it never counts as available memory. |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to: DMESG Monitoring | damien-NF | FreeBSD Installation and Upgrading | 2 | 4th August 2009 11:30 PM |
Memory Not Detected | jrs | OpenBSD Installation and Upgrading | 3 | 19th May 2009 05:50 PM |
KDE4 uses a lot of memory... | mdh | FreeBSD General | 6 | 21st October 2008 06:21 AM |
pf NAT monitoring | cerulean | FreeBSD General | 1 | 20th October 2008 12:27 PM |
problems with installing net-snmp | dejabu18 | FreeBSD Ports and Packages | 9 | 17th May 2008 07:17 PM |