How to find the used memory in HP-UX?

Hi all,

Can any please provide how to calculate the cpu and memory usage of HP-UX server.

Thanks in advance.

You should have tried this:

calculate the cpu and memory usage of HP-UX server

1 Like

Here's a better way:- Better way to look for things

1 Like

Certainly your way is more instructive... :cool:

1 Like

My 2 cents to the above:
I did a lot of scripts in earlier days to calculate e.g. the memory - total per process or the biggest hog etc...
In HP-UX what works in 10.20 did not in 11.00 what worked in11.11 I have no idea in 11.3X

So asking such questions without giving your version and I forgot - Platform are irrelevant to me and show serious lack of knowledge, making me unwilling to show how to look through the kernel...

PS: Used/Free memory in a VM system is pretty meaningless. Once a system goes quiescent, the free memory just represents recent proceess terminations, which make a bunch of free pages. Pages may be used for old mmap(), perhaps by ld() the dynamic linker, and remain mapped in speculation of future use. If there is demand for free memory, and they are not modified, then they can be repurposed immediately, but the memory is in use, used. Whe a process exits, the RAM used for stack and heap are returned to the free memory pool, awaiting use by the nest consumer.

It is more useful to look at page writes and reads of swap per second, to determine if there is a RAM shortage. There are also many ways to tune a system for lower swap I/O, but that is very much an art, sometimes a proprietary product. If you are writing the apps, then there are also many ways to control RAM demand. Paging, in and of itself, may be the right behavior for what is going on, such as extensive interrogation of a huge database. I often see high page faults on virus scanners, as their dictionary is huge.

1 Like

A useful monitoring object is total available memory

swapinfo | awk '{total+=$2; used+=$3} END {print int(used*100/total)}'

And a warning threshold of 80 (percent usage).
This will warn before an "out of memory" situation occurs. It does not say anything about system performance.
Regarding CPU, a useful monitoring object is system load (obtained from the uptime command)

uptime | tr -d ',' | awk '
{
 v1=$(NF-2)/cores; v2=$(NF-1)/cores; v3=$NF/cores
 msg=sprintf ("- load average: %4.2f, %4.2f, %4.2f",v1,v2,v3)
}
(v1>w && v2>w && v3>w) { print "WARNING",msg; exit 1 }
{ print "OK",msg; exit 0 }
' w=1.1 cores=2

Best practice is an AND condition of (1min average, 5min average, 15min average) as done with awk,
and a threshold of 1.1 if the load is divided by the number of active virtual CPUs (here "cores" is set to 2).
Where the number of "cores" can be determined on HP-UX with

machinfo

or

top

I think in HP-UX 11.x the best command to determine the logical CPUs is

/usr/sbin/ioscan -k -C processor | grep -c '^[0-9]'
1 Like