1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
$NetBSD: patch-dn,v 1.2 2008/09/08 12:58:09 adam Exp $
--- agent/mibgroup/ucd-snmp/memory_freebsd2.c.orig 2008-02-12 18:40:48.000000000 +0100
+++ agent/mibgroup/ucd-snmp/memory_freebsd2.c
@@ -10,8 +10,12 @@
*/
#include <sys/param.h>
#include <sys/time.h>
+#ifdef dragonfly
+#include <sys/user.h>
+#else
#include <sys/proc.h>
#include <sys/dkstat.h>
+#endif
#ifdef freebsd5
#include <sys/bio.h>
#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) + ptok(mem.v_inactive_count);
#endif
|