Quickly show memory usage under AIX

Very quick and basic shell script to show total/free/used memory on a host running AIX.

kristijan@AIX > ./meminfo
Memory Information
total memory = 1884 MB
free memory  = 94 MB
used memory  = 1790 MB

Script uses standard AIX command line utilities to work out all the values. I haven’t tested it across all versions of AIX (I wrote this on AIX 6.1), but I believe it should work fine. Let me know in the comments if it doesn’t.

# Quick view of memory usage under AIX
USED=`svmon -G | head -2 | tail -1 | awk '{ print $3 }'`
USED=`expr $USED / 256`
TOTAL=`lsattr -El sys0 -a realmem | awk '{ print $2 }'`
TOTAL=`expr $TOTAL / 1000`
FREE=`expr $TOTAL - $USED`
echo "\nMemory Information"
echo "=================="
echo "total memory = $TOTAL MB"
echo "free memory  = $FREE MB"
echo "used memory  = $USED MB"
exit 0

7 thoughts on “Quickly show memory usage under AIX

  1. something similar using awk for formatting that i have in my .profile:

    [3131][ndcalab08]:/home/jquainta> declare -f lsmem
    lsmem ()
    sudo svmon -G | awk ‘
    /memory/ {printf(“total real memory =\t %5.2f GB\n”,$2/256/1024)}
    /memory/ {printf(“real memory free =\t %5.2f GB\n”,$4/256/1024)}
    /in use/ {printf(“real memory used =\t %5.2f GB\n”,($3+$5)/256/1024)}
    /pg space/ {printf(“paging space used =\t %5.2f GB\n”,$4/256/1024)}’;
    vmstat -v | awk ‘
    /client pages/ {printf(“client pages used =\t %5.2f GB\n”,$1/256/1024)}’;
    echo “”;
    ps -eko vsz,rssize | awk ‘{rss += $2; vsz+=$1} END {
    printf(“total RSS: %5.2f GB\n”,rss/1024/1024)
    printf(“total VSZ: %5.2f GB\n”,vsz/1024/1024)}’
    [3132][ndcalab08]:/home/jquainta> lsmem
    total real memory = 2.00 GB
    real memory free = 0.05 GB
    paging space used = 0.24 GB
    real memory used = 1.95 GB
    client pages used = 0.79 GB

    total RSS: 0.26 GB
    total VSZ: 0.53 GB

    • Thanks Jeff.

      The formatting in the comments makes it a bit of a pain to read, when I get a chance, I’ll tack it on into the main post with some formatting…that’s if you don’t mind?

  2. Pingback: Tweets that mention Quickly show memory usage under AIX -- Topsy.com

  3. Useful Script and it’s works on AIX 7 as well.

    Also I would like to know the below line.

    USED=`svmon -G | head -2 | tail -1 | awk ‘{ print $3 }’`
    USED=`expr $USED / 256`

    why you need to divide by 256 and what is that value.

Leave a Reply

Your email address will not be published. Required fields are marked *