Automatic Heap Dump generation in Weblogic

Oracle Weblogic Server

Now a days getting a heap dump at the right time to analyse is very crucial. So to tackle this problem of getting a automatic heap dump generation at the exact right time when the heap free in server is below some specified threshold this script was written.

autoheapdump.sh

————————-

#!/bin/bash
WL_DOMAIN="/opt/user_projects/domains/hell20tprod_domain"
JAVA_BIN="/opt/bea/jdk1.5.0_15/bin"
MS_NAME=hell20tprod
threshold=20
LOG_DIR="$WL_DOMAIN/servers/$MS_NAME/logs"
while true; do
MS_PID=`ps auxw |grep java |grep $MS_NAME |awk '{print $2}'`
SCRIPT_LOG="$LOG_DIR/heap_dump.log"
if [ ! -f Count.log ]
then
 touch Count.log
fi
Count=`cat Count.log`
GcMonC=`grep "weblogic.GCMonitor" $LOG_DIR/$MS_NAME.log | wc -l` 
grep "weblogic.GCMonitor" $LOG_DIR/$MS_NAME.log | wc -l > Count.log
free=`grep "weblogic.GCMonitor" $LOG_DIR/$MS_NAME.log | tail -1 | cut -d "<" -f14 | cut -d "%" -f1`
if [[ $free -lt $threshold && $GcMonC -gt $Count ]];
then
echo "Free memory on `hostname` has dropped below to $free%, Starting Heap dump Process" | mailx -s "Starting Heap Dump on `hostname`" "weblogicadmin[at]techpaste.com,admin1[at]techpaste.com"
$JAVA_BIN/jmap -heap:format=b $MS_PID >> $SCRIPT_LOG 
mv heap.bin $LOG_DIR/heap_$MS_NAME`date +%m%d%Y_%H%M`.bin
sleep 900
fi;
done

 

Here

WL_DOMAIN – is the weblogic domain path

JAVA_BIN – path till bin directory of java installation for weblogic, which contains jmap tool for heap dump.

MS_NAME – Manage Server Name from which heap dump required.

threshold – The limit from where the heap dump will get triggered. here we have 20% free is given as threshold to take heap dump.

LOG_DIR – it is the directory where managed server logs are stored and heap dump file also will get stored there.

SCRIPT_LOG – The directory where the script run log will get stored.

To run this script you can use crontab or just by issuing nohup ./autoheapdump.sh &

In case of any ©Copyright or missing credits issue please check CopyRights page for faster resolutions.

2 Responses

  1. Anshul Soni says:

    Weblogic managed server goes to ADMIN state in Production. what could be the root cause for this??
    yes we could manually resume the server in running state? but why does this happen all of a sudden?

    logs for the same.

    ODSI Cache odsi.cache.hash.classname: java.util.zip.CRC32
    ODSI Cache odsi.cache.hash.classname: java.util.zip.CRC32
    ODSI Cache odsi.cache.hash.classname: java.util.zip.CRC32
    ODSI Cache odsi.cache.hash.classname: java.util.zip.CRC32
    ODSI Cache odsi.cache.hash.classname: java.util.zip.CRC32

    ODSI Cache odsi.cache.hash.classname: java.util.zip.CRC32
    ODSI Cache odsi.cache.hash.classname: java.util.zip.CRC32
    ODSI Cache odsi.cache.hash.classname: java.util.zip.CRC32
    ODSI Cache odsi.cache.hash.classname: java.util.zip.CRC32
    ODSI Cache odsi.cache.hash.classname: java.util.zip.CRC32
    ODSI Cache odsi.cache.hash.classname: java.util.zip.CRC32
    ODSI Cache odsi.cache.hash.classname: java.util.zip.CRC32

Leave a Reply