Network Deployment (Distributed operating systems), v8.0 > Scripting the application serving environment (wsadmin) > Manage servers and nodes with scripting


List running applications on running servers using wsadmin scripting

Use wsadmin.sh and scripting to list all the running applications on all the running servers.

Use the following example to list all the running applications on all the running servers on each node of each cell.

### Jacl

#----------------------------------------------------------------
# Find all the cell and process them one at a time
#----------------------------------------------------------------
set cells [$AdminConfig list Cell]
foreach cell $cells {
   #-----------------------------------------------------------------------
   # find all the nodes belonging to the cell and
   # process them at a time
   #-----------------------------------------------------------------------
   set nodes [$AdminConfig list Node $cell]
   foreach node $nodes {
      #--------------------------------------------------------------
      # find all the running servers belonging to the cell
      # and node, and process them one at a time
      #--------------------------------------------------------------
      set cname [$AdminConfig showAttribute $cell name]
      set nname [$AdminConfig showAttribute $node name]
      set servs [$AdminControl queryNames type=Server,cell=$cname,node=$nname,*]
      puts "Number of running servers on node $nname: [llength $servs]"
      foreach server $servs {
          #---------------------------------------------------------
          # Get some attributes from the server to display;
          # invoke an operation on the server JVM to display a property.
          #---------------------------------------------------------
          set sname [$AdminControl getAttribute $server name]
          set ptype [$AdminControl getAttribute $server processType]
          set pid   [$AdminControl getAttribute $server pid]
          set state [$AdminControl getAttribute $server state]
          set jvm [$AdminControl queryNames type=JVM,cell=$cname,  
          node=$nname,process=$sname,*]
          set osname [$AdminControl invoke $jvm getProperty os.name]
          puts "  $sname ($ptype) has pid $pid; state: $state; on $osname"

          #---------------------------------------------------------
          # Find the applications running on this server and
          # display the application name.
          #---------------------------------------------------------
          set apps [$AdminControl queryNames type=Application,  
          cell=$cname,node=$nname,process=$sname,*]
          puts "  Number of applications running on $sname: [llength $apps]"
          foreach app $apps {
             set aname [$AdminControl getAttribute $app name]
             puts "    $aname"
          }
          puts "----------------------------------------------------"
          puts ""

       }
    }
 }

### Jython


#----------------------------------------------------------------
# Find all the cell and process them one at a time
#----------------------------------------------------------------
# get line separator
import  java.lang.System  as  sys
lineSeparator = sys.getProperty('line.separator')
cells = AdminConfig.list('Cell').split(lineSeparator)
for cell in cells:
    #----------------------------------------------------------------
    # find all the nodes belonging to the cell and
    # process them at a time
    #-----------------------------------------------------------------
    nodes = AdminConfig.list('Node', cell).split(lineSeparator)
    for node in nodes:
       #--------------------------------------------------------------
       # 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(lineSeparator)
       print "Number of running servers on node " + nname + ": %s \n" % (len(servs))
       for server in servs:
         #---------------------------------------------------------
         # 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 + ',*').split(lineSeparator)
         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"


Results

Example output:

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
----------------------------------------------------


Use the wsadmin scripting AdminConfig object for scripted administration
Use the wsadmin scripting AdminControl object for scripted administration
Start the wsadmin scripting client using wsadmin.sh


Related


Commands for the AdminConfig object using wsadmin.sh
Commands for the AdminControl object using wsadmin.sh

+

Search Tips   |   Advanced Search