diff options
author | gj <gj@FreeBSD.org> | 1999-01-25 22:10:30 +0000 |
---|---|---|
committer | gj <gj@FreeBSD.org> | 1999-01-25 22:10:30 +0000 |
commit | 5d2922a8a8258fbf2e94b447e4b5e48801cd420b (patch) | |
tree | 693128a46f4d7bc7f7d867f9300154c3bcd73559 | |
parent | 71a78a7667f4094d16a73dc2594c399d6b1ac3a1 (diff) | |
download | FreeBSD-ports-5d2922a8a8258fbf2e94b447e4b5e48801cd420b.zip FreeBSD-ports-5d2922a8a8258fbf2e94b447e4b5e48801cd420b.tar.gz |
Update to use kvm_getswapinfo for 4.0-current.
Reviewed by: the maintainer
-rw-r--r-- | sysutils/xperfmon/files/freebsd_system.c | 18 | ||||
-rw-r--r-- | sysutils/xperfmon3/files/freebsd_system.c | 18 |
2 files changed, 36 insertions, 0 deletions
diff --git a/sysutils/xperfmon/files/freebsd_system.c b/sysutils/xperfmon/files/freebsd_system.c index 5857146..d20ec2c 100644 --- a/sysutils/xperfmon/files/freebsd_system.c +++ b/sysutils/xperfmon/files/freebsd_system.c @@ -214,6 +214,7 @@ struct nlist nl[] = { { "_intrcnt" }, #define X_EINTRCNT 7 { "_eintrcnt" }, +#if __FreeBSD_version < 400000 #define VM_NSWAP 8 { "_nswap" }, /* size of largest swap device */ #define VM_NSWDEV 9 @@ -224,6 +225,7 @@ struct nlist nl[] = { { "_swaplist" },/* list of free swap areas */ #define VM_SWDEVT 12 { "_swdevt" }, /* list of swap devices and sizes */ +#endif { "" }, }; @@ -606,6 +608,21 @@ kread(nlx, addr, size) int get_swapspace() { +#if __FreeBSD_version >= 400000 + /* based on swapmode from /usr/src/usr.bin/top/machine.c */ + int n; + int percentfree; + struct kvm_swap swapary[1]; + + n = kvm_getswapinfo(kd, swapary, 1, 0); + if (n < 0) + return(0); + + percentfree = (int)((((double)swapary[0].ksw_total - + (double)swapary[0].ksw_used) * 100.0) / + (double)swapary[0].ksw_total); + return(percentfree); +#else char *header; int hlen, nswap, nswdev, dmmax; int i, div, avail, nfree, npfree, used; @@ -707,6 +724,7 @@ get_swapspace() free(perdev); free(sw); return((100*nfree)/avail); /* return free swap in percent */ +#endif /* __FreeBSD_version >= 400000 */ } #ifdef HAVE_DEVSTAT diff --git a/sysutils/xperfmon3/files/freebsd_system.c b/sysutils/xperfmon3/files/freebsd_system.c index 5857146..d20ec2c 100644 --- a/sysutils/xperfmon3/files/freebsd_system.c +++ b/sysutils/xperfmon3/files/freebsd_system.c @@ -214,6 +214,7 @@ struct nlist nl[] = { { "_intrcnt" }, #define X_EINTRCNT 7 { "_eintrcnt" }, +#if __FreeBSD_version < 400000 #define VM_NSWAP 8 { "_nswap" }, /* size of largest swap device */ #define VM_NSWDEV 9 @@ -224,6 +225,7 @@ struct nlist nl[] = { { "_swaplist" },/* list of free swap areas */ #define VM_SWDEVT 12 { "_swdevt" }, /* list of swap devices and sizes */ +#endif { "" }, }; @@ -606,6 +608,21 @@ kread(nlx, addr, size) int get_swapspace() { +#if __FreeBSD_version >= 400000 + /* based on swapmode from /usr/src/usr.bin/top/machine.c */ + int n; + int percentfree; + struct kvm_swap swapary[1]; + + n = kvm_getswapinfo(kd, swapary, 1, 0); + if (n < 0) + return(0); + + percentfree = (int)((((double)swapary[0].ksw_total - + (double)swapary[0].ksw_used) * 100.0) / + (double)swapary[0].ksw_total); + return(percentfree); +#else char *header; int hlen, nswap, nswdev, dmmax; int i, div, avail, nfree, npfree, used; @@ -707,6 +724,7 @@ get_swapspace() free(perdev); free(sw); return((100*nfree)/avail); /* return free swap in percent */ +#endif /* __FreeBSD_version >= 400000 */ } #ifdef HAVE_DEVSTAT |