Listing running applications on running servers using scripting

 

Overview

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

  • Start wsadmin

  • Using 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=' +  me 
                                                             + ',node=' 
                                                             + nname 
                                                             + ',process=' 
                                                             + sname 
                                                             + ',*')
    
              osname = AdminControl.invoke(jvm, 'getProperty', 'os.name')
    
              print " " + sname 
                        + " " 
                        +  ptype 
                        + " has pid " 
                        + pid 
                        + "; state: " 
                        + state 
                        + "; on " 
                        + ame 
                        + "\n"
    
              ###
              ### find the applications running on this server and 
              ### display the application name. 
              ###
    
              apps = AdminControl.queryNames('type=Application,cell=' + me 
                                                                      + ',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"
           #endFor
         #endFor
       #endFor
     #endFor
    

  • Example output

    Number of running servers on node mynode: 2
    mynode (NodeAgent) has pid 3592; state: STARTED; on Windows 2000
    Number of applications running on mynode: 0
    ----------------------------------------------------
    
    server1 (ManagedProcess) has pid 3972; state: STARTED; on Windows 2000
    Number of applications running on server1: 0
    ----------------------------------------------------
    
    Number of running servers on node mynodeManager: 1
    dmgr (DeploymentManager) has pid 3308; state: STARTED; on Windows 2000
    Number of applications running on dmgr: 2
    adminconsole
    filetransfer
    ----------------------------------------------------
    
    


 

See Also


AdminConfig object for scripted administration
AdminControl object for scripted administration

 

See Also


Commands for the AdminConfig object
Commands for the AdminControl object