aboutsummaryrefslogtreecommitdiff
path: root/sysutils/xperfmon
diff options
context:
space:
mode:
authorGary Jennejohn <gj@FreeBSD.org>1999-01-25 22:10:30 +0000
committerGary Jennejohn <gj@FreeBSD.org>1999-01-25 22:10:30 +0000
commitb0f9942875a65db91c740afe71292ae21a140612 (patch)
treef503374364c6b053fa8f29dc1e086379a6e42e53 /sysutils/xperfmon
parent4023be545c9e85adbd61d05674934a0fe355551d (diff)
downloadports-b0f9942875a65db91c740afe71292ae21a140612.tar.gz
ports-b0f9942875a65db91c740afe71292ae21a140612.zip
Notes
Diffstat (limited to 'sysutils/xperfmon')
-rw-r--r--sysutils/xperfmon/files/freebsd_system.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/sysutils/xperfmon/files/freebsd_system.c b/sysutils/xperfmon/files/freebsd_system.c
index 5857146a2a56..d20ec2c08751 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