Sunday, September 30, 2012

Controlling Data Sources using weblogic.Admin

While WLST has become the primary direction when it comes to controlling and administering WebLogic. There are still simple ways using shell scripts which may be leveraged to perform simple administrative actions. This is helpful for administrators who are not familiar with the Python language or the WLST API and are looking for a quick way to to perform administrative actions which help understand the status of assets within WebLogic. As can be seen in the script below there are simple calls which allow for immediate results. These calls can be added into as a part of a larger script or suite of scripts which could allow the administrator to get a quick report on each of the data sources on a daily basis through the use of a CRON job.

Script

#!/bin/sh
#********************************************************************************
#
# AUTHOR:       Harold Dost III
# CREATED:      2012-09-26
# LAST UPDATED: 2012-09-26
# DESCRIPTION:  Checks for status, turns on, turns off data sources
#
#********************************************************************************

#--------------------------------------------------------------------------------
# Variables
#--------------------------------------------------------------------------------
WL_HOME=/u01/app/oracle/middleware/wlserver_10.3
USERNAME=administrator
PASSWORD=welcome123
SOAHOST=localhost
SOAPORT=8001

#--------------------------------------------------------------------------------
# Input parameters
#--------------------------------------------------------------------------------
export DSNAME="${1}"
export DSACTION="${2}"
export 
if [ "${DSNAME}" = "" ]; then
  echo ""
  echo "ERROR: Must specify data source name."
  echo ""
  echo "       USAGE:   ${0} <data source name> test|on|off
  echo ""
  echo "       EXAMPLE: ${0} SOADataSource test"
  echo ""
  exit 1
fi


#--------------------------------------------------------------------------------
# Set environment
#--------------------------------------------------------------------------------
. $WL_HOME/server/bin/setWLSEnv.sh

#--------------------------------------------------------------------------------
# Action
#--------------------------------------------------------------------------------
if [ "${DSACTION}" = "test" ]; then
  java weblogic.Admin -url t3://${SOAHOST}:${SOAPORT} -username ${USERNAME} -password ${PASSWORD} TEST_POOL ${DSNAME}
elif [ "${DSACTION}" = "on" ]; then
  java weblogic.Admin -url t3://${SOAHOST}:${SOAPORT} -username ${USERNAME} -password ${PASSWORD} ENABLE_POOL -poolName ${DSNAME}
elif [ "${DSACTION}" = "off" ]; then
  java weblogic.Admin -url t3://${SOAHOST}:${SOAPORT} -username ${USERNAME} -password ${PASSWORD} DISABLE_POOL -poolName ${DSNAME}
else
  if [ "${DSNAME}" = "" ]; then
    echo ""
    echo "ERROR: Must specify valid action."
    echo ""
    echo "       USAGE:   ${0} <data source name> test|on|off
    echo ""
    echo "       EXAMPLE: ${0} SOADataSource test"
    echo ""
    exit 1
  fi
if
# END SCRIPT


Reference: http://docs.oracle.com/cd/E13222_01/wls/docs81/admin_ref/clic.html

No comments:

Post a Comment