#!/bin/sh
# Script to monitor JVM Heap Memory for the managed servers
# Author : Ramasubbu Sunadaravel
# Date : 23-Aug-2016
# Usage : sh jvm_heap_mem_mon.sh run
## VARIABLES
save_date=`date +%d_%b_%y`
LOGFILE=/export/home/applmgr/oraprocs/logs
HISTFILE=/export/home/applmgr/oraprocs/histfile
threshold=10
MAIL_LIST=rsundaravel@yahoo.com
SCRIPT=/export/home/applmgr/oraprocs/.jvm_check.py
## SCRIPTS STARTS HERE
. /r11/app/FLRPRD/R12apps/EBSapps.env
. $FMW_HOME/wlserver_10.3/server/bin/setWLSEnv.sh
java weblogic.WLST $SCRIPT > $LOGFILE/jvm_heap_monitoring.log
date '+Start Time: %m/%d/%y %H:%M:%S' >> $HISTFILE/jvm_heap_monitoring_$save_date.log
cat $LOGFILE/jvm_heap_monitoring.log|grep "%" >> $HISTFILE/jvm_heap_monitoring_$save_date.log
date '+End Time: %m/%d/%y %H:%M:%S' >> $HISTFILE/jvm_heap_monitoring_$save_date.log
#Alert DBA's if any of the managed server heap size reached more than $threshold value
current=`cat $LOGFILE/jvm_heap_monitoring.log|grep %|awk '{print $8}'|cut -f1 -d'%'|sort -n |head -1`
if test $current -lt $threshold
then
echo "one of the managed server heap size free % reached less than $threshold% . Please check logfile $LOGFILE/jvm_heap_monitoring.log from `hostname`" |mailx -s "Managed server heap size free % reached less
than $threshold% in `hostname` " $MAIL_LIST < $LOGFILE/jvm_heap_monitoring.log
else
echo "All is well"
fi
## END
### Weblogic script to find out JVM Memory usage.
cat /export/home/applmgr/oraprocs/.jvm_check.py
connect('weblogic','password','t3://test.testing.int:7014')
domainRuntime()
servers = domainRuntimeService.getServerRuntimes();
print('################################################################')
print('# Java heap information per server')
print('################################################################')
print('%20s %10s %8s %8s %4s' % ('Server','Current','Free','Max','Free'))
for server in servers:
free = int(server.getJVMRuntime().getHeapFreeCurrent())/(1024*1024)
freePct = int(server.getJVMRuntime().getHeapFreePercent())
current = int(server.getJVMRuntime().getHeapSizeCurrent())/(1024*1024)
max = int(server.getJVMRuntime().getHeapSizeMax())/(1024*1024)
print('%20s %7d MB %5d MB %5d MB %3d%%' % (server.getName(),current,free,max,freePct))
disconnect()
exit()
# Script to monitor JVM Heap Memory for the managed servers
# Author : Ramasubbu Sunadaravel
# Date : 23-Aug-2016
# Usage : sh jvm_heap_mem_mon.sh run
## VARIABLES
save_date=`date +%d_%b_%y`
LOGFILE=/export/home/applmgr/oraprocs/logs
HISTFILE=/export/home/applmgr/oraprocs/histfile
threshold=10
MAIL_LIST=rsundaravel@yahoo.com
SCRIPT=/export/home/applmgr/oraprocs/.jvm_check.py
## SCRIPTS STARTS HERE
. /r11/app/FLRPRD/R12apps/EBSapps.env
. $FMW_HOME/wlserver_10.3/server/bin/setWLSEnv.sh
java weblogic.WLST $SCRIPT > $LOGFILE/jvm_heap_monitoring.log
date '+Start Time: %m/%d/%y %H:%M:%S' >> $HISTFILE/jvm_heap_monitoring_$save_date.log
cat $LOGFILE/jvm_heap_monitoring.log|grep "%" >> $HISTFILE/jvm_heap_monitoring_$save_date.log
date '+End Time: %m/%d/%y %H:%M:%S' >> $HISTFILE/jvm_heap_monitoring_$save_date.log
#Alert DBA's if any of the managed server heap size reached more than $threshold value
current=`cat $LOGFILE/jvm_heap_monitoring.log|grep %|awk '{print $8}'|cut -f1 -d'%'|sort -n |head -1`
if test $current -lt $threshold
then
echo "one of the managed server heap size free % reached less than $threshold% . Please check logfile $LOGFILE/jvm_heap_monitoring.log from `hostname`" |mailx -s "Managed server heap size free % reached less
than $threshold% in `hostname` " $MAIL_LIST < $LOGFILE/jvm_heap_monitoring.log
else
echo "All is well"
fi
## END
### Weblogic script to find out JVM Memory usage.
cat /export/home/applmgr/oraprocs/.jvm_check.py
connect('weblogic','password','t3://test.testing.int:7014')
domainRuntime()
servers = domainRuntimeService.getServerRuntimes();
print('################################################################')
print('# Java heap information per server')
print('################################################################')
print('%20s %10s %8s %8s %4s' % ('Server','Current','Free','Max','Free'))
for server in servers:
free = int(server.getJVMRuntime().getHeapFreeCurrent())/(1024*1024)
freePct = int(server.getJVMRuntime().getHeapFreePercent())
current = int(server.getJVMRuntime().getHeapSizeCurrent())/(1024*1024)
max = int(server.getJVMRuntime().getHeapSizeMax())/(1024*1024)
print('%20s %7d MB %5d MB %5d MB %3d%%' % (server.getName(),current,free,max,freePct))
disconnect()
exit()
Comments