Shell script to get list of services along with there count having more than two version deployed in any domain.
Hello to viewer,
This shell script will provide you the list of services that are having more than two versions deployed in any domain along with there count and partition in which they are deployed.
Benefit: This is helpful for techies supporting non prod environment where there are many versions deployed in a domain for the same service. Since large number of versions creates confusion and leads to slowness of EM console.
Maintenance activity of any non prod environment includes undeploying older versions of the services and maintaining only one version that will respond to client request.Gathering the list of service having more versions ,manually is a time consuming process.This script will surely save your Time.
Here is the Flow :
Wlst command: It will list all the composites that are deployed in any domain.
sca_listDeployedComposites('host','manageserver_port','user','password')
Change the value of host,manageserver_port,user and password accrding to your environment.
Follow the below steps:
Step 1) : Create the directory structure as below:
cd /shared/fmw/build/script/versioncount
Step 2) : Under your current directory "versioncount " create serviceList.py file with content below:
import ConfigParser
def connectToServer():
USERNAME = 'user'
PASSWORD = 'password'
URL='t3://host : adminport'
#Connect to the Administration Server
print 'starting the script ....'
connect(USERNAME,PASSWORD,URL)
def disconnectFromServer():
print "Disconnecting from the Admin Server"
disconnect()
print "Exiting from the Admin Server"
exit()
print "Mission Accomplished"
def readConfigurationFile():
try:
print 'Entry point...'
sca_listDeployedComposites('host','manageserver_port','user','password')
except :
print 'Unable to find admin server...'
exit()
print 'Command executed successfully'
############### Main Script #####################################
#Conditionally import wlstModule only when script is executed with jython
if __name__ == '__main__':
from wlstModule import *#@UnusedWildImport
print('This will enable you to create distributed JMS Queues')
connectToServer()
readConfigurationFile()
disconnectFromServer()
####################################
Step 3) : Under your current directory "yourscript " create serviceList.sh with the content below :
#!/bin/sh
# set up WL_HOME, the root directory of your WebLogic installation
WL_HOME="wl_home"
umask 027
cd /shared/fmw/build/script/versioncount
# set up common environment
WLS_NOT_BRIEF_ENV=true
. "${WL_HOME}/server/bin/setWLSEnv.sh"
#CLASSPATH="${CLASSPATH}${CLASSPATHSEP}${FMWLAUNCH_CLASSPATH}${CLASSPATHSEP}${DERBY_CLASSPATH}${CLASSPATHSEP}${DERBY_TOOLS}${CLASSPATHSEP}${POINTBASE_CLASSPATH}${CLASSP
ATHSEP}${POINTBASE_TOOLS}"
if [ "${WLST_HOME}" != "" ] ; then
WLST_PROPERTIES="-Dweblogic.wlstHome='${WLST_HOME}' ${WLST_PROPERTIES}"
export WLST_PROPERTIES
fi
#echo
#echo CLASSPATH=${CLASSPATH}
JVM_ARGS="-Dprod.props.file='${WL_HOME}'/.product.properties ${WLST_PROPERTIES} ${JVM_D64} ${MEM_ARGS} ${CONFIG_JVM_ARGS}"
sh ORACLE_HOME/common/bin/wlst.sh serviceList.py > output.out
grep -E "partition" output.out > final.out
cat final.out | sed -e 's/mode.*//' > a.out
cat a.out | sed -e 's/^[0-9]*. //g' | sed -e's/[0-9]*[.]*//g' | sed -e 's/\[//g' | sed -e 's/\]//g' | sed -e 's/, /,/' > b.out
N=0
while read LINE ; do
var[$N]=$(echo $LINE)
#echo {$var[$N]}
N=$((N+1))
done < b.out
for i in ${var[*]};
do
COUNT=0
for j in ${var[*]};
do
if [ "$i" = "$j" ]; then
COUNT=$((COUNT+1))
fi
done
if [ "$COUNT" -gt 1 ]; then
echo $i $COUNT >> result.txt
fi
done
sort result.txt | uniq > finalresult.txt
rm result.txt
Note : Change the value of wl_home, oracle_home according to your environment.
After this you just need to run the shell script : sh serviceList.sh and you will get the output in finalresult.txt file like mentioned below:
service1,partition=partition_name, count
Thanks a lot for your patience !!!!
Regards
-Ashish