# ==============================================================
# domain_status.py
# ==============================================================
# ==============================================================
# recuperation des arguments passe en option
#
# ==============================================================
adminurl = sys.argv[1]
username = sys.argv[2]
passwd = sys.argv[3]
# ==============================================================
# connection a admin weblogic
#
# ==============================================================
def connect_weblogic(username,password,adminurl):
try :
connect(username,password,adminurl)
except :
print 'Cannot connect to ' + adminurl
exit()
# ==============================================================
# lecture des MBEAN
#
# ==============================================================
def getMBeanByType(mbeanType):
return adminHome.getMBeansByType(mbeanType)
# ==============================================================
# formatage de date
#
# ==============================================================
def fmtDate(t):
from time import *
return strftime("%d/%m
%H:%M:%S",localtime(t))
# ==============================================================
# connexion et affichage des status
#
# ==============================================================
redirect("/dev/null",toStdOut='false')
connect_weblogic(username,passwd,adminurl)
listeServer = ls('Servers',returnMap='true')
domainRuntime()
listeRunning = ls('ServerRuntimes',returnMap='true')
fmt = "%11s %10s %18s %6s %5s %5s %7s %7s %11s %10s %10s %15s"
print fmt %
("Server","State","Uptime","Active","Idle","Total","Hogging","Standby","Pending
Req","QueueLength","Throughput","Completed Req")
for srv in listeServer:
if listeRunning.size()>0 and
listeRunning.indexOf(srv)>=0:
cd("/ServerRuntimes/"+srv)
uptime = cmo.getActivationTime()/1000
tp = getMBean('ThreadPoolRuntime/ThreadPoolRuntime')
thp = "%.1f" % tp.getThroughput()
active = 0
import re
for thrd in tp.getExecuteThreads():
if not re.search("ACTIVE",thrd.getName()) is None:
active = active +1
print fmt %
(srv,cmo.getState(),fmtDate(uptime),str(active),str(tp.getExecuteThreadIdleCount()),str(tp.getExecuteThreadTotalCount()),
str(tp.getHoggingThreadCount()),str(tp.getStandbyThreadCount()),str(tp.getPendingUserRequestCount()),str(tp.getQueueLength()),
str(thp),str(tp.getCompletedRequestCount()) )
else:
print fmt %
(srv,"SHUTDOWN","N/A","N/A","N/A","N/A","N/A","N/A","N/A","N/A","N/A","N/A")
# ==============================================================
# déconnexion
#
# ==============================================================
disconnect()
exit()
Vous pouvez lancer ce script depuis un script shell :
#! /bin/sh
. /opt/platform103/weblogic/wlsserver_10.3/server/bin/setWLSEnv.sh >
/dev/null 2>&1
java weblogic.WLST $*
exit $?
Pour le lancer :
./lancwlst.sh domain_status.py t3://127.0.0.1:7001 reader reader
Initializing WebLogic Scripting Tool (WLST) ...
Welcome to WebLogic Server Administration Scripting Shell
Type help() for help on available commands
Server
State Uptime Active Idle
Total Hogging Standby Pending Req QueueLength Throughput Completed
Req
server RUNNING 01/09
08:54:37 1
0 6
0
5
0
0
7.5 95204
admin RUNNING 31/08
17:51:28 2
1 9
0
7
0
0
11.0 584537
Et Voilà