From owner-freebsd-questions@FreeBSD.ORG Mon Apr 4 20:53:06 2005 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CD03E16A4CE for ; Mon, 4 Apr 2005 20:53:06 +0000 (GMT) Received: from shiva.nextrials.com (shiva.nextrials.com [64.81.74.145]) by mx1.FreeBSD.org (Postfix) with ESMTP id 59FC043D45 for ; Mon, 4 Apr 2005 20:53:06 +0000 (GMT) (envelope-from dannyman@toldme.com) Received: from [192.168.1.102] (mito.sr.nextrials.com [192.168.1.102]) by shiva.nextrials.com (Postfix) with ESMTP id CC9513C2826; Mon, 4 Apr 2005 13:53:05 -0700 (PDT) Message-ID: <4251A92A.7020202@toldme.com> Date: Mon, 04 Apr 2005 13:52:58 -0700 From: Danny Howard User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050328) X-Accept-Language: en-us, en MIME-Version: 1.0 To: freebsd-questions@freebsd.org, freebsd-hackers@freeebsd.org Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: FAQ: How to Measure Swap in FreeBSD X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Apr 2005 20:53:06 -0000 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@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 Now, perhaps the next poor soul to Google this topic may get a slightly better answer. :) Thanks, -danny -- http://dannyman.toldme.com/