$NetBSD: patch-dn,v 1.1 2006/03/19 22:03:29 joerg Exp $ --- agent/mibgroup/ucd-snmp/memory_freebsd2.c.orig 2006-03-19 20:27:45.000000000 +0000 +++ agent/mibgroup/ucd-snmp/memory_freebsd2.c @@ -10,8 +10,12 @@ */ #include #include +#ifdef dragonfly +#include +#else #include #include +#endif #ifdef freebsd5 #include #endif @@ -251,6 +255,10 @@ var_extensible_mem(struct variable *vp, static struct vmmeter mem; static struct vmtotal total; +#ifdef dragonfly + static struct vmstats vmstats; + size_t vmstats_size = sizeof(vmstats); +#endif size_t total_size = sizeof(total); int total_mib[] = { CTL_VM, VM_METER }; @@ -284,6 +292,8 @@ var_extensible_mem(struct variable *vp, */ sysctl(phys_mem_mib, 2, &phys_mem, &phys_mem_size, NULL, 0); + sysctlbyname("vm.vmstats", &vmstats, &vmstats_size, NULL, 0); + #ifdef BUFSPACE_SYMBOL /* * Buffer space @@ -296,7 +306,11 @@ var_extensible_mem(struct variable *vp, /* * Page-to-kb macro */ +#ifdef dragonfly +#define ptok(p) ((p) * (vmstats.v_page_size >> 10)) +#else #define ptok(p) ((p) * (mem.v_page_size >> 10)) +#endif switch (vp->magic) { case MIBINDEX: @@ -316,7 +330,11 @@ var_extensible_mem(struct variable *vp, long_ret = phys_mem >> 10; return ((u_char *) (&long_ret)); case MEMAVAILREAL: /* FREE real memory */ +#ifdef dragonfly + long_ret = ptok(vmstats.v_free_count); +#else long_ret = ptok(mem.v_free_count); +#endif return ((u_char *) (&long_ret)); /* @@ -351,6 +369,8 @@ var_extensible_mem(struct variable *vp, case MEMCACHED: #ifdef darwin long_ret = ptok(mem.v_lookups); +#elif defined(dragonfly) + long_ret = ptok(vmstats.v_cache_count); #else long_ret = ptok(mem.v_cache_count); #endif