Project:Sandbox

= SWAP =

Show free swap.

{zpsu1047:root}# swap -l swapfile            dev  swaplo blocks   free /dev/zvol/dsk/rpool/swap 256,1     16 67110896 67110896 /dev/zvol/dsk/rpool/swap2 256,3     16 335544304 335544304

= Memory =

Show all available memory

{zpsu1047:root}# prtconf | grep Memory Memory size: 523264 Megabytes

sar
Check free memory using sar.

{zpsu1047:root}# sar -r 5 5

SunOS zpsu1047 5.10 Generic_150400-19 sun4v   02/03/2017

13:58:48 freemem freeswap 13:58:53 7823220 348803302 13:58:58 7822348 348805238 13:59:03 7822473 348823629 13:59:08 7821954 348828058 13:59:13 7820303 348743258

Average 7822060 348800697

First number - number of repetition.

Second number - time interval in seconds.

Output of sar is in pages. Fromula for conversion to MB is:

output*pagesize/1024/1024

For example:

7822060*8182/1024/1024=61109 MB

Page size is 8192 for SPARC machines and 4096 for x86 machines. If You want to be sure you can verify it by command pagesize.

{zpsu1047:root}# pagesize 8192

Show free memory in MB.

echo "`sar -r 1 1 | tail -1 | awk '{print $2}'` * "`pagesize`/1024" / 1024" | bc

Show all available memory in MB.

echo `prtconf | grep Memory | head -1 | awk '{print $3}'`

Example:

{zpsu1047:root}# echo "`sar -r 1 1 | tail -1 | awk '{print $2}'` * "`pagesize`/1024" / 1024" | bc 62028

{zpsu1047:root}# echo `prtconf | grep Memory | head -1 | awk '{print $3}'` 523264

vmstat
Command vmstat provide memory size in KB. To get size in MB you just divide output by 1024.

{zpsu1047:root}# vmstat 2 kthr     memory            page            disk          faults      cpu r b w  swap  free  re  mf pi po fr de sr lf lf lf lf   in   sy   cs us sy id 27 0 0 164710328 45109944 2454 11400 241 0 0 0 0 1 2 6 0 39921 130238 83242 2 1 96 48 0 0 167613512 48998432 9965 54778 244 0 0 0 0 0 0 0 0 60653 643158 69964 5 4 91 45 0 0 167813048 49095664 7076 37859 5519 0 0 0 0 0 0 0 0 60862 546999 66698 5 3 92 47 0 0 167755640 49035912 2882 16392 3616 0 0 0 0 0 0 0 0 47814 596750 55239 5 3 92 46 0 0 167720920 49017704 2471 13654 394 0 0 0 0 0 0 0 0 42556 512608 46668 4 2 94 43 0 0 167662168 48992368 2633 15194 20 0 0 0 0 0 0 0 0 49562 600292 53683 4 2 94 44 0 0 167597040 48955104 1481 8731 4772 0 0 0 0 0 0 0 0 43916 502688 48284 5 2 93 Free memory = 48955104 KB / 1024 = 47807 MB

Script

 * 1) !/usr/bin/ksh

memory=`prtconf | grep Memory | head -1 | awk 'BEGIN {FS=" "} {print $3}'` gb_memory=`echo "scale=2; $memory/1024" | bc -l`
 * 1) Available memory

pagesize=`pagesize` kb_pagesize=`echo "scale=2; $pagesize/1024" | bc -l` sar_freemem=`sar -r 1 1 | tail -1 | awk 'BEGIN {FS=" "} {print $2}'` gb_freemem=`echo "scale=2; $kb_pagesize*$sar_freemem/1024/1024" | bc -l`
 * 1) Free memory

gb_usedmem=`echo "scale=2; $gb_memory-$gb_freemem" | bc -l`
 * 1) Used Memory

echo "Avai Mem: $gb_memory GB" echo "Free Mem: $gb_freemem GB" echo "Used Mem: $gb_usedmem GB"
 * 1) Conclusion

Output:

{zpsu1047:root}# ./free.sh Avai Mem: 511.00 GB Free Mem: 51.26 GB Used Mem: 459.74 GB

Processes
Check how many processes are running. (More then 10 000 is allways problem)

{zpsu1047:root}# ps -ef | wc -l 861

You can also grep suspicious process.

{zpsu1047:root}# ps -ef | grep summit | wc -l 213

Show process with high memory usage.

{zpsu1047:root}# UNIX95= ps -e -o vsz=Kbytes -o pmem,pcpu,user,args| sort -rn -k 1 | head -40 21123904 3.4  0.0 pasummdx /rte/java/soft/pkgs/product/jdk1.7.0_45/bin/sparcv9/java -Djava.util.logging.co 17913600  2.6  0.0 pasummdx /rte/java/soft/pkgs/product/jdk1.7.0_45/bin/sparcv9/java -Djava.util.logging.co 17110512  2.4  0.0 dasummdx /rte/java/soft/pkgs/product/jdk1.7.0_45/bin/sparcv9/java -Djava.util.logging.co 2896776  0.2  0.0 dasummdx /rte/java/soft/pkgs/product/jdk1.7.0_45/bin/sparcv9/java -Djava.util.logging.co 1783024  0.3  0.0 uagmqaad /rte/java/soft/pkgs/product/jdk1.7.0_75/bin/java -DINSTANCE_HOME=/app/gmqa/soft 1758800 0.3  0.0 dasummdx /rte/java/soft/pkgs/product/jdk1.7.0_45/jre/bin/java -Djava.util.logging.config 1698560 0.2  0.0 dasummdx /rte/java/soft/pkgs/product/jdk1.7.0_45/jre/bin/java -Djava.util.logging.config 1668928 0.2  0.0 dasummdx /rte/java/soft/pkgs/product/jdk1.7.0_45/jre/bin/java -Djava.util.logging.config 1566936 0.2  0.0 pasummdx /rte/java/soft/pkgs/product/jdk1.8.0_05/jre/bin/java -Djava.util.logging.config 1441248 0.3  0.0 pasummdx /rte/java/soft/pkgs/product/jdk1.7.0_45/bin/java -Djava.util.logging.config.fil 1374648 0.2  0.0 dasummdx /rte/java/soft/pkgs/product/jdk1.7.0_45/bin/java -Djava.util.logging.config.fil 1186888 0.2  0.0 pasummdm /app/summit/soft/pkgs/product/v5.5/exe/gstp_server -CFG /app/summit/soft/pkgs/c 1153688 0.2  0.0 pasummdm /app/summit/soft/pkgs/product/v5.5/exe/bvsapp_2k -ML 3 -CFG /app/summit/soft/pk 940896 0.2  0.0 uagmqaad /rte/java/soft/pkgs/product/jdk1.7.0_75/bin/java -DINSTANCE_HOME=/app/gmqa/soft 774696 0.2  0.0 pasummtt modTTSummitServer3006 /app/summit/soft/pkgs/custom/WMB/v5.5/exe/modTTSummitServ 690984 0.1  0.0 pasummdm /app/summit/soft/pkgs/product/v5.5/exe/bvsapp_2k -ML 3 -CFG /app/summit/soft/pk 664104 0.1  0.0 pasummtt modTTSummitServer3004 /app/summit/soft/pkgs/custom/WMB/v5.5/exe/modTTSummitServ 660048 0.1  0.0 pasummtt modTTSummitServer3018 /app/summit/soft/pkgs/custom/WMB/v5.5/exe/modTTSummitServ 651864 0.1  0.0 pasummtt modTTSummitServer3016 /app/summit/soft/pkgs/custom/WMB/v5.5/exe/modTTSummitServ 651816 0.1  0.0 pasummtt modTTSummitServer3019 /app/summit/soft/pkgs/custom/WMB/v5.5/exe/modTTSummitServ 643624 0.1  0.1 pasummtt modTTSummitServer3017 /app/summit/soft/pkgs/custom/WMB/v5.5/exe/modTTSummitServ 631336 0.1  0.0 pasummtt modTTSummitServer3015 /app/summit/soft/pkgs/custom/WMB/v5.5/exe/modTTSummitServ 619048 0.1  0.0 pasummtt modTTSummitServer3014 /app/summit/soft/pkgs/custom/WMB/v5.5/exe/modTTSummitServ 614952 0.1  0.0 pasummtt modTTSummitServer3009 /app/summit/soft/pkgs/custom/WMB/v5.5/exe/modTTSummitServ 610856 0.1  0.0 pasummtt modTTSummitServer3003 /app/summit/soft/pkgs/custom/WMB/v5.5/exe/modTTSummitServ 590376 0.1  0.0 pasummtt modTTSummitServer3013 /app/summit/soft/pkgs/custom/WMB/v5.5/exe/modTTSummitServ 563912 0.1  0.0 pasummdm /app/summit/soft/pkgs/product/v5.5/exe/bdposserver_2k -ML 2 -DB 15 -PUBLISH SEC 516648 0.1  0.0 pasummtt modTTSummitServer3007 /app/summit/soft/pkgs/custom/WMB/v5.5/exe/modTTSummitServ 496376 0.1  0.0   makamr /home/makamr/p4clients/SummitV6.0.12/unix/6.0/exe/regmtmrpt -F LNDEVAL_E1 -CS " 481768  0.1  0.0 uakyroad /rte/java/soft/pkgs/product/jdk1.7.0_75/bin/java -Djava.rmi.server.ignoreStubCl 465288  0.1  0.0 pasummdm /app/summit/soft/pkgs/product/v5.5/exe/bvsapp_2k -ML 3 -CFG /app/summit/soft/pk 438824  0.1  0.1 pasummtt modTTSummitServer3002 /app/summit/soft/pkgs/custom/WMB/v5.5/exe/modTTSummitServ 429400  0.0  0.8   makamr /opt/SUNWspro12_3/solarisstudio12.3/bin/sparcv9/dbx /home/makamr/p4clients/Summ 428592  0.1  0.0 pasummdm /app/summit/soft/pkgs/product/v5.5/exe/bvsapp_2k -ML 1 -MG 88 -CFG /app/summit/ 426536  0.1  0.0 pasummtt modTTSummitServer3005 /app/summit/soft/pkgs/custom/WMB/v5.5/exe/modTTSummitServ 421608  0.1  0.0 dasummdm etoolkitsvr_2k -N eTKS_d707398_DUSL2170_eTKM_ZPDEV0101X1033LLLL_rmgx1027_zp_d01 417192  0.1  0.0 pasummob emirfeed /app/summit/soft/pkgs/custom/WMB/v5.5/exe/emirfeed -C /app/summit/soft 415832 0.1  0.0 pasummdm /app/summit/soft/pkgs/product/v5.5/exe/bvsapp_2k -ML 3 -CFG /app/summit/soft/pk 395520 0.1  0.0 pasummdm /app/summit/soft/pkgs/product/v5.5/exe/bvsapp_2k -ML 3 -CFG /app/summit/soft/pk 389712 0.1  0.0 pasummtt modTTSummitServer3008 /app/summit/soft/pkgs/custom/WMB/v5.5/exe/modTTSummitServ