Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!wuarchive!udel!haven!decuac!bacchus.pa.dec.com!mogul From: mogul@wrl.dec.com (Jeffrey Mogul) Newsgroups: comp.unix.ultrix Subject: Re: how do you write a program to determine free swap (like pstat -s) Message-ID: <1990Nov7.015529.15623@wrl.dec.com> Date: 7 Nov 90 01:55:29 GMT References: <1990Nov6.033516.18772@NCoast.ORG> Sender: news@wrl.dec.com (News) Organization: DEC Western Research Lines: 19 In article <1990Nov6.033516.18772@NCoast.ORG> simpsong@NCoast.ORG (Gregory R. Simpson @ The North Coast) writes: >I'd like to write a simple vm_check program that returns >nothing except the amount of swap remaining... (which is >all I'm interested in... As you might have guessed from the output of /etc/pstat -s, there isn't simple value stored in the kernel that says "this much swap space is in use"; rather, pstat grovels through kernel data structures counting things up, and computes a total through a fairly hairy computation. I counted over 160 lines in pstat just to do what you're asking for. Since the Ultrix version of pstat.c carries the usual Digital/AT&T copyright, I can't post that on the net. If you get a 4.2BSD source tape, I suspect that the code to do this calculation hasn't changed all that much, so perhaps starting with that version of pstat.c, you can create a program to do what you want. -Jeff