'분류 전체보기'에 해당되는 글 125건
- 2014.08.26 db connection
- 2014.08.25 pythons programming
- 2014.08.22 쉘 프로그래밍
- 2014.08.21 javascript 예제6
- 2014.08.21 javascript 예제4
- 2014.08.20 JVM Monitoring with WLST
- 2014.08.20 WLST Thread Count
- 2014.08.19 WebLogic Scripting Tool (WLST) Overview
- 2014.08.19 Server State using WLST
- 2014.08.19 JDBC Monitoring
파이썬은 1991년 프로그래머인 귀도 반 로섬 이 발표한 고급 프로그래밍 언어로, 플랫폼 독립적이며 인터프리터식, 객체지향적, 동적 타이핑 대화형 언어
참고사이트 : https://www.python.org, www.pycon.kr
'Weblogic' 카테고리의 다른 글
JVM Heap Size and Garbage Collection (0) | 2014.09.19 |
---|---|
weblogic 12c (0) | 2014.08.27 |
JVM Monitoring with WLST (0) | 2014.08.20 |
WLST Thread Count (0) | 2014.08.20 |
WebLogic Scripting Tool (WLST) Overview (0) | 2014.08.19 |
int1 -eq int2 |
int1이 int2와 같다면 True 리턴 |
|
int1 -ge int2 |
int1이 int2보다 크거나 같은면 True 리턴 |
|
int1 -gt int2 |
int1이 int2보다 크면 True 리턴 |
|
int1 -le int2 |
int1이 int2보다 작거나 같으면 True 리턴 |
|
int1 -lt int2 |
int1이 int2보다 작으면 True 리턴 |
|
int1 -ne int2 |
int1이 int2과 다르면 True 리턴 |
|
-d filename |
filename이 디렉토리면 True 리턴 |
|
-f filename |
filename이 파일이면 True 리턴 |
|
-r filename |
filename이 프로세스에 의해 읽혀진다면 True 리턴 |
|
-s filename |
filename이 길이가 0이 아니면 True 리턴 |
|
-w filename |
filename이 프로세스에 의해 쓰여질 수 있다면 True 리턴 |
|
-x filename |
filename이 수행 가능하다면 True 리턴 |
|
논리
If...then
if [ expression ]
then
commands
fi
반복(루프, loop)
for var1 in list
do
commands
done
------------------------------------------------------------------------
for a in 1 2 3 4 5 6
do
cd /app/domains/cuiSvr?$a/bin
./startNode.sh
sleep 5
done
함수
fname(){
commands
}
'Linux' 카테고리의 다른 글
netstat (0) | 2014.08.29 |
---|---|
mpstat (0) | 2014.08.27 |
sysctl.conf (0) | 2014.08.27 |
OS 버전 확인 (0) | 2014.08.26 |
db connection (0) | 2014.08.26 |
예제 6. 반복문
<html> <body> <B stype="font-size:201 color:red"> while 문을 이용해 1부터 10까지 합 구하기<br> -3, 6, 9 제외-</B><hr><br> <script type="text/javascript"> var sum=0, i=0, end=10; while (i<end){ ++i; alert(i); if(0 == i%3){ continue; }else{ alert("sum=>"+sum) } } document.write("=<b>" +sum+ "</b">); </script> </html> |
* for in 반복문
- 배열이나 객체를 더욱 쉽게 다룰 수 있음
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>for_in</title>
<script type="text/javascript">
var array = ['아이폰5', '아이폰5S', '아이폰5C', '갤럭시노트3', '넥서스5', 'G2'];
for (var i in array) { // for (var i = 0; i < array.length; i++)
alert(array[i]);
}
</script>
</head>
<body>
</body>
</html>
'Javascript' 카테고리의 다른 글
javascript 예제4 (0) | 2014.08.21 |
---|
예제 4. 외부주입
<html> <head></head> <body> <script type="text/javascript" src="TEST.js"></script> </html> |
'Javascript' 카테고리의 다른 글
javascript 예제6 (0) | 2014.08.21 |
---|
JVM Monitoring with WLST
Hey dear WLAs, here I am with a new assignment for JVM monitoring. The fresh production environment setup with Clustered Domain with multiple physical locations with multiple UNIX machines.
The WebLogic capacity planning going on and various low memory or OutOfMemory issues araising when new migration happen from WebLogic 8.1 to 9.2 MP3. To identity how the Garbage Collection working? How much free memory is available for each instance? This can be known with JVM statistics, which inturn tuning the JVM parameters or reset is easy for decide.
I had found a JVM monitoring script that is best suites to my WebLogic environment.
This script is able to get all server instances JVM statistics with a single run. The beauty of WLST is that it runs on single JVM and provides us the required output with the help of domain, server Runtime MBeans, which are supported by WebLogic 9.x and later releases by default supporting JMX 1.2, which has many good features to control and monitor the Runtime Environment of a WebLogic Server instance.
Here have the script which I have modified as per my task there is little C-style customization done with Python language syntax. I mean in Jython which actally used in the WLST.
This could be further refined but ... short of time I am pubishing this
Enjoy!!! Jython/WLST SCRIPTING
#You can create key files
ucf='keypath/xuserconfig.key'
ukf='keypath/xkeyfile.key'
admurl = "t3://hostingdns.com:port"
# This module is for retrieve the JVM statistics
def monitorJVMHeapSize():
connect(userConfigFile=ucf, userKeyFile=ukf, url=admurl)
# alternate connect('user', 'passwd', 'adminurl')
serverNames = getRunningServerNames()
domainRuntime()
print ' TotalJVM FreeJVM Used JVM'
print '=============================================='
for name in serverNames:
try:
cd("/ServerRuntimes/"+name.getName()+"/JVMRuntime/"+name.getName())
freejvm = int(get('HeapFreeCurrent'))/(1024*1024)
totaljvm = int(get('HeapSizeCurrent'))/(1024*1024)
usedjvm = (totaljvm - freejvm)
print '%14s %4d MB %4d MB %4d MB ' % (name.getName(),totaljvm, freejvm, usedjvm)
except WLSTException,e:
pass
# This module for managed Servers list
def getRunningServerNames():
domainConfig()
return cmo.getServers()
if __name__== "main":
monitorJVMHeapSize()
disconnect()
'Weblogic' 카테고리의 다른 글
weblogic 12c (0) | 2014.08.27 |
---|---|
pythons programming (0) | 2014.08.25 |
WLST Thread Count (0) | 2014.08.20 |
WebLogic Scripting Tool (WLST) Overview (0) | 2014.08.19 |
Server State using WLST (0) | 2014.08.19 |
-
######################################################
-
# This script is used to monitor all servers
-
# Author: Pavan Devarakonda
-
# Date: 28th April 2009
-
######################################################
-
import thread
-
# Configured user credentials with storeUserConfig
-
ucf='keypath/xuserconfig.key'
-
ukf='keypath/xkeyfile.key'
-
admurl = "t3://hostingdns.com:port"
-
def monitorThrds():
-
connect(userConfigFile=ucf, userKeyFile=ukf, url= admurl )
-
serverNames = getRunningServerNames()
-
domainRuntime()
-
print 'EXECUTE QUEUES'
-
print ' '
-
print 'Execute Total Current PendRequest ServicedRequest'
-
print 'QueueName Count IdleCount CurrCount TotalCount '
-
print '===========**=======**=================================='
-
for snam in serverNames:
-
try:
-
cd("/ServerRuntimes/" + snam.getName() + "/ExecuteQueueRuntimes/weblogic.kernel.Default")
-
totcnt=get('ExecuteThreadTotalCount')
-
idlecnt = get('ExecuteThreadCurrentIdleCount')
-
pndcnt =get('PendingRequestCurrentCount')
-
sevcnt = get('ServicedRequestTotalCount')
-
print '%10s %4d %4d %4d %16d' % (snam.getName(), totcnt, idlecnt, pndcnt, sevcnt)
-
except WLSTException,e:
-
# this typically means the server is not active, just ignore
-
pass
-
def getRunningServerNames():
-
domainConfig()
-
return cmo.getServers()
-
if __name__== "main":
-
monitorThrds()
-
disconnect()
'Weblogic' 카테고리의 다른 글
pythons programming (0) | 2014.08.25 |
---|---|
JVM Monitoring with WLST (0) | 2014.08.20 |
WebLogic Scripting Tool (WLST) Overview (0) | 2014.08.19 |
Server State using WLST (0) | 2014.08.19 |
JDBC Monitoring (0) | 2014.08.19 |
WebLogic Scripting Tool (WLST) Overview
After being in the development team one of my buddy asked me "your blogs are very nice, I want to learn WLST. But where to start? " My answer for all my blog readers who want to encourage newbies in WLST can pass this post. Currently WLST is supporting Application Servers are listed as follows:
- WebLogic 8.1
- BEA WebLogic 9.0
- BEA WebLogic 9.1
- BEA WebLogic 9.2
- BEA WebLogic 10.0
- Oracle WebLogic 10g R3
- Oracle WebLogic 11gR1
- Oracle WebLogic 11gR1 PatchSet 1 (10.3.1)
- Oracle WebLogic 11gR1 PatchSet 2 (10.3.2)
- Oracle WebLogic 11gR1 PatchSet 3 (10.3.3)
- Oracle WebLogic 12c
WLST Features indentation - Clear Sytax
The WLST programming structure follows strict syntax indentation and it is the same structure as in Python programming. As per my experiances with WLST it can be divided into four parts
- Importing section
- Global variables
- Definations - class/function
- Main program uses above sections
Import section for Reuse
importing WLST libraries includes Python standard libraries and thousands of new Jython libraries also included. You can have Java packages as module imports which gives you flexible programming.
While writing a WLST script, the file can be store with the extension .py are called python modules. We can reuse the external language such as Java methods into our WLST script you can use import statement for this. Here is the syntaxes that you can use.
import module from module import submodule from . import submodule
You can write a WLST script that uses command line aruguments using sys module sys.args.
WLST Datatypes - Global variables
In WLST you can define the global variables on the top of the program that can be used across all the functions defined in the script. On the other hand you can define the variables in the function definitions that can be treated as local to the function, Jython programming language supported datatypes all can be used it supports- Base Datatypes: integer, float, long, char, str, bool
- Collection Types: list, dictionary, tuple, sequances, maps etc
- Object types: Python objects and Java package objects
1
2
3
4
5
6
7
8
9
10 |
wls: / offline> # VAR CAN CHANGE INTO MANY TYPES wls: / offline> var = 10 wls: / offline> print var 10 wls: / offline> var = 'Busy in WLST' wls: / offline> print var Busy in WLST wls: / offline> var = [ 1 , 2 , 3 ] wls: / offline> print var [ 1 , 2 , 3 ] |
Class in WLST
Object oriented scripting can be defined and can be reusable with creation of objects.
1
2
3
4
5
6
7 |
class CLASSNAME:
def __init__(): #like C++ constructor
self .name
do something initially
def function1():
do some task |
1
2
3 |
wls: / offline> class test: ... u,p = 'weblogic' , 'vybhav@28' ... |
1
2
3 |
wls: / offline> t = test() wls: / offline> print t.u,t.p weblogic vybhav@ 28 |
1
2
3 |
wls: / offline> t.u = 'vasuakka' wls: / offline> t.u 'vasuakka' |
Function definitions in WLST
How to define a Function in WLST? It is simple it starts with keyword ‘def’, you need to give a name of the function followed by number of argument and a colon. After this you need to give a tab space indentation that indicates the function block. You can add text to tell about what this function will do. Then you can add number of WLST statements or control flow statements. At the bottom of the function you can return a value or you leave that line, it is optional.Now, let’s experiment with function definition for conversion of Kilobytes to megabytes. The logic of this function is that we can get the megabyte value when you pass the argument as kilobyte this will be divided by 1024.
1
2
3
4
5
6 |
wls: / offline> def kb2MB(kb): ... mb = kb / 1024 ... return mb ... wls: / offline> print kb2MB( 2048 ) 2 |
WLST Operators
You WLST commands statements not only JMX accessing functions we need to use some of the Python programming control flows in it. To use the control flow you must know about what kind of operations you can do in WLST. So let us see some of them are:Comparition operators
This opertators we can use in regular if statements or while statements
1 |
= = , >, <, < = , = > |
In WLST the variable can be empty or zero values are treated as "", 0, None, 0.0, [], and {}. So you need to be careful when you define a variable and moved the values of variables.
Iterations in WLST Scripts
We can see the major types of WLST iterations control flows available such as 'for loop' and 'while loop'.The range function
When you are using for-loop best trick to use with range built in Python function. It will take three different optional arguments and gives you different variety of values in the range of list as output.* Until the given number
* From one particular value to another
* From one value to another with increment by value
Experimenting with range function to understand all its capabilities The range command always start from the 0 if you pass single argument that is considered as number of values you want as output.
1
2
3
4
5
6
7
8
9 |
wls: / offline> R = range ( 11 ) wls: / offline> R [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ] wls: / offline> R = range ( 2 , 10 , 2 ) wls: / offline> R [ 2 , 4 , 6 , 8 ] wls: / offline> R = range ( 2 , 10 , 3 ) wls: / offline> R [ 2 , 5 , 8 ] |
While loop control
This loop control works as same as in C programming style loop. The execution of while loop should not have any control on the variable that is used for iterate the loop. You need to initialize, check the termination condition and in the while loop block it should be iterated by increase or decrease as per program needs.![]() |
WLST While loop - WLST for loop |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 |
wls: / offline> while i< 10 : ... print 'jms' + str (i) + '_server' ... i = i + 1 ...
jms0_server jms1_server jms2_server jms3_server jms4_server jms5_server jms6_server jms7_server jms8_server jms9_server |
The 'for loop' in WLST
Every scripting favourite iterator is for loop. Let us dive into some of the examples with it. The example of the 'for loop' in WLST is given below
1
2
3
4
5
6
7
8
9
10
11
12
13
14 |
wls: / offline> slist = range ( 1 , 11 ) wls: / offline> for i in slist: ... print 'managed' + str (i) + '_server' ... managed1_server managed2_server managed3_server managed4_server managed5_server managed6_server managed7_server managed8_server managed9_server managed10_server |
How WLST script Execution works?
Here I am going to explain with the following picture, how the Python script will be interpreted and internally compiled to java code and then Byte code so that it can be executable on JVM.![]() |
WLST Execution process |
You might wonder by seeing this Chines WLST link, but it is worthy to see in google chrome. Because the web-page is from china and entire page is in chineese language. If you have Google Chrome it will give you translate on top of the page you can choose your choice of language and have knowledge on WLST :)
Here I am sharing the wonderful presentation about WLST overview. Check this following SlideShare Presentation: it's pretty informative, it was delivered by James Bayer who is the technical expert from Oracle. Especially I more impressed myself to see the 47 slide saying about THIS blog as one of the web reference.
Thankyou for visiting this post, feel free to post your comments after
'Weblogic' 카테고리의 다른 글
JVM Monitoring with WLST (0) | 2014.08.20 |
---|---|
WLST Thread Count (0) | 2014.08.20 |
Server State using WLST (0) | 2014.08.19 |
JDBC Monitoring (0) | 2014.08.19 |
weblogic coherence (0) | 2014.08.19 |
Server State using WLST
While trouble shooting administrator need to check the status of all server instances. This is the basic need when the all the servers are in bounced for production code move. This same script can be applicable for the pre-production or staging environment too. WLST provides the built-in methods, which gives the status of the Server instance or servers in a Cluster. Here we will deal with individual instance wise data.
![]() |
WebLogic Server Life cycle state diagram |
![]() |
ServerLIfecycleRuntime Mbean tree |
Using above shown MBean hierarchy we can fetch the all WebLogic domain server instance's states. If your production WebLogic domain consists of two digit (eg. 60 instances) or three digit number (eg. 120 instances) of managed server then, it is difficult to see all server’s state at once. Weblogic Administration console is unable to show all the servers in the domain on a single page. Navigating in between also a time eating process so think! think better way!! WLST has the solution.
To get the status of all servers in the domain can be obtained with the following steps
1. Connect to the Admin Server
2. Fetch the server list from the domain runtime MBean
3. Iterate the loop and get the state of each managed server with Server Life Cycle Runtime MBean
4. Repeat if required the step 3 as per the user input
5. Finally disconnect
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42 |
################################################## # This script is used to check the status of all WL instances including the admin ###########################################################
def conn():
UCF = '/path/.AdminScripts/userConfigFile.sec'
UKF = '/path/.AdminScripts/userKeyFile.sec'
try :
connect(userConfigFile = UCF, userKeyFile = UKF, url = admurl)
except ConnectionException,e:
print '\033[1;31m Unable to find admin server...\033[0m'
exit()
def ServrState():
print 'Fetching state of every WebLogic instance' #Fetch the state of the every WebLogic instance
for name in serverNames:
cd( "/ServerLifeCycleRuntimes/" + name.getName())
serverState = cmo.getState()
if serverState = = "RUNNING" :
print 'Server ' + name.getName() + ' is :\033[1;32m' + serverState + '\033[0m'
elif serverState = = "STARTING" :
print 'Server ' + name.getName() + ' is :\033[1;33m' + serverState + '\033[0m'
elif serverState = = "UNKNOWN" :
print 'Server ' + name.getName() + ' is :\033[1;34m' + serverState + '\033[0m'
else :
print 'Server ' + name.getName() + ' is :\033[1;31m' + serverState + '\033[0m'
quit()
def quit():
print '\033[1;35mRe-Run the script HIT any key..\033[0m'
Ans = raw_input ( "Are you sure Quit from WLST... (y/n)" )
if (Ans = = 'y' ):
disconnect()
stopRedirect()
exit()
else :
ServrState()
if __name__ = = "main" :
redirect( './logs/Server.log' , 'false' )
conn()
serverNames = cmo.getServers()
domainRuntime()
ServrState() |
'Weblogic' 카테고리의 다른 글
WLST Thread Count (0) | 2014.08.20 |
---|---|
WebLogic Scripting Tool (WLST) Overview (0) | 2014.08.19 |
JDBC Monitoring (0) | 2014.08.19 |
weblogic coherence (0) | 2014.08.19 |
weblogic status check (0) | 2014.08.18 |
JDBC Monitoring
![]() |
JDBC Monitoring with LWLST script |
One fine morning we (WLA support Team) got an assignment, The summary of the assignment was to find "How the WebLogic server instance performing for a DataSource?". WebLogic 9.x onwards a DataSource is associated with a ConnectionPool (a pool of connections to the DB). If we monitor ConnectionPool, inturn it is nothing but monitoring a DataSource.
Of-course the task is not that easy, I have gone through various WebLogic forums to find a appropriate solution for this task.
Oracle WebLogic provides two ways to Monitor a Datasource
1. Monitoring Datasource server wise
2. Testing the Connection Pool
Here I am publishing the same script which Madan Noru/Satya prepared in the old bea fourms or ObjectMix forums. Only one thing is difference is that displaying pattern, I had created a separate header, so that output looks good to see in a table form. To make this possible I have used C-Style print command from Python Language. This format you can change as per your screen display size.
The script will retrieve the JDBC Connection Pool MBean using adminHome, which is deprecated object in WLST. The output of the script will gives you the values of the following attributes:
DataSource Name
- Maximum Capacity of the Connection Pool at Run-time
- Active Connections Current Count
- Active Connections High Count
- Wait Seconds High Count
- Waiting For Connection Current Count
- State of the Connection Pool
#=======================================================
# This script will monitor the JDBC CONNECTION POOL
# more details on this script contact: Pavan Devarkonda
#=======================================================
try
:
poolrtlist
=
adminHome.getMBeansByType(
'JDBCConnectionPoolRuntime')
//MBean에서 JDBCConnection 정보 가져옴
print
' '
print
' '
print
'JDBC CONNECTION POOLS'
print
' '
print
'Name Max Active Active WaitSecs Waiting State'
print
' capacity Current HighCnt HighCnt Count'
for
poolRT
in
poolrtlist:
pname
=
poolRT.getName()
pmaxcapacity
=
poolRT.getAttribute(
"MaxCapacity"
)
paccc
=
poolRT.getAttribute(
"ActiveConnectionsCurrentCount"
)
pachc
=
poolRT.getAttribute(
"ActiveConnectionsHighCount"
)
pwshc
=
poolRT.getAttribute(
"WaitSecondsHighCount"
)
pwfccc
=
poolRT.getAttribute(
"WaitingForConnectionCurrentCount"
)
pstate
=
poolRT.getAttribute(
"State"
)
print
'%10s %7d %7d %7d %7d %7d %10s'
%
(pname,pmaxcapacity,paccc,pachc, pwshc,pwfccc,pstate)
print
' '
except
:
print
'Error:'
dumpStack()
pass
disconnect()
'Weblogic' 카테고리의 다른 글
WebLogic Scripting Tool (WLST) Overview (0) | 2014.08.19 |
---|---|
Server State using WLST (0) | 2014.08.19 |
weblogic coherence (0) | 2014.08.19 |
weblogic status check (0) | 2014.08.18 |
WebLogic StuckThreadMaxTime (0) | 2014.06.16 |