summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordillon <dillon@FreeBSD.org>2003-01-11 07:29:47 +0000
committerdillon <dillon@FreeBSD.org>2003-01-11 07:29:47 +0000
commit187e654d9ab8b270eb7ce255f4014e7a97b9298b (patch)
tree47505a9e9b6fcfb7c6793719d09dfa37ab8058f9
parente2486fdf1adabf06e18a78b19875589848ad3649 (diff)
downloadFreeBSD-src-187e654d9ab8b270eb7ce255f4014e7a97b9298b.zip
FreeBSD-src-187e654d9ab8b270eb7ce255f4014e7a97b9298b.tar.gz
Make 'sysctl vm.vmtotal' work properly using updated patch from Hiten.
(the patch in the PR was stale). PR: kern/5689 Submitted by: Hiten Pandya <hiten@unixdaemons.com>
-rw-r--r--sbin/sysctl/sysctl.c26
-rw-r--r--sys/vm/vm_meter.c2
-rw-r--r--sys/vm/vm_param.h4
-rw-r--r--usr.bin/systat/vmstat.c2
-rw-r--r--usr.bin/vmstat/vmstat.c2
5 files changed, 31 insertions, 5 deletions
diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c
index b712a26..5dc53a3 100644
--- a/sbin/sysctl/sysctl.c
+++ b/sbin/sysctl/sysctl.c
@@ -54,6 +54,7 @@ static const char rcsid[] =
#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 @@ S_timeval(int l2, void *p)
}
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 @@ 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 cc50d7f..ae7850a 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 795157f..959b35c 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 8f8f868..4697bc5 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 54c51ed..c67ca61 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));
OpenPOWER on IntegriCloud