Hi Guys,
How can we find the free swap memory for HP-UX 11*? For
Linux/Solaris I use vmstat and look for the value under swap, which
gives me the amount of free memory in KB's. Here I see a column
called avm, but I dont know how would that help to figure out the free
swap memory. Any help is appreciated.
Thanks!
|
|
0
|
|
|
|
Reply
|
sunjit
|
10/7/2004 10:38:10 AM |
|
> How can we find the free swap memory for HP-UX 11*? For
swapinfo -tam
|
|
0
|
|
|
|
Reply
|
nissan350z
|
10/7/2004 12:09:57 PM
|
|
"nissan350z" <ota1998@hotmail.com> wrote in message news:<4165365f$0$24602$ba620e4c@news.skynet.be>...
> > How can we find the free swap memory for HP-UX 11*? For
> swapinfo -tam
Thanks, I tried that but I guess the system doesnt have swapinfo
binary installed
$ uname -a
HP-UX cairo B.11.11 U 9000/785 2005933311 unlimited-user license
$ ./swapinfo -tam
-bash: ./swapinfo: No such file or directory
Iam basically looking for some command that is present by default in
HP-UX, example some systems dont have top and have to instal it, but
vmstat is something is present by default. Something like vmstat which
gives the free swap memory?
|
|
0
|
|
|
|
Reply
|
sunjit
|
10/7/2004 9:35:44 PM
|
|
In article <8e100ffa.0410071335.6c762a65@posting.google.com>, Sunjit wrote:
> "nissan350z" <ota1998@hotmail.com> wrote in message news:<4165365f$0$24602$ba620e4c@news.skynet.be>...
>> > How can we find the free swap memory for HP-UX 11*? For
>> swapinfo -tam
>
> Thanks, I tried that but I guess the system doesnt have swapinfo
> binary installed
>
> $ uname -a
> HP-UX cairo B.11.11 U 9000/785 2005933311 unlimited-user license
>
> $ ./swapinfo -tam
> -bash: ./swapinfo: No such file or directory
First off, why are you running "./swapinfo", and why would you expect that to
exist unless your were in /usr/sbin? Second, you need to run it as root. Third,
it is provedid by the OS on all versions of HP-UX.
Try:
# /usr/sbin/swapinfo -mt
>
> Iam basically looking for some command that is present by default in
> HP-UX, example some systems dont have top and have to instal it, but
> vmstat is something is present by default. Something like vmstat which
> gives the free swap memory?
Kevin
|
|
0
|
|
|
|
Reply
|
spamtotrash
|
10/7/2004 9:49:10 PM
|
|
spamtotrash@toomuchfiction.com (Kevin Collins) wrote in message news:<slrncmbeej.1tt.spamtotrash@doom.unix-guy.com>...
> In article <8e100ffa.0410071335.6c762a65@posting.google.com>, Sunjit wrote:
> > "nissan350z" <ota1998@hotmail.com> wrote in message news:<4165365f$0$24602$ba620e4c@news.skynet.be>...
> >> > How can we find the free swap memory for HP-UX 11*? For
> >> swapinfo -tam
> >
> > Thanks, I tried that but I guess the system doesnt have swapinfo
> > binary installed
> >
> > $ uname -a
> > HP-UX cairo B.11.11 U 9000/785 2005933311 unlimited-user license
> >
> > $ ./swapinfo -tam
> > -bash: ./swapinfo: No such file or directory
>
> First off, why are you running "./swapinfo", and why would you expect that to
> exist unless your were in /usr/sbin? Second, you need to run it as root. Third,
> it is provedid by the OS on all versions of HP-UX.
>
> Try:
>
> # /usr/sbin/swapinfo -mt
>
> >
> > Iam basically looking for some command that is present by default in
> > HP-UX, example some systems dont have top and have to instal it, but
> > vmstat is something is present by default. Something like vmstat which
> > gives the free swap memory?
>
> Kevin
My bad, swapinfo is indeed present at /usr/sbin. And you are right
that I need to be root to run that. Which might be a problem, cause
Iam writing a application(in java) which calculates the free swap
memory and it having root permissions would not help :-/ , any other
way to do it? I have tried on all other unix platforms like
Solaris/Linux and even AIX and none of those require root permissions
for their respective command to get the free swap memory.
Thanks.
|
|
0
|
|
|
|
Reply
|
sunjit
|
10/8/2004 3:00:44 PM
|
|
Sunjit wrote:
> My bad, swapinfo is indeed present at /usr/sbin. And you are right
> that I need to be root to run that. Which might be a problem, cause
> Iam writing a application(in java) which calculates the free swap
> memory and it having root permissions would not help :-/ , any other
> way to do it? I have tried on all other unix platforms like
> Solaris/Linux and even AIX and none of those require root permissions
> for their respective command to get the free swap memory.
>
> Thanks.
man pstat_getvminfo
[Note the fields in the pst_vminfo structure:
psv_swapspc_cnt, psv_swapspc_max, psv_swapmem_cnt,
psv_swapmem_max].
Granted -- I'm not sure how easy/hard it is to encapsulate C code
in Java (been a while since I programmed in Java) -- but at the
least you could code this in C and call it as an external program
from Java:
#include <stdio.h>
#include <unistd.h>
#include <sys/mman.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/param.h>
#include <sys/pstat.h>
int
main(int argc, char *argv[])
{
int error;
struct pst_vminfo pvmi;
size_t sys_page_size;
sys_page_size = sysconf(_SC_PAGE_SIZE);
error = pstat_getvminfo(&pvmi, sizeof(struct pst_vminfo), 1, 0);
if ( error == -1 ) {
perror("pstat_getvminfo: ");
exit(1);
}
if ( error != 1 ) {
fprintf(stderr, "pstat_getvminfo success but %d elements.\n",
error);
exit(error);
}
printf("Device/FS Swap: %ld kb Total, %ld kb Free.\n",
(((size_t)pvmi.psv_swapspc_max * sys_page_size) / (size_t)1024),
((size_t)pvmi.psv_swapspc_cnt * sys_page_size) / (size_t)1024);
printf("Memory Swap: %ld kb Total, %ld kb Free.\n",
((size_t)pvmi.psv_swapmem_max * sys_page_size) / (size_t)1024,
((size_t)pvmi.psv_swapmem_cnt * sys_page_size) / (size_t)1024);
exit(0);
}
You'll want to compile this (using the cc compiler) as:
cc +DD64 -o swap_report swap_report.c
I had overflow errors with +DD32 -D_PSTAT64 that I just
wasn't willing to spend the time to track down... if you're
on a pure 32-bit machine, just use +DD32 obviously.
You may also want to consider using getrlimit() if you're
checking swap availability as a prelude to making large
allocations... you could hit the RLIM_DATA / RLIM_STACK
type limits before you come close to exhausting the swap
depending on your configuration.
Don
--
kernel, n:
A part of an operating system that preserves the medieval traditions
of sorcery and black art.
|
|
0
|
|
|
|
Reply
|
Don
|
10/8/2004 5:26:12 PM
|
|
Don Morris <don.morris@hp.com> wrote in message news:<U4A9d.412$DB7.33@news.cpqcorp.net>...
> Sunjit wrote:
> > My bad, swapinfo is indeed present at /usr/sbin. And you are right
> > that I need to be root to run that. Which might be a problem, cause
> > Iam writing a application(in java) which calculates the free swap
> > memory and it having root permissions would not help :-/ , any other
> > way to do it? I have tried on all other unix platforms like
> > Solaris/Linux and even AIX and none of those require root permissions
> > for their respective command to get the free swap memory.
> >
> > Thanks.
>
> man pstat_getvminfo
>
> [Note the fields in the pst_vminfo structure:
> psv_swapspc_cnt, psv_swapspc_max, psv_swapmem_cnt,
> psv_swapmem_max].
>
> Granted -- I'm not sure how easy/hard it is to encapsulate C code
> in Java (been a while since I programmed in Java) -- but at the
> least you could code this in C and call it as an external program
> from Java:
>
> #include <stdio.h>
> #include <unistd.h>
> #include <sys/mman.h>
> #include <errno.h>
> #include <fcntl.h>
> #include <sys/param.h>
> #include <sys/pstat.h>
>
> int
> main(int argc, char *argv[])
> {
> int error;
> struct pst_vminfo pvmi;
> size_t sys_page_size;
>
> sys_page_size = sysconf(_SC_PAGE_SIZE);
>
> error = pstat_getvminfo(&pvmi, sizeof(struct pst_vminfo), 1, 0);
>
> if ( error == -1 ) {
> perror("pstat_getvminfo: ");
> exit(1);
> }
>
> if ( error != 1 ) {
> fprintf(stderr, "pstat_getvminfo success but %d elements.\n",
> error);
> exit(error);
> }
>
> printf("Device/FS Swap: %ld kb Total, %ld kb Free.\n",
> (((size_t)pvmi.psv_swapspc_max * sys_page_size) / (size_t)1024),
> ((size_t)pvmi.psv_swapspc_cnt * sys_page_size) / (size_t)1024);
>
> printf("Memory Swap: %ld kb Total, %ld kb Free.\n",
> ((size_t)pvmi.psv_swapmem_max * sys_page_size) / (size_t)1024,
> ((size_t)pvmi.psv_swapmem_cnt * sys_page_size) / (size_t)1024);
>
> exit(0);
> }
>
> You'll want to compile this (using the cc compiler) as:
> cc +DD64 -o swap_report swap_report.c
>
> I had overflow errors with +DD32 -D_PSTAT64 that I just
> wasn't willing to spend the time to track down... if you're
> on a pure 32-bit machine, just use +DD32 obviously.
>
> You may also want to consider using getrlimit() if you're
> checking swap availability as a prelude to making large
> allocations... you could hit the RLIM_DATA / RLIM_STACK
> type limits before you come close to exhausting the swap
> depending on your configuration.
>
> Don
Thanks for the info, I will try it out.
|
|
0
|
|
|
|
Reply
|
sunjit
|
10/12/2004 2:29:46 AM
|
|
|
6 Replies
500 Views
(page loaded in 0.096 seconds)
|