Hello to viewer,
This shell script is for Monitoring purpose for all the composites that are default and in retired state.
Script will send the Email Notification in case it finds the default version of the composites deployed in any domain in Retired state.
Benefit : Helpful for techies supporting soa application in weblogic 11g environment. they will get the prior notification in case composites is in retired state so that any transaction failure can be avoided that are critical in production environment.
Here is the flow:
Shell calls the python ---> python executes the wlst command.
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/yourscript
Step 2) : Under your current directory "yourscript " 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()
#activateTheChanges()
disconnectFromServer()
####################################
Step 3) : Under your current directory "yourscript " create serviceList.sh with the content below :
#!/bin/sh
sender="sender@xxxxx.com"
receiver="receiver@xxxxx.com"
subj="CompositeStatus"
OUTPUT=/shared/fmw/build/script/yourscript/CompositeStatus.html
MAILTO=receiver@xxxxx.com
MAILCC=InCC@xxxxx.com
MAILFROM=sender@xxxxx.com
# set up WL_HOME, the root directory of your WebLogic installation
WL_HOME="wl_home"
umask 027
# 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_CLASSPAT
H}${CLASSPATHSEP}${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
#eval '"${JAVA_HOME}/bin/java"' ${JVM_ARGS} weblogic.WLST serviceList.py
#grep -E "mode=retired"\|"state=off" output.out | grep "isDefault=true" > retired.out
#grep -v "partition=SOAInfraTest" retired.out > stateoff.out
#awk -F, '{ print $1, $2 }' stateoff.out > CompositeStatus.out
N=0
COUNT=0
echo '<html>' > $OUTPUT
echo "<br /><b style='color:#ff0000'>Below are the tables showing retired / shutdown composite with there partition and domain.</b> <br /><br />" >> $OUTPUT
while read LINE ; do
if echo "$LINE" | egrep -q "user = " > /dev/null; then
N=$((N+1))
if [ "$N" -ge 2 ] ; then
echo "</table>" >> $OUTPUT
echo "<br />" >> $OUTPUT
fi
echo "<span style='color:black;font-weight:bold;'>" >> $OUTPUT
echo "$LINE" | awk '{print $3}' >> $OUTPUT
echo "</span>" >> $OUTPUT
echo "<br />" >> $OUTPUT
echo "<table border=1 cellpadding=0 cellspacing=0 style='background-color:#eee'>" >>$OUTPUT
echo "<tr style='background-color:#ddd'>" >> $OUTPUT
echo "<th>Composite Name</th><th>Partition Name</th>" >>$OUTPUT
echo "</tr>" >> $OUTPUT
fi
if echo "$LINE" | grep -E "mode=retired"\|"state=off" | grep "isDefault=true" | grep -v "partition=SOAInfraTest" > /dev/null; then
echo "<tr >" >> $OUTPUT
echo "<td style='padding:3px 5px;width:300px;'>" >> $OUTPUT
echo "$LINE" | awk '{print $2}' | sed -e "s/,//g" >> $OUTPUT
echo "</td>" >> $OUTPUT
echo "<td style='padding:3px 5px;width:300px;'>" >> $OUTPUT
echo "$LINE" | awk '{print $3}' | sed -e "s/,//g" >> $OUTPUT
echo "</td>" >> $OUTPUT
echo "</tr>" >> $OUTPUT
fi
#echo "$LINE" | grep -E "mode=retired"\|"state=off" | grep "isDefault=true" | awk '{print $2,$3}'
done < output.out
echo "</table>" >> $OUTPUT
echo '</html>' >> $OUTPUT
#cat /shared/fmw/build/script/yourscript/abcd.html | mail -s $subj sender@xxxxx.com
#mail --append="Content-type: text/html" -s "Built notification" sender@xxxxx.com < /shared/fmw/build/script/yourscript/abcd.html
(
echo "From: $MAILFROM"; \
echo "To: $MAILTO"; \
echo "Cc: $MAILCC"; \
echo "Content-Type: text/html";\
echo "Subject: CompositeStatus"; \
echo ""; \
cat $OUTPUT; \
) | /usr/lib/sendmail -t
Note : Change the value of wl_home, oracle_home, sender, receiver according to your environment.
After this you just need to execute the shell script or you can set this job in cron.
Thanks a lot for your patience !!!!
Regards
-Ashish
This shell script is for Monitoring purpose for all the composites that are default and in retired state.
Script will send the Email Notification in case it finds the default version of the composites deployed in any domain in Retired state.
Benefit : Helpful for techies supporting soa application in weblogic 11g environment. they will get the prior notification in case composites is in retired state so that any transaction failure can be avoided that are critical in production environment.
Here is the flow:
Shell calls the python ---> python executes the wlst command.
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/yourscript
Step 2) : Under your current directory "yourscript " 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()
#activateTheChanges()
disconnectFromServer()
####################################
Step 3) : Under your current directory "yourscript " create serviceList.sh with the content below :
#!/bin/sh
sender="sender@xxxxx.com"
receiver="receiver@xxxxx.com"
subj="CompositeStatus"
OUTPUT=/shared/fmw/build/script/yourscript/CompositeStatus.html
MAILTO=receiver@xxxxx.com
MAILCC=InCC@xxxxx.com
MAILFROM=sender@xxxxx.com
# set up WL_HOME, the root directory of your WebLogic installation
WL_HOME="wl_home"
umask 027
# 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_CLASSPAT
H}${CLASSPATHSEP}${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
#eval '"${JAVA_HOME}/bin/java"' ${JVM_ARGS} weblogic.WLST serviceList.py
#grep -E "mode=retired"\|"state=off" output.out | grep "isDefault=true" > retired.out
#grep -v "partition=SOAInfraTest" retired.out > stateoff.out
#awk -F, '{ print $1, $2 }' stateoff.out > CompositeStatus.out
N=0
COUNT=0
echo '<html>' > $OUTPUT
echo "<br /><b style='color:#ff0000'>Below are the tables showing retired / shutdown composite with there partition and domain.</b> <br /><br />" >> $OUTPUT
while read LINE ; do
if echo "$LINE" | egrep -q "user = " > /dev/null; then
N=$((N+1))
if [ "$N" -ge 2 ] ; then
echo "</table>" >> $OUTPUT
echo "<br />" >> $OUTPUT
fi
echo "<span style='color:black;font-weight:bold;'>" >> $OUTPUT
echo "$LINE" | awk '{print $3}' >> $OUTPUT
echo "</span>" >> $OUTPUT
echo "<br />" >> $OUTPUT
echo "<table border=1 cellpadding=0 cellspacing=0 style='background-color:#eee'>" >>$OUTPUT
echo "<tr style='background-color:#ddd'>" >> $OUTPUT
echo "<th>Composite Name</th><th>Partition Name</th>" >>$OUTPUT
echo "</tr>" >> $OUTPUT
fi
if echo "$LINE" | grep -E "mode=retired"\|"state=off" | grep "isDefault=true" | grep -v "partition=SOAInfraTest" > /dev/null; then
echo "<tr >" >> $OUTPUT
echo "<td style='padding:3px 5px;width:300px;'>" >> $OUTPUT
echo "$LINE" | awk '{print $2}' | sed -e "s/,//g" >> $OUTPUT
echo "</td>" >> $OUTPUT
echo "<td style='padding:3px 5px;width:300px;'>" >> $OUTPUT
echo "$LINE" | awk '{print $3}' | sed -e "s/,//g" >> $OUTPUT
echo "</td>" >> $OUTPUT
echo "</tr>" >> $OUTPUT
fi
#echo "$LINE" | grep -E "mode=retired"\|"state=off" | grep "isDefault=true" | awk '{print $2,$3}'
done < output.out
echo "</table>" >> $OUTPUT
echo '</html>' >> $OUTPUT
#cat /shared/fmw/build/script/yourscript/abcd.html | mail -s $subj sender@xxxxx.com
#mail --append="Content-type: text/html" -s "Built notification" sender@xxxxx.com < /shared/fmw/build/script/yourscript/abcd.html
(
echo "From: $MAILFROM"; \
echo "To: $MAILTO"; \
echo "Cc: $MAILCC"; \
echo "Content-Type: text/html";\
echo "Subject: CompositeStatus"; \
echo ""; \
cat $OUTPUT; \
) | /usr/lib/sendmail -t
Note : Change the value of wl_home, oracle_home, sender, receiver according to your environment.
After this you just need to execute the shell script or you can set this job in cron.
Thanks a lot for your patience !!!!
Regards
-Ashish
No comments:
Post a Comment