diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c index b712a2660453..5dc53a333361 100644 --- a/sbin/sysctl/sysctl.c +++ b/sbin/sysctl/sysctl.c @@ -54,6 +54,7 @@ static const char rcsid[] = #include #include #include +#include #include #include @@ -322,6 +323,29 @@ S_timeval(int l2, void *p) return (0); } +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) { @@ -587,6 +611,8 @@ show_var(int *oid, int nlen) 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 diff --git a/sys/vm/vm_meter.c b/sys/vm/vm_meter.c index cc50d7f84aa1..ae7850a54e37 100644 --- a/sys/vm/vm_meter.c +++ b/sys/vm/vm_meter.c @@ -237,7 +237,7 @@ vcnt(SYSCTL_HANDLER_ARGS) 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"); diff --git a/sys/vm/vm_param.h b/sys/vm/vm_param.h index 795157fd8a24..959b35c8c8d9 100644 --- a/sys/vm/vm_param.h +++ b/sys/vm/vm_param.h @@ -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 }, \ diff --git a/usr.bin/systat/vmstat.c b/usr.bin/systat/vmstat.c index 8f8f86800252..4697bc506cf2 100644 --- a/usr.bin/systat/vmstat.c +++ b/usr.bin/systat/vmstat.c @@ -784,7 +784,7 @@ getinfo(ls) 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)); diff --git a/usr.bin/vmstat/vmstat.c b/usr.bin/vmstat/vmstat.c index 54c51ed09882..c67ca6189dc7 100644 --- a/usr.bin/vmstat/vmstat.c +++ b/usr.bin/vmstat/vmstat.c @@ -472,7 +472,7 @@ dovmstat(interval, reps) 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));