First you may create secure key files to avoid using plain text uname and password for weblogic.
Step1:
Run WLST --> /opt/admin/fmw/oracle_common/common/bin/wlst.sh
Initializing WebLogic Scripting Tool (WLST) ...
Welcome to WebLogic Server Administration Scripting Shell
Type help() for help on available commands
wls:/offline>connect('weblogic','welcome1',url='t3://localhost:7001')
wls:/myDomain/serverConfig> storeUserConfig('/tmp/myUserConfigFile','/tmp/myUserKeyFile')
wls:/myDomain/serverConfig> exit()
Step2:
File name: getServerStatus.py
import sys
import os
sServer=sys.argv[1]
connect(userConfigFile='myUserConfigFile', userKeyFile='myUserKeyFile', url='t3://localhost:7001')
state(sServer)
disconnect()
exit()
Step3:
FileName: getServerState_wls.sh
#!/bin/ksh
usage()
{
echo "\n!!!!!Usage!!!!!!!"
echo
echo " getServerState_wls.sh
echo "\n getServerState_wls.sh myserver1"
echo
}
if [ $# -ne 1 ]
then
usage
exit 2
fi
SERVER=$1
echo "Server= ${SERVER}"
echo
/opt/admin/fmw/oracle_common/common/bin/wlst.sh getServerStatus.py ${SERVER} > /tmp/serverstatus.log
state=`cat /tmp/serverstatus.log | grep -i state`
echo $state
exit 0
Example Run:
./getServerState_wls_adp.sh MY_server2
Server= MY_server2
Current state of 'MY_server2' : RUNNING
No comments:
Post a Comment