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
loadProperties(">
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):
srvlist=site.split(',')
# setting up the dictionary elements now...
for y in srvlist:
i=y.split('#')
ud[i[0]]=i[1]
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
site=int(showMenu())
if site == 1:
u=getSite(SITE1)
elif site == 2:
u=getSite(SITE2)
elif site == 3:
u=getSite(SITE3)
# Add as much sites(physical locations) you have in your domain...
else:
print 'exiting from the script now...'
disconnect()
stopRedirect()
exit()

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

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


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?

    ReplyDelete

Please write your comment here

Popular Posts

Oracle WebLogic Administration Course

Oracle WebLogic Administration Course
WebLogic Training

Followers