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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
$NetBSD: patch-fi,v 1.3 2006/10/08 07:49:27 markd Exp $
--- ksysguard/ksysguardd/NetBSD/Memory.c.orig 2006-10-08 15:49:27.000000000 +1300
+++ ksysguard/ksysguardd/NetBSD/Memory.c
@@ -45,8 +45,11 @@
static size_t Total = 0;
static size_t MFree = 0;
static size_t Used = 0;
-static size_t Buffers = 0;
-static size_t Cached = 0;
+static size_t Active = 0;
+static size_t Inactive = 0;
+static size_t Wired = 0;
+static size_t Execpages = 0;
+static size_t Filepages = 0;
static size_t STotal = 0;
static size_t SFree = 0;
static size_t SUsed = 0;
@@ -55,19 +58,18 @@ static kvm_t *kd;
void
initMemory(struct SensorModul* sm)
{
- char *nlistf = NULL;
- char *memf = NULL;
- char buf[_POSIX2_LINE_MAX];
-
- if ((kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, buf)) == NULL) {
- log_error("kvm_openfiles()");
+ if ((kd = kvm_open(NULL, NULL, NULL, KVM_NO_FILES, "kvm_open")) == NULL) {
+ log_error("kvm_open()");
return;
}
registerMonitor("mem/physical/free", "integer", printMFree, printMFreeInfo, sm);
registerMonitor("mem/physical/used", "integer", printUsed, printUsedInfo, sm);
- registerMonitor("mem/physical/buf", "integer", printBuffers, printBuffersInfo, sm);
- registerMonitor("mem/physical/cached", "integer", printCached, printCachedInfo, sm);
+ registerMonitor("mem/physical/active", "integer", printActive, printActiveInfo, sm);
+ registerMonitor("mem/physical/inactive", "integer", printInactive, printInactiveInfo, sm);
+ registerMonitor("mem/physical/wired", "integer", printWired, printWiredInfo, sm);
+ registerMonitor("mem/physical/execpages", "integer", printExecpages, printExecpagesInfo, sm);
+ registerMonitor("mem/physical/filepages", "integer", printFilepages, printFilepagesInfo, sm);
registerMonitor("mem/swap/free", "integer", printSwapFree, printSwapFreeInfo, sm);
registerMonitor("mem/swap/used", "integer", printSwapUsed, printSwapUsedInfo, sm);
}
@@ -83,7 +85,6 @@ updateMemory(void)
{
#define ARRLEN(X) (sizeof(X)/sizeof(X[0]))
- long pagesize; /* using a long promotes the arithmetic */
size_t len;
{
@@ -95,37 +96,26 @@ updateMemory(void)
}
{
- struct uvmexp x;
- static int mib[] = { CTL_VM, VM_UVMEXP };
+ struct uvmexp_sysctl x;
+ static int mib[] = { CTL_VM, VM_UVMEXP2 };
len = sizeof(x);
STotal = SUsed = SFree = -1;
- pagesize = 1;
+ Active = Inactive = Wired = Execpages = Filepages = MFree = Used = -1;
if (-1 < sysctl(mib, ARRLEN(mib), &x, &len, NULL, 0)) {
- pagesize = x.pagesize;
- STotal = (pagesize*x.swpages) >> 10;
- SUsed = (pagesize*x.swpginuse) >> 10;
+ STotal = (x.pagesize*x.swpages) >> 10;
+ SUsed = (x.pagesize*x.swpginuse) >> 10;
SFree = STotal - SUsed;
+ MFree = (x.free * x.pagesize) >> 10;
+ Active = (x.active * x.pagesize) >> 10;
+ Inactive = (x.inactive * x.pagesize) >> 10;
+ Wired = (x.wired * x.pagesize) >> 10;
+ Execpages = (x.execpages * x.pagesize) >> 10;
+ Filepages = (x.filepages * x.pagesize) >> 10;
+ Used = Total - MFree;
}
}
- /* can't find NetBSD filesystem buffer info */
- Buffers = -1;
-
- /* NetBSD doesn't know about vm.stats */
- Cached = -1;
-
- {
- static int mib[]={ CTL_VM, VM_METER };
- struct vmtotal x;
-
- len = sizeof(x);
- MFree = Used = -1;
- if (sysctl(mib, ARRLEN(mib), &x, &len, NULL, 0) > -1) {
- MFree = (x.t_free * pagesize) >> 10;
- Used = (x.t_rm * pagesize) >> 10;
- }
- }
return 0;
}
@@ -154,27 +144,63 @@ printUsedInfo(const char* cmd)
}
void
-printBuffers(const char* cmd)
+printActive(const char* cmd)
+{
+ fprintf(CurrentClient, "%d\n", Active);
+}
+
+void
+printActiveInfo(const char* cmd)
+{
+ fprintf(CurrentClient, "Active Memory\t0\t%d\tKB\n", Total);
+}
+
+void
+printInactive(const char* cmd)
+{
+ fprintf(CurrentClient, "%d\n", Inactive);
+}
+
+void
+printInactiveInfo(const char* cmd)
+{
+ fprintf(CurrentClient, "Inactive Memory\t0\t%d\tKB\n", Total);
+}
+
+void
+printWired(const char* cmd)
+{
+ fprintf(CurrentClient, "%d\n", Wired);
+}
+
+void
+printWiredInfo(const char* cmd)
+{
+ fprintf(CurrentClient, "Wired Memory\t0\t%d\tKB\n", Total);
+}
+
+void
+printExecpages(const char* cmd)
{
- fprintf(CurrentClient, "%d\n", Buffers);
+ fprintf(CurrentClient, "%d\n", Execpages);
}
void
-printBuffersInfo(const char* cmd)
+printExecpagesInfo(const char* cmd)
{
- fprintf(CurrentClient, "Buffer Memory\t0\t%d\tKB\n", Total);
+ fprintf(CurrentClient, "Exec Pages\t0\t%d\tKB\n", Total);
}
void
-printCached(const char* cmd)
+printFilepages(const char* cmd)
{
- fprintf(CurrentClient, "%d\n", Cached);
+ fprintf(CurrentClient, "%d\n", Filepages);
}
void
-printCachedInfo(const char* cmd)
+printFilepagesInfo(const char* cmd)
{
- fprintf(CurrentClient, "Cached Memory\t0\t%d\tKB\n", Total);
+ fprintf(CurrentClient, "File Pages\t0\t%d\tKB\n", Total);
}
void
|