Search This Blog

Showing posts with label ActivationTime. Show all posts
Showing posts with label ActivationTime. Show all posts

Thursday, December 2, 2010

Switching from WLST edit tree

An online buddy pinged me today and asking 'Urgent!! I am in WLST edit session, I want to come out I don't know how to do that'. I asked did you done the modifications to the configuration?. He said 'yep! I want regular prompt from this edit!>'. I asked to try save(), activate() he said it don't works!!

While working on edit tree you might gone some where and your remote connection got disconnected, re-entering to the edit session you can use startEdit().

Oh.. ohh what else we can do? I had a thought he might want to navigate from edit tree to some other mbean tree. I asked him to try ' serverConfig() '. He is happily said it Works!!

Best alternate is  using currentTree(), This command enables you to store the current location in the hierarchy and easily return to it after browsing.

wls:/testdomain/edit> loc=currentTree()
wls:/testdomain/edit> serverRuntime()
Location changed to serverRuntime tree. This is a read-only tree with
ServerRuntimeMBean as the root.
For more help, use help('serverRuntime')
 
wls:/testdomain/serverRuntime> loc()
wls:/testdomain/edit>

What is learning here?
WLST is having various options for MBeans traversals. Basic differences I understand are:
1. Read-only tree
2. Editable tree

Read only trees
once you connected to the WebLogic domain first you are in the serverConfig tree it is a read-only tree. Similarly you can navigate on the such read-only trees serverRuntime, domainRuntime,

To save the changes which you made on the current configuration save(). After saving you can continue the changes to the configuration. You make the changes permanent by activate() the configuration. When something configured wrong on your interactive WLST session you can use say UNDO for your settings by cancelEdit('y'). It is like clicking on WebLogic administration console at the change control 'Undo All changes' button.

Reference:
http://download.oracle.com/docs/cd/E13222_01/wls/docs92/config_scripting/reference.html#wp1179175
http://weblogicserver.blogspot.com/2009/03/check-for-resourceconfiguration.html

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()


Popular Posts