Hello Gang!
Currently, people, the vm.vmmeter sysctl is "bogus and misleading". It
refers to struct vmtotal, which gives us the "system wide totals", and
does not relate/refer to struct vmmeter in _any_ way.
It is silently skipped by sysctl -a listing, because there is no handler
for it:
# sysctl vm.vmmeter # nothing returned...
# sysctl -ao vm.vmmeter
vm.vmmeter: Format:S,vmtotal Length:48 Dump: ....
It has been this from the days of 3.0-CURRENT, and earlier, I think. PR
kern/5689 addressed this problem. Johan Karlsson assigned this PR to
phk@ in 2000 (submitted: 1998), but no action was taken by anyone anyway,
and eventually, patch was left to rot.
Well, I have updated the patch for 3.0-CURRENT, for our latest -current,
and also made one more change vmmeter->vmtotal, as requested in the PR.
The patches are attached with this mail. I would be very grateful is
someone can commit (and review) them for me.
Cheers.
P.S. http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/5689
--
Hiten Pandya ([EMAIL PROTECTED], [EMAIL PROTECTED])
http://www.unixdaemons.com/~hiten/
Index: sbin/sysctl/sysctl.c
===================================================================
RCS file: /home/ncvs/src/sbin/sysctl/sysctl.c,v
retrieving revision 1.48
diff -u -r1.48 sysctl.c
--- sbin/sysctl/sysctl.c 2002/11/12 21:18:21 1.48
+++ sbin/sysctl/sysctl.c 2002/12/08 14:58:56
@@ -54,6 +54,7 @@
#include <sys/resource.h>
#include <sys/stat.h>
#include <sys/sysctl.h>
+#include <sys/vmmeter.h>
#include <ctype.h>
#include <err.h>
@@ -323,6 +324,29 @@
}
static int
+S_vmtotal(int l2, void *p)
+{
+ struct vmtotal *v = (struct vmtotal *)p;
+
+ if (l2 != sizeof(*v)) {
+ warnx("S_vmtotal %d != %d", l2, sizeof(*v));
+ return (0);
+ }
+
+ printf("\nSystem wide totals computed every five seconds:\n");
+ printf("===============================================\n");
+ printf("Processes: (RUNQ:\t %hu Disk Wait: %hu Page Wait: %hu Sleep: %hu)\n",
+ v->t_rq, v->t_dw, v->t_pw, v->t_sl);
+ printf("Virtual Memory:\t\t (Total: %hu Active %hu)\n", v->t_vm, v->t_avm);
+ printf("Real Memory:\t\t (Total: %hu Active %hu)\n", v->t_rm, v->t_arm);
+ printf("Shared Virtual Memory:\t (Total: %hu Active: %hu)\n", v->t_vmshr,
+v->t_avmshr);
+ printf("Shared Real Memory:\t (Total: %hu Active: %hu)\n", v->t_rmshr,
+v->t_armshr);
+ printf("Free Memory Pages:\t %hu\n", v->t_free);
+
+ return (0);
+}
+
+static int
T_dev_t(int l2, void *p)
{
dev_t *d = (dev_t *)p;
@@ -587,6 +611,8 @@
func = S_timeval;
else if (strcmp(fmt, "S,loadavg") == 0)
func = S_loadavg;
+ else if (strcmp(fmt, "S,vmtotal") == 0)
+ func = S_vmtotal;
else if (strcmp(fmt, "T,dev_t") == 0)
func = T_dev_t;
else
Index: sys/vm/vm_meter.c
===================================================================
RCS file: /home/ncvs/src/sys/vm/vm_meter.c,v
retrieving revision 1.66
diff -u -r1.66 vm_meter.c
--- sys/vm/vm_meter.c 2002/10/02 20:31:47 1.66
+++ sys/vm/vm_meter.c 2002/12/08 14:59:01
@@ -222,7 +222,7 @@
return(error);
}
-SYSCTL_PROC(_vm, VM_METER, vmmeter, CTLTYPE_OPAQUE|CTLFLAG_RD,
+SYSCTL_PROC(_vm, VM_TOTAL, vmtotal, CTLTYPE_OPAQUE|CTLFLAG_RD,
0, sizeof(struct vmtotal), vmtotal, "S,vmtotal",
"System virtual memory statistics");
SYSCTL_NODE(_vm, OID_AUTO, stats, CTLFLAG_RW, 0, "VM meter stats");
Index: sys/vm/vm_param.h
===================================================================
RCS file: /home/ncvs/src/sys/vm/vm_param.h,v
retrieving revision 1.15
diff -u -r1.15 vm_param.h
--- sys/vm/vm_param.h 2001/10/10 23:06:54 1.15
+++ sys/vm/vm_param.h 2002/12/08 14:59:02
@@ -76,7 +76,7 @@
/*
* CTL_VM identifiers
*/
-#define VM_METER 1 /* struct vmmeter */
+#define VM_TOTAL 1 /* struct vmtotal */
#define VM_LOADAVG 2 /* struct loadavg */
#define VM_V_FREE_MIN 3 /* cnt.v_free_min */
#define VM_V_FREE_TARGET 4 /* cnt.v_free_target */
@@ -91,7 +91,7 @@
#define CTL_VM_NAMES { \
{ 0, 0 }, \
- { "vmmeter", CTLTYPE_STRUCT }, \
+ { "vmtotal", CTLTYPE_STRUCT }, \
{ "loadavg", CTLTYPE_STRUCT }, \
{ "v_free_min", CTLTYPE_INT }, \
{ "v_free_target", CTLTYPE_INT }, \
Index: usr.bin/systat/vmstat.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/systat/vmstat.c,v
retrieving revision 1.52
diff -u -r1.52 vmstat.c
--- usr.bin/systat/vmstat.c 2002/06/06 23:01:50 1.52
+++ usr.bin/systat/vmstat.c 2002/12/08 14:59:05
@@ -784,7 +784,7 @@
size = sizeof(ls->Total);
mib[0] = CTL_VM;
- mib[1] = VM_METER;
+ mib[1] = VM_TOTAL;
if (sysctl(mib, 2, &ls->Total, &size, NULL, 0) < 0) {
error("Can't get kernel info: %s\n", strerror(errno));
bzero(&ls->Total, sizeof(ls->Total));
Index: usr.bin/vmstat/vmstat.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/vmstat/vmstat.c,v
retrieving revision 1.59
diff -u -r1.59 vmstat.c
--- usr.bin/vmstat/vmstat.c 2002/08/09 15:47:43 1.59
+++ usr.bin/vmstat/vmstat.c 2002/12/08 14:59:07
@@ -472,7 +472,7 @@
kread(X_SUM, &sum, sizeof(sum));
size = sizeof(total);
mib[0] = CTL_VM;
- mib[1] = VM_METER;
+ mib[1] = VM_TOTAL;
if (sysctl(mib, 2, &total, &size, NULL, 0) < 0) {
(void)printf("Can't get kerninfo: %s\n",
strerror(errno));