Monday, April 29, 2013

This script is used the check the health of the heap in weblogic server 11g

There are two script

1. Shell script whihc will call a python
2. Python Script


1. Shell Script : heap_status.sh

#!/bin/bash


#Author Mohammed Ashraf TP

#Date APRIL 08 2013

# ************* Setting the Environment ***********************

PAR_SLICE=`whoami `

echo $PAR_SLICE

SLICE=`echo $PAR_SLICE
cut -c4-8`

echo $SLICE

SOA_USER=soa_"$SLICE"

echo $SOA_USER

SOA_DOMAIN_NAME=soa_"$SLICE"_Domain

echo $S0A_DOMAIN_NAME







DOMAIN_HOME="/var/domain/"$SOA_USER"/"$SOA_DOMAIN_NAME"/"

echo $DOMAIN_HOME

. ${DOMAIN_HOME}/bin/setDomainEnv.sh $*



export CLASSPATH=/var/domain/"$PAR_SLICE"/WEBLOGIC_HOME/server/lib/weblogic.jar



echo "Environment has been set....."



# ************* Changing the directory where all the related files are needed ***********************



echo "Calling the PYTHON script....."



# ************* Calling the WLST script *****************



export CONFIG_JVM_ARGS="-Dweblogic.security.SSL.ignoreHostnameVerification=true -Dweblogic.security.TrustKeyStore=CustomTrust -Dweblogic.security.CustomTrustKeyStoreFileName=/var/domain/"$SOA_USER"/keystore/WebLogicTrustKeyStore.jks -Dweblogic.security.CustomTrustKeyStorePassPhrase=password -Dweblogic.security.CustomTrustKeyStoreType=JKS -Dweblogic.security.SSL.allowSmallRSAExponent=true"



echo $CONFIG_JVM_ARGS

/opt/Oracle/Middleware/Oracle_SOA1/common/bin/wlst.sh /home/"$PAR_SLICE"/WLST_TP/Health_Check/heap_status.py

    ++++++++++++++++++++++++++++++++++++++++++++++++++ 2.Python Script :heap_status.py   #Definition for connecting to a server

#!/usr/bin/python

from java.io import FileInputStream

from java.util import *

from javax.management import *

import sys

import re

import os

import pdb



def connectToServer():

username = 'weblogic'

password = 'password'

url = 't3s://mlx555:7777'

connect(username, password, url)



#Definition to print a running servers heap details

def printHeapDetails(server_name):

domainRuntime()

cd('/')

cd('ServerRuntimes/'+server_name+'/JVMRuntime/'+server_name)

hf = float(get('HeapFreeCurrent'))/1024

hs = float(get('HeapSizeCurrent'))/1024

hf = hf/1024

hs = hs/1024

print 'HeapFreeCurrent - ' + `hf` + 'MB'

print 'HeapSizeCurrent - ' + `hs` + 'MB'



#Definition to disconnect from a server

def disconnectFromServer():

disconnect()

exit()



#Calling connectToServer definition with no arguments

connectToServer()



#Calling printHeapDetails with arguments

printHeapDetails('soa_dev04_AdminServer01')

printHeapDetails('soa_dev04_BusinessServer01')

#printHeapDetails('mgds2')



#Calling disconnectFromServer definition with no arguments

disconnectFromServer()

No comments:

Post a Comment