* Provide this example as a Jython script file and run it with the "-f" option:
1 #----------------------------------------------------------------
2 # lines 7 and 8 find all the cell and process them one at a time
3 #----------------------------------------------------------------
4 # get line separator
5 import java.lang.System as sys
6 lineSeparator = sys.getProperty('line.separator')
7 cells = AdminConfig.list('Cell').split(lineSeparator)
8 for cell in cells:
9 #----------------------------------------------------------------
10 # lines 13 and 14 find all the nodes belonging to the cell and
11 # process them at a time
12 #-----------------------------------------------------------------
13 nodes = AdminConfig.list('Node', cell).split(lineSeparator)
14 for node in nodes:
15 #--------------------------------------------------------------
16 # lines 19-23 find all the running servers belonging to the cell
17 # and node, and process them one at a time
18 #--------------------------------------------------------------
19 cname = AdminConfig.showAttribute(cell, 'name')
20 nname = AdminConfig.showAttribute(node, 'name')
21 servs = AdminControl.queryNames('type=Server,cell=' + cname +
',node=' + nname + ',*').split(lineSeparator)
22 print "Number of running servers on node " +
nname + ": %s \n" % (len(servs))
23 for server in servs:
24 #---------------------------------------------------------
25 # lines 28-34 get some attributes from the server to display;
26 # invoke an operation on the server JVM to display a property.
27 #---------------------------------------------------------
28 sname = AdminControl.getAttribute(server, 'name')
29 ptype = AdminControl.getAttribute(server, 'processType')
30 pid = AdminControl.getAttribute(server, 'pid')
31 state = AdminControl.getAttribute(server, 'state')
32 jvm = AdminControl.queryNames('type=JVM,cell=' +
cname + ',node=' + nname + ',process=' + sname + ',*')
33 osname = AdminControl.invoke(jvm, 'getProperty', 'os.name')
34 print " " + sname + " " + ptype + " has pid " + pid +
"; state: " + state + "; on " +
osname + "\n"
35
36 #---------------------------------------------------------
37 # line 40-45 find the applications running on this server and
38 # display the application name.
39 #---------------------------------------------------------
40 apps = AdminControl.queryNames('type=Application,cell=' +
cname + ',node=' + nname + ',process=' + sname + ',*').
split(lineSeparator)
41 print "Number of applications running on " + sname +
": %s \n" % (len(apps))
42 for app in apps:
43 aname = AdminControl.getAttribute(app, 'name')
44 print aname + "\n"
45 print "----------------------------------------------------"
46 print "\n"