dannyman.toldme.com


FreeBSD, Technical

FAQ: How do you measure swap utilization in FreeBSD?

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@mito ~> swapinfo
Device          1K-blocks     Used    Avail Capacity
/dev/ad0s1b       1022224        0  1022224     0%
0-13:38 djh@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@mito ~> swapctl -lsk
Device:       1024-blocks      Used:
/dev/ad0s1b      1022224          0
Total:           1022224          0

Read More

Next:
Previous:
Categories: FreeBSD, Technical
Possibly-Related Posts

Comment

Leave a comment . . .

Tiny Print:

  1. For private messages, e-mail me: dannyman@toldme.com.
  2. You must provide an e-mail address.
  3. You can use a bogus e-mail address, but I like to know who you are.
  4. I will not spam you. I will not publish or share your e-mail address.
  5. First-time commenters will be held for review.
  6. You can use these HTML tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>