FAQ: How to Measure Swap in FreeBSD
Danny Howard
dannyman at toldme.com
Mon Apr 4 13:53:06 PDT 2005
Hello,
I tried to get an answer to this question last year but failed.
Today, I think I have it.
Q: How do you measure swap utilization in FreeBSD? (Assuming you are
writing a script to gather performance metrics.)
A: If you are writing a C program, check kvm_getswapinfo(3) and maybe
take a gander at the bottom of /usr/src/usr.bin/top/machine.c.
A: If you are writing a Perl script:
Measure swap activity:
sysctl vm.stats.vm.v_swapin vm.stats.vm.v_swapout
vm.stats.vm.v_swappgsin vm.stats.vm.v_swappgsout
(I believe these results are COUNTER type values, like you get from
netstat -inb. You could establish "swap activity" by plotting changes
in this value.)
Measure swap size:
0-13:38 djh at mito ~> swapinfo
Device 1K-blocks Used Avail Capacity
/dev/ad0s1b 1022224 0 1022224 0%
0-13:38 djh at mito ~> swapctl -l
Device: 1024-blocks Used:
/dev/ad0s1b 1022224 0
If you are trying to accomodate n+1 swap devices, try this:
0-13:44 djh at mito ~> swapctl -lsk
Device: 1024-blocks Used:
/dev/ad0s1b 1022224 0
Total: 1022224 0
Now, perhaps the next poor soul to Google this topic may get a slightly
better answer. :)
Thanks,
-danny
--
http://dannyman.toldme.com/
More information about the freebsd-questions
mailing list