Using 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 }
Using 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"