aboutsummaryrefslogtreecommitdiffstats
path: root/sysutils/xperfmon3/files
diff options
context:
space:
mode:
authorgj <gj@FreeBSD.org>1999-01-26 06:10:30 +0800
committergj <gj@FreeBSD.org>1999-01-26 06:10:30 +0800
commit5d2922a8a8258fbf2e94b447e4b5e48801cd420b (patch)
tree693128a46f4d7bc7f7d867f9300154c3bcd73559 /sysutils/xperfmon3/files
parent71a78a7667f4094d16a73dc2594c399d6b1ac3a1 (diff)
downloadfreebsd-ports-gnome-5d2922a8a8258fbf2e94b447e4b5e48801cd420b.tar.gz
freebsd-ports-gnome-5d2922a8a8258fbf2e94b447e4b5e48801cd420b.tar.zst
freebsd-ports-gnome-5d2922a8a8258fbf2e94b447e4b5e48801cd420b.zip
Update to use kvm_getswapinfo for 4.0-current.
Reviewed by: the maintainer
Diffstat (limited to 'sysutils/xperfmon3/files')
-rw-r--r--sysutils/xperfmon3/files/freebsd_system.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/sysutils/xperfmon3/files/freebsd_system.c b/sysutils/xperfmon3/files/freebsd_system.c
index 5857146a2a56..d20ec2c08751 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