使用 wsadmin 脚本编制列示运行服务器上运行的应用程序
使用 wsadmin 工具和脚本编制来列示所有运行的服务器上的所有运行的应用程序。
开始之前
开始本任务前,wsadmin 工具必须正在运行。有关更多信息,请参阅“使用 wsadmin 脚本编制来启动 wsadmin 脚本编制客户机”主题。
关于此任务
使用下面的示例列示每个单元的每个节点上运行的所有服务器上的所有在运行的应用程序。
过程
- 使用 Jacl:
*Provide this example as a Jacl script file and run it with the "-f" option: 1 #---------------------------------------------------------------- 2 # lines 4 and 5 find all the cell and process them one at a time 3 #---------------------------------------------------------------- 4 set cells [$AdminConfig list Cell] 5 foreach cell $cells { 6 #----------------------------------------------------------------------- 7 # lines 10 and 11 find all the nodes belonging to the cell and 8 # process them at a time 9 #----------------------------------------------------------------------- 10 set nodes [$AdminConfig list Node $cell] 11 foreach node $nodes { 12 #-------------------------------------------------------------- 13 # lines 16-20 find all the running servers belonging to the cell 14 # and node, and process them one at a time 15 #-------------------------------------------------------------- 16 set cname [$AdminConfig showAttribute $cell name] 17 set nname [$AdminConfig showAttribute $node name] 18 set servs [$AdminControl queryNames type=Server,cell=$cname,node=$nname,*] 19 puts "Number of running servers on node $nname: [llength $servs]" 20 foreach server $servs { 21 #--------------------------------------------------------- 22 # lines 25-31 get some attributes from the server to display; 23 # invoke an operation on the server JVM to display a property. 24 #--------------------------------------------------------- 25 set sname [$AdminControl getAttribute $server name] 26 set ptype [$AdminControl getAttribute $server processType] 27 set pid [$AdminControl getAttribute $server pid] 28 set state [$AdminControl getAttribute $server state] 29 set jvm [$AdminControl queryNames type=JVM,cell=$cname, node=$nname,process=$sname,*] 30 set osname [$AdminControl invoke $jvm getProperty os.name] 31 puts " $sname ($ptype) has pid $pid; state: $state; on $osname" 32 j3 #--------------------------------------------------------- 34 # line 37-42 find the applications running on this server and 35 # display the application name. 35 #--------------------------------------------------------- 37 set apps [$AdminControl queryNames type=Application, cell=$cname,node=$nname,process=$sname,*] 38 puts " Number of applications running on $sname: [llength $apps]" 39 foreach app $apps { 40 set aname [$AdminControl getAttribute $app name] 41 puts " $aname" 42 } 43 puts "----------------------------------------------------" 44 puts "" 45 46 } 47 } 48 }
- 使用 Jython:
* Provide this example as a Jython script file and run it with the "-f" option: # ------------------------------------------------------ # get line separator import java.lang.System as sys lineSeparator = sys.getProperty('line.separator') cells = AdminConfig.list('Cell').split() for cell in cells: #---------------------------------------------------------------- # lines 13 and 14 find all the nodes belonging to the cell and # process them at a time #----------------------------------------------------------------- nodes = AdminConfig.list('Node', cell).split() for node in nodes: #-------------------------------------------------------------- # lines 19-23 find all the running servers belonging to the cell # and node, and process them one at a time #-------------------------------------------------------------- cname = AdminConfig.showAttribute(cell, 'name') nname = AdminConfig.showAttribute(node, 'name') servs = AdminControl.queryNames('type=Server,cell=' + cname + ',node=' + nname + ',*').split() print "Number of running servers on node " + nname + ": %s \n" % (len(servs)) for server in servs: #--------------------------------------------------------- #lines 28-34 get some attributes from the server to display; # invoke an operation on the server JVM to display a property. #--------------------------------------------------------- sname = AdminControl.getAttribute(server, 'name') ptype = AdminControl.getAttribute(server, 'processType') pid = AdminControl.getAttribute(server, 'pid') state = AdminControl.getAttribute(server, 'state') jvm = AdminControl.queryNames('type=JVM,cell=' + cname + ',node=' + nname + ',process=' + sname + ',*') osname = AdminControl.invoke(jvm, 'getProperty', 'os.name') print " " + sname + " " + ptype + " has pid " + pid + "; state: " + state + "; on " + osname + "\n" #--------------------------------------------------------- # line 40-45 find the applications running on this server and # display the application name. #--------------------------------------------------------- apps = AdminControl.queryNames('type=Application,cell=' + cname + ',node=' + nname + ',process=' + sname + ',*').splitlines() print "Number of applications running on " + sname + ": %s \n" % (len(apps)) for app in apps: aname = AdminControl.getAttribute(app, 'name') print aname + "\n" print "----------------------------------------------------" print "\n"
结果
示例输出:
Number of running servers on node mynode: 2
mynode (NodeAgent) has pid 3592; state: STARTED; on Windows Vista
Number of applications running on mynode: 0
----------------------------------------------------
server1 (ManagedProcess) has pid 3972; state: STARTED; on Windows Vista
Number of applications running on server1: 0
----------------------------------------------------
Number of running servers on node mynodeManager: 1
dmgr (DeploymentManager) has pid 3308; state: STARTED; on Windows Vista
Number of applications running on dmgr: 2
adminconsole
filetransfer
----------------------------------------------------
相关任务:


http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=txml_listrunapp
文件名:txml_listrunapp.html