Search This Blog

Oracle Fusion Middleware Administration Course

Oracle Fusion Middleware Administration Course
OFMW Admin Course

Tuesday, June 30, 2009

Start timing of WebLogic instances

Here again I m concerned with regular reoccuring issues ... due to one of the issue the servers were bounced one of them at any time in the day...
Here is an oppurtunity to create a new script. The very first thing is a at what time the server instances were bounced, and there is manager need of knowing how many servers were bounced today.

WLST attribute 'ActivationTime' will give a time in the form of integer. That date can be converted to java.util.Date format.
The new learning is that easy to read the WLST script we can declare all constant values in a separate file which can be reused to other scripts too. The common, separate file is your properties file.
In WLST we have a wonder method called loadProperties(). This is defined for segrigating script with logic and all constants into properties which are loaded dynamically. We can load them while invoking the WLST script also.

Jython (Java utilities provides current day).
So I traced it with the little research on Jython date, string formating comparing server start date with the today date. The tuff part was that when I was printing integer with concatinating with string it is throwing exception. So don't use + symbol for concatinating int,string values.

The script goes like this...
Don't forget to indent the code..
#This script is for display the start time of instance
# and  it will also counts the number of WebLogic Server instances restarted today

from java.util import Date
from java.text import SimpleDateFormat
ud = {}  # This dictonary object is used in the getSite module
t = Date()  # Current date will be returned to t
searchday=SimpleDateFormat("dd").format(t) # extracting only day from the today date e.g:  Jul 3 2009 returns 3 here

redirect('./logs/urSiteStart.log', 'false')
def getSite(site):
# setting up the dictionary elements now...
for y in srvlist:
return ud

def showMenu():
print '1: SITE1 \n2: SITE2\n3: SITE3\n .... '
print '0: Quit'
choice=raw_input('ENTER Site CHOICE:')
return choice

# The main script logic starts here...
while 1
if site == 1:
elif site == 2:
elif site == 3:
# Add as much sites(physical locations) you have in your domain...
print 'exiting from the script now...'

for svr,surl in u.items():
connect(userConfigFile=UCK, userKeyFile=UKF, url=surl)
strout=svr+' instance is stared @'+ SimpleDateFormat('d MMM yyyy HH:mm:ss').format(java.util.Date(cmo.getActivationTime()))
print strout

if num_matches > 0:                     # a nonzero count means there was a match
restartCnt = restartCnt + 1
print ' server: \033[1;47;31m', svr, ' \033[0m'     
print '\033[1;47;31mThere are ',restartCnt,  'instance(s) restarted today in this site\033[0m'

1 comment:

  1. Hi Pavan ,

    i am new to the weblogic . please tell me how can i use the script ?
    in which language is used in weblogic?


Please write your comment here

Popular Posts

Oracle WebLogic Administration Course

Oracle WebLogic Administration Course
WebLogic Training