Operating System - HP-UX
1820227 Members
3749 Online
109620 Solutions
New Discussion юеВ

Re: Getting swap space size by coding

 
yck
Advisor

Getting swap space size by coding

Hi all,

I need help in getting swap info. Is that possible to get swap space size in runtime by using C/C++ coding? If yes, how to do it?

Thanks.

- ck
ck
2 REPLIES 2
A. Clay Stephenson
Acclaimed Contributor

Re: Getting swap space size by coding

Sure:

Plan A. Use the pstat_getswap() system call. Man pstat for details.

Plan B.
FILE *p;

p = popen("swapinfo","r");

If it ain't broke, I can fix that.
yck
Advisor

Re: Getting swap space size by coding

Hi,

As plan B, swapinfo command only can be used as a root user and how do my application able to do it?

And for plan A, i trying to refer to man pstat but really no idea how to use the command you suggested?

For your information, I only need to get fixed value of swap space size. Means that I want value of total swap space size in local machine.

Thanks.

-ck
ck