Obtain Memory on HP UNIX

Hi,

Does anyone know an easy way of getting the memory usage on a UNIX box? I basically want to find the total % available/in use. Running vmstat gives me 'avm' and 'free' but come in bytes and not percents. Didn't see a switch in sar that just gave me the memory stats similar to Sun's -r command.

Oh, and I need it to come one one line (like sar or vmstat).

Cheers,
J

Currently, we are looking for something that does exactly what you say... :wink:

If you find something or i ... please be in touch. Regards.

Hi,

Have not found anything. Any luck on your side?

J

Glance PLUS is going to do what you need, but you'll have to pay for it depending of the version of HP-UX you have. I know that it comes with the Enterprise OE version of HP-UX but you have to buy a pack for Foundation OE version.


 GlancePlus C.03.85.00          09:51:39     xxxx     ia64    Current  Avg  High
--------------------------------------44----------------------------------------
CPU  Util   SSSSSSUUUUUU                                       | 24%   24%   24%
Disk Util   FFFFFFFFFFF                                        | 21%   23%   24%
Mem  Util   SSSSSSSSSSSSFFFFSSSSSSSSSSSSSSSSSSUUUUUUUUUUBBB    | 32%   21%   32%
Swap Util   UUUUUUUUUUUUUUUUUUUURRRRRRRR                       | 54%   54%   54%
--------------------------------------------------------------------------------
                                  PROCESS LIST                      Users=  312
                              User      CPU Util     Cum     Disk           Thd
Process Name   PID   PPID Pri Name   (  400% max)    CPU   IO Rate    RSS   Cnt
--------------------------------------------------------------------------------
xxxxxxx       8449      1 168 xxxx     42.2/21.7  7489.5  0.2/ 0.0   1.2mb    1
xx           26306  25776 198 xxxx     18.7/19.9  6877.4  0.0/99.0   1.9mb    1
xxxxxxx       8306      1 185 xxxx      1.8/19.9  6879.1  343/99.2   1.2mb    1
xx           24642  24641 148 xxxx      1.5/ 0.8    37.0  229/14.3   2.3mb    1
xx xx        15611  15610 154 xxxx      1.1/ 0.0     1.5  8.7/ 0.3   2.1mb    1
xxxxxxxx      1876      1 -16 xxxx      0.8/ 0.4  9881.3  0.0/ 0.0  22.3mb    2
xx            8066   8065 154 xxxx      0.6/ 0.0     0.6  6.8/ 0.1   2.7mb    1
xx            9621   9620 154 xxxx      0.6/ 0.0     2.7  8.7/ 0.2   3.7mb    1
xxxxxxxx      3742   3739 154 xxxx      0.4/ 0.1     0.3  3.4/ 0.0  21.8mb    2
xx            8332   8331 154 xxxx      0.4/ 0.2     3.7  2.1/ 0.8   3.5mb    1
xx           26653  26651 154 xxxx      0.4/ 0.0     1.2  7.6/ 0.1   5.0mb    1
xxxx         17820  17819 148 xxxx       0.2/ 0.5 11723.1 38.5/ 0.4   3.1mb   71
xxxxx           53      0 134 xxxx       0.0/ 4.3  100794 15.8/30.4  11.4mb   46
                                          0               9.5                 2

PxT pioneered a technique involving invoking pstat from perl. I have been studying the technique in preparation for a script I plan to write. I have tried to write a script to solve your requirement. I may have succeeded. I have only tested it on one system. The total physical memory matches what I from cstm. Free memory matches what I get from vmstat. And the percentages match what I get from glance. So it may be working. But no guarantees. :smiley:

#!/usr/contrib/bin/perl

local($PSTAT, $PSTAT_STATIC, $PSTAT_DYNAMIC) = (239, 2, 3);
local($struct_pst) = ("\0" x 156);
local($struct_psd) = ("\0" x 2904);

syscall($PSTAT, $PSTAT_STATIC, $struct_pst, length($struct_pst), 1, 0);
($pages, $psize) = (unpack("x16LL", $struct_pst));
syscall($PSTAT, $PSTAT_DYNAMIC, $struct_psd, length($struct_psd), 1, 0);
$free = unpack("x64L", $struct_psd);
$mb = ($psize / 1024) * $pages;
$mb = $mb / 1024;
print "Physical Memory: ",$mb,"MB\n";
print "Free Pages: ", $free, "\n";
$pcfree = 100. * $free /$pages;
$pcused = 100. - $pcfree;
printf(" %0.2f%% free          %0.2f%% used \n", $pcfree, $pcused);
exit 0;