List running applications on running servers

 




###
### lines 4 and 5 find all the cell and process them one at a time
###

set cells [$AdminConfig list Cell]
foreach cell $cells {

   ###
   ### lines 10 and 11 find all the nodes belonging to the cell and 
   ### process them at a time
   ###

  set nodes [$AdminConfig list Node $cell]
  foreach node $nodes {

     ###
     ### lines 16-20 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 {

         ###
         ### lines 25-31 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"

         ###
         ### line 37-42 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 ""

      } 
   }
}