Memory HAL

From Net-SNMP Wiki
Revision as of 15:24, 30 September 2007 by BobocDronr (Talk | contribs)

Jump to: navigation, search

acdelcvarchi Net-SNMP 5.4 has introduced the memory HAL. Here's an overview how it calculates the values currently:

MEMTOTALSWAP:
    MEM_SWAP -> size
        aix:     perfstat_memory_total().pgsp_total
        darwin:  swapsize()
        dynix:   getTotalSwap()
        freeBSD: swapmode().swapTotal
        hpux:    getswapinfo().total_swap
        irix:    swapctl(GETSWAPTOT)
        linux:   /proc/meminfo:SwapTotal
        netBSD:  sysctl(VM_UVMEXP).swpages
        solaris: getSwapInfo().swap_pages
        win:     GlobalMemoryStatus().dwTotalPageFile
MEMAVAILSWAP:
    MEM_SWAP -> free
        aix:     perfstat_memory_total().pgsp_free
        darwin:  swapsize() - pages_swapped()
        dynix:   getFreeSwap()
        freeBSD: swapmode().swapFree
        hpux:    getswapinfo().free_swap
        irix:    swapctl(GETFREESWAP)
        linux:   /proc/meminfo:SwapFree
        netBSD:  sysctl(VM_UVMEXP).(swpages-swpginuse)
        solaris: getSwapInfo().swap_free
        win:     GlobalMemoryStatus().dwAvailPageFile
MEMTOTALREAL:
    MEM_PHYSMEM -> size
        aix:     perfstat_memory_total().real_total
        darwin:  sysctl(HW_PHYSMEM)
        dynix:   sysconf(PHYSMEM)
        freeBSD: sysctl(HW_USERMEM)
        hpux:    pstat_getstatic().physical_memory
        irix:    sysmp(MPSA_RMINFO).physmem
        linux:   /proc/meminfo:MemTotal
        netBSD:  sysctl(HW_PHYSMEM)
        solaris: sysconf(_SC_PHYS_PAGES)
         (or)    kstat("physmem")
        win:     GlobalMemoryStatus().dwTotalPhys
MEMAVAILREAL:
    MEM_PHYSMEM -> free
        aix:     perfstat_memory_total().real_free
        darwin:  sysctl(HW_PHYSMEM) - host_stats(VM_INFO).
                     (active_count+inactive_count+wire_count)
        dynix:   sysconf(FREEMEM)
        freeBSD: sysctl(VM_METER).t_free
        hpux:    pstat_getdynamic().psd_free
        irix:    sysmp(MPSA_RMINFO).availrmem
        linux:   /proc/meminfo:MemFree
        netBSD:  sysctl(VM_METER).t_free
        solaris: sysconf(_SC_AVPHYS_PAGES)
         (or)    swapctl(SC_AINFO).(ani_max-ani_resv)
                      - getSwapInfo().swap_free
        win:     GlobalMemoryStatus().dwAvailPhys
MEMTOTALSWAPTXT:
    MEM_STEXT -> size
        hpux:    pstat_getdynamic().psd_vmtxt
MEMAVAILSWAPTXT:
    MEM_STEXT -> free
        hpux:    pstat_getdynamic().psd_avmtxt
MEMTOTALREALTXT:
    MEM_RTEXT -> size
        hpux:    pstat_getdynamic().psd_rmtxt
MEMAVAILREALTXT:
    MEM_RTEXT -> free
        hpux:    pstat_getdynamic().psd_armtxt
MEMTOTALFREE:
    MEM_VIRTMEM -> free
        aix:     perfstat_memory_total().(real_free+pgsp_free)
        freeBSD: sysctl(VM_METER).t_avm
        irix:    sysmp(MPSA_RMINFO).availsmem
        linux:   /proc/meminfo:(MemFree+SwapFree)
        win:     GlobalMemoryStatus().dwAvailVirtual
MEMSHARED:
    MEM_SHARED -> size
        freeBSD: sysctl(VM_METER).t_vmshr
        linux:   /proc/meminfo:MemShared
MEMBUFFER:
    MEM_MBUF -> size
        linux:   /proc/meminfo:Buffers
MEMCACHED:
    MEM_CACHED -> size
        freeBSD: nlist("cnt").v_cache_count
        linux:   /proc/meminfo:Cached
ERRORFLAG/ERRORMSG:
    MEM_SWAP -> free

There are a few differences to how the previous implementations calculated the values:

MEMAVAILREAL:
    FreeBSD:  sysctl(VM_METER).t_free  vs  nlist("cnt").v_free_count
    NetBSD:   sysctl(VM_METER).t_free  vs  sysctl(VM_UVMEXP).free

      t_free:       /* free memory pages    */  (sys/vmmeter.h:vmtotal)
      v_free_count: /* number of pages free */  (sys/vmmeter.h:vmmeter)
      free:         /* number of free pages */  (uvm/uvm_extern.h:uvmexp)

MEMAVAILSWAPTEXT:
    HP-UX:    pstat_getdynamic().psd_avmtxt  vs
                        pstat_getdynamic().(psd_vmtxt - psd_avmtxt)

MEMAVAILREALTEXT:
    HP-UX:    pstat_getdynamic().psd_armtxt  vs
                        pstat_getdynamic().(psd_rmtxt - psd_armtxt)

MEMTOTALFREE:
    FreeBSD:  sysctl(VM_METER).t_vm    vs  sysctl(VM_METER).t_free
    HP-UX:    <missing>                vs
                   pstat_getdynamic().psd_free + getswapinfo().free_swap
    Dynix:    <missing>                vs  getTotalFree()
    NetBSD:   <missing>                vs  sysctl(VM_METER).t_free
    Solaris:  <missing>                vs  getTotalFree()

      t_vm:         /* total virtual memory */   (sys/vmmeter.h:vmtotal)
      t_free:       /* free memory pages    */   (sys/vmmeter.h:vmtotal)

      AIX,HP-UX,Dynix,Solaris,Linux are all MEMAVAILREAL+MEMAVAILSWAP
      FreeBSD,NetBSD are just MEMAVAILSWAP

MEMSHARED:
    FreeBSD:  sysctl(VM_METER).t_vmshr vs
                    sysctl(VM_METER).(t_vmshr+t_avmshr+t_rmshr+t_armshr)

MEMBUFFER:
    FreeBSD:   <missing>               vs  nlist("bufspace")

ERRORFLAG/ERRORMSG:
    5.4 - HAL:                MEMAVAILSWAP
    AIX,Dynix,HP-UX,Solaris:  MEMTOTALFREE
    Darwin:                   MEMAVAILSWAP
                             (MEMTOTALFREE not implemented)
    FreeBSD,NetBSD:           MEMAVAILSWAP   (swapFree)
                             (MEMTOTALFREE    sysctl(VM_METER).t_free)