1838747 Members
3633 Online
110129 Solutions
New Discussion

Re: memory utilization

 
SOLVED
Go to solution
PVR
Valued Contributor

memory utilization

I want to find out system load during some specific time. I don't have glance, pv type of performance monitoring softwares installed in my system.

TOP is not giving full memory utilization information.( I mean full physical memory).

Can anybody help with some commands or scripts?
Don't give up. Try till success...
7 REPLIES 7
Karthik S S
Honored Contributor

Re: memory utilization

dmesg | grep -i physical

can give you some info on physical memory usage ..

-Karthik S S
For a list of all the ways technology has failed to improve the quality of life, please press three. - Alice Kahn
Nicolas Dumeige
Esteemed Contributor

Re: memory utilization

Hello,

You can activate sar, it will record system activity on file that you can interrogate later on.
vmstat is also a very good tool but do not record anything unless you redirect it's output.

This script is for Solaris so adapt it to your need :
#!/bin/ksh

DELAY=${1:-20}

# Redirect output LOG=/projets/RST/rstexplo/outils/cperf_`date +'%y_%m_%d__%H_%M'`.log
#exec 1>>$LOG 2>&1

id ; echo "${0##*/} lunched `date +'%A %d %B %Y %H:%M:%S'` on tty `tty`"

tput bold
print "Time %usr %sys %wio %idl intr migr smtx syscl r b w Swap RAM re mf pi po fr de sr in sy cs kr/s kw/s wsvc_t"
tput rmso

# The real thing
while :
do
{
date +'%H:%M:%S'
/usr/bin/sar -u 1 2 | nawk '{ if ( $1 ~ /Average/ ) { print $2" "$3" "$4" "$5 } }'
/usr/bin/mpstat 1 3 | /bin/grep -v '^CPU' | tail -16 | \
/usr/bin/nawk '{ intr += $5 ; migr += $9 ; smtx += $10 ; syscall += $12 } END { printf("%5.f %5.f %5.f %5.f\n",intr/2, migr/2,smtx/2,syscall/2) }'
/usr/bin/vmstat 2 2 | tail -1
/usr/bin/iostat -nx 2 2 | /usr/bin/nawk 'BEGIN { shw=0 } { if ( $1 ~ /extended/ ) { shw++ } if ( shw > 1 ) \
{ if ( $11 ~ /c..*t..*d/ ) { kb +=$3 ; kw += $4 ; wsvc_t += $7 } } }
END { printf("%d %d %3.1f \n", kb, kw, wsvc_t) }'
} | /usr/bin/xargs | \
/usr/bin/nawk '{ printf("%8s %4d %4d %4d %4d %5d %5d %5d %6d %2d %2d %2d %5d %5d %5d %5d %7d %5d %3d %3d %3d %5d %5d %5d %6d %6d %3.1f\n",
$1, $2,$3,$4,$5, $6,$7,$8,$9, $10,$11,$12, int($13/1024),int($14/1024), $15,$16,$17,$18,$19,$20,$21, $26,$27,$28, $32,$33,$34 ) }'
# Time %u %s %w %id in mg sm scl r b w Swap RAM re mf pi po fr de sr in sy cs r/s w/s svc_t"
sleep $DELAY
done

exit 0
/usr/bin/mpstat 1 3 | grep -v '^CPU' | tail -16 | awk '{ migr += $9 , smtx += $10 } END { printf("%4.f\n",smtx/16) }'
All different, all Unix
Robert-Jan Goossens
Honored Contributor

Re: memory utilization

Hi,

From
http://www.cmve.net/~merijn/


How much memory do I have

a5:/ 112 # echo "selclass qualifier memory;info;wait;infolog" | cstm | grep 'Total Configured'
Total Configured Memory : 2048 MB
a5:/ 113 # echo 'memory_installed_in_machine/D' | adb -k /stand/vmunix /dev/mem | perl -nle'/(\d+)/&&print$1*4,"k"'
2097152k
a5:/ 114 # grep Physical /var/adm/syslog/syslog.log
Aug 25 08:01:07 a5 vmunix: Physical: 2097152 Kbytes, lockable: 1562360 Kbytes, available: 1801856 Kbytes
a5:/ 115 #
Colin Topliss
Esteemed Contributor

Re: memory utilization

Have a look at sar. It might give you the information you require.

Unfortunately it doesn't give you much in the way of stats about virtual memory. Paging-in and out rates, and swapping-in and out rates are shown. Its not very useful in helping to sort out bottlenecks in memory, but it *might* be enough to give you an idea.

vmstat will allow you to monitor virtual memory, but not on a per-process basis. Again, might be enough to give you a clue.

Last thing is to download a trial version of glance - it will last long enough to look at your current problem, and maybe even persuade your bosses that glance is a good investment??

Col
Geoff Wild
Honored Contributor
Solution

Re: memory utilization

Here's some script that might help:

# cat top10
#/bin/sh
UNIX95= ps -e -o "vsz pcpu ruser pid stime time state args" | sort -rn |head -10


# cat usermem
#!/bin/ksh
# usermem - display memory claimed by a user
# gwild 06232003
#
if [ $# -lt 1 -o \( $# -gt 1 -a $# -lt 4 \) ]
then
echo "Usage:"
echo "usermem \"userid\""
echo "Example:"
echo "usermem gwild"
exit 1
fi
echo " "

USER=$1
t=0
for j in `UNIX95= ps -e -o vsz=Kbytes -o ruser -o pid,args=Command-Line | sort -rnk1 | grep -v Kbytes | grep $USER | awk '{print $1}'`
do
t=`expr $t + $j`
done
echo "\nMemory claimed by $USER: $t Kbytes.\n"

# cat processmem
#!/bin/sh
# processmem - display memory claimed by a process
# gwild 03192004
#
if [ $# -lt 1 -o \( $# -gt 1 -a $# -lt 4 \) ]
then
echo "Usage:"
echo "processmem \"process\""
echo "Example:"
echo "processmem rpc"
exit 1
fi
echo " "

PROCESS=$1

mps=0
#for sz in `ps -elf | grep $PROCESS | grep -v grep | awk '{print $10}'`
for sz in `UNIX95= ps -e -o vsz=Kbytes -o ruser -o pid,args=Command-Line | sort -rnk1 | grep -v Kbytes | grep $PROCESS | awk '{print $1}'`
do
mps=`expr $mps + $sz`
done
#echo `expr $mps \* 4096`
echo "\nMemory claimed by $PROCESS: $mps Kbytes.\n"

As well as attached c program called memdetail

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.
jherring
Regular Advisor

Re: memory utilization

check knowledge base for this doc
Introduction to Performance Tuning
DocId: UPERFKBAN00000726

it will walk you through pretty much any issue you might have. No special tools needed all of them are listed with a description of what to look for.
Sundar_7
Honored Contributor

Re: memory utilization

Hi,

Total memory you have

# echo "phys_mem_pages/D" | adb -k /stand/vmunix /dev/kmem

Multiply the output with 4 and the resulting number is the amount of memory you have in Kbytes.

Free Memory

# echo "freemem/D" | adb -k /stand/vmunix /dev/kmem

Multiply the output with 4 and the resulting number is the amount of FREE memory you have in Kbytes.

Search for shminfo, kmeminfo and procsize - 3 unsupported tools that will give u wealth of information.

Sundar
Learn What to do ,How to do and more importantly When to do ?