diff options
| author | mrg <mrg@NetBSD.org> | 1998-02-07 12:04:37 +0000 |
|---|---|---|
| committer | mrg <mrg@NetBSD.org> | 1998-02-07 12:04:37 +0000 |
| commit | f1d37094a53b983665b539b10e37b62e2eb8ecf2 (patch) | |
| tree | 784f927aa5d4e9b4bf464911838dd2bef91dd151 /libexec | |
| parent | e9fbc9f83bf2ba7cb2368ad2f735820ac80dc8f4 (diff) | |
make this work in the -DUVM case.
Diffstat (limited to 'libexec')
| -rw-r--r-- | libexec/rpc.rstatd/rstat_proc.c | 62 |
1 files changed, 51 insertions, 11 deletions
diff --git a/libexec/rpc.rstatd/rstat_proc.c b/libexec/rpc.rstatd/rstat_proc.c index 4ef4abf0d62..509f86af28d 100644 --- a/libexec/rpc.rstatd/rstat_proc.c +++ b/libexec/rpc.rstatd/rstat_proc.c @@ -1,4 +1,4 @@ -/* $NetBSD: rstat_proc.c,v 1.20 1997/10/07 11:28:18 mrg Exp $ */ +/* $NetBSD: rstat_proc.c,v 1.21 1998/02/07 12:04:37 mrg Exp $ */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for @@ -35,7 +35,7 @@ static char sccsid[] = "from: @(#)rpc.rstatd.c 1.1 86/09/25 Copyr 1984 Sun Micro"; static char sccsid[] = "from: @(#)rstat_proc.c 2.2 88/08/01 4.0 RPCSRC"; #else -__RCSID("$NetBSD: rstat_proc.c,v 1.20 1997/10/07 11:28:18 mrg Exp $"); +__RCSID("$NetBSD: rstat_proc.c,v 1.21 1998/02/07 12:04:37 mrg Exp $"); #endif #endif @@ -45,6 +45,10 @@ __RCSID("$NetBSD: rstat_proc.c,v 1.20 1997/10/07 11:28:18 mrg Exp $"); * Copyright (c) 1984 by Sun Microsystems, Inc. */ +#include <sys/param.h> +#include <sys/errno.h> +#include <sys/socket.h> + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -52,21 +56,33 @@ __RCSID("$NetBSD: rstat_proc.c,v 1.20 1997/10/07 11:28:18 mrg Exp $"); #include <fcntl.h> #include <kvm.h> #include <limits.h> -#include <rpc/rpc.h> -#include <sys/socket.h> #include <nlist.h> #include <syslog.h> -#include <sys/errno.h> -#include <sys/param.h> #ifdef BSD +#if defined(UVM) +#include <sys/sysctl.h> +#include <vm/vm.h> +#include <uvm/uvm_extern.h> +#else #include <sys/vmmeter.h> +#endif #include <sys/dkstat.h> #include "dkstats.h" #else #include <sys/dk.h> #endif + #include <net/if.h> +/* + * XXX + * + * this is a huge hack to stop `struct pmap' being + * defined twice! + */ +#define _RPC_PMAPPROT_H +#include <rpc/rpc.h> + #undef FSHIFT /* Use protocol's shift and scale values */ #undef FSCALE #undef DK_NDRIVE @@ -84,12 +100,14 @@ int cp_xlat[CPUSTATES] = { CP_USER, CP_NICE, CP_SYS, CP_IDLE }; #endif struct nlist nl[] = { -#define X_CNT 0 - { "_cnt" }, -#define X_IFNET 1 +#define X_IFNET 0 { "_ifnet" }, -#define X_BOOTTIME 2 +#define X_BOOTTIME 1 { "_boottime" }, +#if !defined(UVM) +#define X_CNT 2 + { "_cnt" }, +#endif { NULL }, }; @@ -209,7 +227,13 @@ updatestat(dummy) { long off; int i; +#if defined(UVM) + struct uvmexp uvmexp; + size_t len; + int mib[2]; +#else struct vmmeter cnt; +#endif struct ifnet ifnet; double avrun[3]; struct timeval tm, btm; @@ -272,6 +296,21 @@ updatestat(dummy) stats_all.s3.cp_time[1], stats_all.s3.cp_time[2], stats_all.s3.cp_time[3]); #endif +#if defined(UVM) + mib[0] = CTL_VM; + mib[1] = VM_UVMEXP; + len = sizeof(uvmexp); + if (sysctl(mib, 2, &uvmexp, &len, NULL, 0) < 0) { + syslog(LOG_ERR, "can't sysctl vm.uvmexp"); + exit(1); + } + stats_all.s3.v_pgpgin = uvmexp.fltanget; + stats_all.s3.v_pgpgout = uvmexp.pdpageouts; + stats_all.s3.v_pswpin = uvmexp.swapins; + stats_all.s3.v_pswpout = uvmexp.swapouts; + stats_all.s3.v_intr = uvmexp.intrs; + stats_all.s3.v_swtch = uvmexp.swtch; +#else if (kvm_read(kfd, (long)nl[X_CNT].n_value, (char *)&cnt, sizeof cnt) != sizeof cnt) { syslog(LOG_ERR, "can't read cnt from kmem"); @@ -282,10 +321,11 @@ updatestat(dummy) stats_all.s3.v_pswpin = cnt.v_pswpin; stats_all.s3.v_pswpout = cnt.v_pswpout; stats_all.s3.v_intr = cnt.v_intr; + stats_all.s3.v_swtch = cnt.v_swtch; +#endif gettimeofday(&tm, (struct timezone *) 0); stats_all.s3.v_intr -= hz*(tm.tv_sec - btm.tv_sec) + hz*(tm.tv_usec - btm.tv_usec)/1000000; - stats_all.s3.v_swtch = cnt.v_swtch; stats_all.s3.if_ipackets = 0; stats_all.s3.if_opackets = 0; |
