Operating System - HP-UX
1820390 Members
3523 Online
109623 Solutions
New Discussion юеВ

How to check processes eating memory and swap resources

 
SOLVED
Go to solution
gerjam
Advisor

How to check processes eating memory and swap resources

Hi HP Gurus,

I need to know how to track down the processes loading up my RAM and swap space.

Thank you very much.
10 REPLIES 10
Shaikh Imran
Honored Contributor

Re: How to check processes eating memory and swap resources

Hi,

In short top & vmstat command will do the trick.
man top & man vmstat will give more details
than .....

Regards,

I'll sleep when i am dead.
Shaikh Imran
Honored Contributor

Re: How to check processes eating memory and swap resources

Muthukumar_5
Honored Contributor

Re: How to check processes eating memory and swap resources

You can use glance tool for this. It is very efficient to know about every information of a process.

By simply use, top to know with process informations.

glance tool will give memory, swap, etc.. informations about individual process.
Easy to suggest when don't know about the problem!
Franky_1
Respected Contributor

Re: How to check processes eating memory and swap resources

Hi,

simply use the "top" command (or glance if installed)

Regards

Franky
Don't worry be happy
Mike Patterson
Frequent Advisor
Solution

Re: How to check processes eating memory and swap resources

Here is an old script of mine that you cron every 15 min. to gather info into a log. The logic is based on basic hp-ux performance step-by-step troubleshooting methods (supplied by hp support and docs years ago). The key to finding transient performance problems is gathering info over time. Once you have this data in a log, you can see when performance problems occur (maybe when you are sleeping) and hopefully correlate it to some conditions. This script will also page (via emai) if cpu idle% is low. Please excuse the very old code, but it should still work. I hope this info is of some use...

#!/usr/bin/sh
# /usr/local/scripts/sa.perf.sh
#
# Gathers performance info, pages on cpu low - run in crontab every 15 min.
#
# EXPLANATION:
#
# HP-UX Perf. Troubleshooting Flowchart:
#
# Step 1.
#
# sar -u (or sar -Mu for multiple processors)
#
# Is the %idle low?
#
# No -> The system is not CPU bound. Goto Step 3;
# Yes -> The system is possibly either CPU, memory, or I/O bound.
# Goto Step 2;
#
# Step 2.
#
# Is %usr high? (What is normal on this system?)
#
# No -> The system may be experiencing either a CPU, memory, or
# I/O bottleneck. Goto Step 3;
# Yes -> CPU bottleneck due to user processes
# Goto Section 3, Part A, Tuning a system with CPU bottleneck
#
# Step 3.
#
# Does %wio have a value > 15?
#
# Yes -> Possible disk or tape involvement in a bottleneck. Goto Step 4;
# No -> Goto Step 4;
#
# Step 4.
#
# sar -d
#
# Is %busy for any disks >50? (or Is %busy higher than normal?)
# For same disa(s), is avwait > avserv?
#
# No -> Most likely no disk bottlenecks, go to Step 6;
# Yes -> There seems to be an I/O bottleneck on this device. Goto Step 5;
#
# Step 5.
# There is a disk bottleneck. What is on that bottlenecked disk?
#
# Raw Partitions,
# File Systems -> Use glance for more info and tune the disk problem
# Swap -> Possibly caused by a memory bottleneck. Goto Step 6;
#
# Step 6.
#
# vmstat (vmstat -n 3 -> readable 80 column output, 3 samples)
#
# Over sustained periods of time, is po > 0?
# Is (free * 4k) < 2 MB,
# for a s800 system (The values 2 MB is a rough guide
#
# No -> If, in step 1, %idle was low, the system is most likely CPU
# If %idle not low, something other than cpu, memory, disk is problem.
# Yes -> There is a memory bottleneck on the system.
#
#
# BEGIN CODE:
#
umask 177
HOST=`hostname`
PERFLOG="/var/tmp/sa.hp.perf.log"
ALARM="/var/tmp/sa.hp.perm.alarm"
SALOG="/var/tmp/sa.hp.log"
PERCENT_IDLE_MIN=10
#
## This script should be run by root:

if [ x`id | grep root | awk '{print $1}'` = "x" ]; then
echo "Root privileges are required to run sa.hp.perm" >> $ALARM
exit
fi

echo "" >> $PERFLOG
echo "**************** `date` ******************" >> $PERFLOG
echo "**************** users on ****************" >> $PERFLOG
who -q >> $PERFLOG
echo "" >> $PERFLOG

# Check cpu with sar
echo "" >> $PERFLOG
echo "sar -Mu output:" >> $PERFLOG
echo "" >> $PERFLOG
sar -Mu 1 3 >> $PERFLOG

# Page someone if cpu idle is too low
PERCENT_IDLE=`sar 1 3 | tail -1 | awk '{print $5}'`
if [ $PERCENT_IDLE -lt $PERCENT_IDLE_MIN ]; then
echo "CPU on $HOST is only $PERCENT_IDLE idle" >> $ALARM
fi

# Check buffers with sar
echo "" >> $PERFLOG
echo "sar -b output:" >> $PERFLOG
echo "" >> $PERFLOG
sar -b 1 3 >> $PERFLOG
# %rcache should be >= 90
# %wcache should be >= 70

# Check io with iostat
echo "" >> $PERFLOG
echo "iostat output:" >> $PERFLOG
echo "" >> $PERFLOG
iostat >> $PERFLOG

# Check disk io with sar
echo "" >> $PERFLOG
echo "sar -d output:" >> $PERFLOG
echo "" >> $PERFLOG
sar -d 1 3 >> $PERFLOG

# Check virtual memory with vmstat
echo "" >> $PERFLOG
echo "vmstat -n 1 3 output:" >> $PERFLOG
echo "" >> $PERFLOG
vmstat -n 1 3 > /tmp/vmstat.txt
echo "" >> $PERFLOG
cat /tmp/vmstat.txt >> $PERFLOG
rm /tmp/vmstat.txt

# Check top process with top
echo "" >> $PERFLOG
echo "top -d1 output:" >> $PERFLOG
echo "" >> $PERFLOG
top -d1 > /tmp/top.txt
echo "" >> $PERFLOG
cat /tmp/top.txt >> $PERFLOG
sleep 2
rm /tmp/top.txt

# Notify someone!
if [ -f $ALARM ]; then
MAILLIST=[your mail list]
mailx -s "$HOST SYSALARM" "$MAILLIST" < $ALARM
#echo `cat $ALARM`
echo "`date +'%b %d %y %H:%M'` `cat $ALARM`" >> $SALOG
rm $ALARM
Kent Ostby
Honored Contributor

Re: How to check processes eating memory and swap resources

If I have a particularly offensive process on my machine I can usually find it with:

ps -ef | cut -c42-80 | sort -nr | head

This lists the top 10 processes in terms of CPU usage and usually the bad apple stands out.

Best regards,

Kent M. Ostby
"Well, actually, she is a rocket scientist" -- Steve Martin in "Roxanne"
Geoff Wild
Honored Contributor

Re: How to check processes eating memory and swap resources

#!/bin/sh
# memtop - show top memory users and pid
# VSZ is in KB
echo "VSZ(KB) PID RUSER COMMAND"
UNIX95= ps -e -o 'vsz pid ruser args' |sort -nr|head -30


I have a cool utility from HP called kmeminfo


partial output:

Summary of processes memory usage:

List sorted by physical size, in pages/bytes:

virtual physical swap
pid ppid pages / bytes pages / bytes pages / bytes command
5037 5033 11556 45.1m 8048 31.4m 9560 37.3m Xhp
28468 1 8808 34.4m 4293 16.8m 4707 18.4m nautilus
4362 1 8294 32.4m 3269 12.8m 3680 14.4m scopeux


Let me know what OS you have (11.0 or 11.11) parisc - and I can post it.

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
gerjam
Advisor

Re: How to check processes eating memory and swap resources

Hi Geoff,

Im using HPUX 11.0

Thanks.

Geoff Wild
Honored Contributor

Re: How to check processes eating memory and swap resources

Here's the kmeminfo program.

It's a shar archive, zipped up first with winzip, so download, unzip it, ftp to your HP server, and execute:

sh kmeminfo_11_0.sh

Run it like:

/usr/local/bin/kmeminfo

or

/usr/local/bin/kmeminfo -user


I created myself a script to run from cron:

0 1,5,9,13,17,21 * * * /usr/local/bin/kmeminfo.get.sh > /dev/null 2>&1

cat /usr/local/bin/kmeminfo.get.sh
#!/bin/sh
#
# script to run kmeminfo and store data
# gwild

LOG=/tmp/`/usr/bin/uname -n`kmeminfo.out
LOGU=/tmp/`/usr/bin/uname -n`kmeminfouser.out

/usr/bin/echo " " >> $LOG
/usr/bin/date >> $LOG
/usr/bin/echo " " >> $LOG
/usr/local/bin/kmeminfo >> $LOG

sleep 120

/usr/bin/echo " " >> $LOGU
/usr/bin/date >> $LOGU
/usr/bin/echo " " >> $LOGU
/usr/local/bin/kmeminfo -user >> $LOGU





WARNING - I have found that the 11.0 version caused zombies with the -user option - so watch that - if it does, then don't run it with the -user optin - only the first way.

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
gerjam
Advisor

Re: How to check processes eating memory and swap resources

Thanks for all the help!