+

Search Tips   |   Advanced Search

get_config.jacl

 

###
### get_config.jacl 
###
###
###  
###  Produce a short summary of some configuration
###  and runtime information about the WebSphere installation. 
###  
###  This is a bi-modal script: it can be included in the wsadmin 
###  command invocation like this:
###     
###     wsadmin.sh -username username -password password -f get_config.jacl all
###
###  or the script can be sourced from the wsadmin command line:
###
###     wsadmin> source get_config.jacl
###     wsadmin> get_config.jacl all
### 
###  The script expects one parameter:
###      arg1 - a flag -- either "all" or "config" 
###
 proc get_config {flag} {
  
  if {$flag == "config"} {
     set configonly 1
  } else {
     if {$flag == "all"} {
        set configonly 0
     } else {
        puts "Single argument must be \"all\" or \"config\""
        return
     }
  }



  ###
  ### set up globals
  ###
  global AdminControl
  global AdminConfig
  global AdminApp


  puts ""
  puts ""
  puts "WEBSPHERE APPLICATION SERVER CONFIGURATION SUMMARY"           
  puts "----------------------------------------------------"           
  puts ""


  ###
  ### Get the cells/nodes/servers 
  ###

  puts ""
  puts "CONFIGURED CELLS, NODES, AND SERVERS: "           
  puts "----------------------------------------------------"           
  puts ""

  set cells [$AdminConfig list Cell]
  puts "Number of cells: [llength $cells]"
  puts ""

  puts $cells

  foreach cell $cells {

     ###
     ### Get some attributes from the config for this cell --
     ### the name and the security enabled flag. 
     ###

     puts "Getting cell $cell"

     set cname [$AdminConfig showAttribute $cell name]

     if {$cname == ""} {
         puts "showAttribute cell returned empty"
         continue
     }


#     set sec [$AdminConfig list Security $cell]
#
#     if {$sec == ""} {
#         puts "list Security cell returned empty"
#         continue
#     }
#
#     set enabled [$AdminConfig showAttribute $sec enabled]
#
#     if {$enabled == ""} {
#         puts "showAttribute sec returned empty"
#         continue
#     }
#
#     puts "    $cname -- security enabled: $enabled"
#
#     puts ""
#     puts "Security information for cell $cname"
#     puts ""
#
#     set securityid [$AdminConfig getid /Cell:$cname/Security:/]
#
#     if {$securityid == ""} {
#         puts "getid cname Security returned empty"
#         continue
#     }
#
#     set xSecurity [$AdminConfig showall $securityid]
#
#     if {$xSecurity == ""} {
#         puts "showall securityid returned empty"
#         continue
#     }
#
#     puts $xSecurity


     ###
     ### Get a list of the nodes in this cell, and the name of each
     ###

     set nodes [$AdminConfig list Node $cell]

     if {$nodes == ""} {
         puts "list Node cell returned empty"
         continue
     }

     puts ""
     puts "Number of nodes in $cname: [llength $nodes]"
     puts ""

     foreach node $nodes {

        set nname [$AdminConfig showAttribute $node name]

        if {$nname == ""} {
            puts "showAttribute node returned empty"
            continue
        }

        puts "    $nname"


        ###
        ### Get a list of the servers on this node.  Use getObjectName
        ### to see if there is a running server for this config object. 
        ###

        set servs [$AdminConfig list Server $node]

        if {$servs == ""} {
            puts "list Server node returned empty"
            continue
        }

        puts ""

        puts "Number of servers in $nname: [llength $servs]"

        foreach server $servs {

           puts ""

           set sname [$AdminConfig showAttribute $server name]

           if {$sname == ""} {
               puts "showAttribute server returned empty"
               continue
           }

           set runserv [$AdminConfig getObjectName $server]

           if {[llength $runserv] > 0} {
              set state [$AdminControl getAttribute $runserv state]
              puts "    Server $sname is running; state is $state"
           } else {
              puts "    Server $sname is not running"
           }



           ###
           ### Get a list of the http transports on the server, and display 
           ### host and port information for them. 
           ###

           puts "" 
           set https [$AdminConfig list HTTPTransport $server]

           if {$https == ""} {
               puts "list HTTPTransport server returned empty"
               continue
           }

           puts "    $sname has [llength $https] HTTPTransports"

           foreach http $https {
              set add [$AdminConfig showAttribute $http address]

              if {$add == ""} {
                  puts "showAttribute http address returned empty"
                  continue
              }

              set host [$AdminConfig showAttribute $add host]

              if {$host == ""} {
                  puts "showAttribute add host returned empty"
                  continue
              }

              set port [$AdminConfig showAttribute $add port]

              if {$port == ""} {
                  puts "showAttribute add port returned empty"
                  continue
              }

              puts "port: $port on host \"$host\""
           }
        }
        puts "" 
     }


     ###
     ### Get a list of the ServerClusters and display it. 
     ###

     puts "" 
     set clusters [$AdminConfig list ServerCluster $cell]

     if {$clusters == ""} {
         puts "list ServerCluster cell returned empty"
         continue
     }

     puts "Number of ServerClusters in $cname: [llength $clusters]"
  
     foreach cluster $clusters {

        set clname [$AdminConfig showAttribute $cluster name]
        set memberlist [$AdminConfig showAttribute $cluster members]
        set members [lindex $memberlist 0]

        puts "Cluster $clname has [llength $members] members"

        foreach member $members {
           set mname [$AdminConfig showAttribute $member memberName]
           set weight [$AdminConfig showAttribute $member weight]
           puts "Member $mname has weight $weight"
        }
    }
  }




  ###
  ### Get the apps 
  ###

  puts "Getting apps"
  puts "----------------------------------------------------"           
  puts ""
  set apps [$AdminApp list]
  puts "Number of applications: [llength $apps]"
  puts ""
  puts $apps 


  if {$configonly} {
     return
  }


  ###
  ### What servers are running on each node, and what apps do they have? 
  ###

  puts ""
  puts "----------------------------------------------------"           
  puts "Running servers: "           

  foreach cell $cells {

     set cname [$AdminConfig showAttribute $cell name]

     if {$cname == ""} {
         puts "showAttribute cell name returned empty"
         continue
     }

     set nodes [$AdminConfig list Node $cell]

     if {$nodes == ""} {
         puts "list Node cell returned empty"
         continue
     }

     foreach node $nodes {

        set nname [$AdminConfig showAttribute $node name]

        if {$nname == ""} {
           puts "showAttribute node name returned empty"
           continue
        }

        set servs [$AdminControl queryNames type=Server,cell=$cname,node=$nname,*]

        if {$servs == ""} {
           puts "queryNames cname nname returned empty"
           continue
        }

        puts ""
        puts "Number of running servers on node $nname: [llength $servs]"
        puts ""

        foreach server $servs {


           ###
           ### Get some attributes from the server to display; also 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"


           if {$sname == "nodeagent"} {
               continue
           }
         

           ###
           ### Use getConfigId to see if there is config data for this 
           ### server.
           ###

           set configserv [$AdminControl getConfigId $server]

           if {$configserv == ""} {
              puts "getConfigId server returned empty"
              continue
           }

           if {[llength $configserv] > 0} {
              puts "$sname is configured."
           } else {
              puts "$sname is not configured; configuration must have changed after the server was started."
           }




           ###
           ### Get Web Container info
           ###

           set serverid [$AdminConfig getid /Cell:$cname/Node:$nname/Server:$sname]

           if {$serverid == ""} {
              puts "getid cname nname returned empty"
              continue
           }

           if {[llength $serverid] > 0} {

               set WebContainerID [$AdminConfig list WebContainer $serverid]

               if {$WebContainerID == ""} {
                  puts "list WebContainer serverid returned empty"
                  continue
               }

               puts ""
               puts "Web Container information for server $sname"
               puts ""
               set services [$AdminConfig showall $WebContainerID services]

               if {$services == ""} {
                  puts "list showall WebContainerID returned empty"
                  continue
               }

               foreach service $services {
                   puts $service
                   puts " "
               }

               ###
               ### Get transports
               ###
               set transports [$AdminConfig showall $WebContainerID transports]
               puts ""
               puts "Transports information for server $sname"
               puts ""
               foreach transport $transports {
                   puts $transport
                   puts " "
               }


               ### Get JVM info
               set jpd [$AdminConfig list JavaProcessDef $serverid]

               if {$jpd == ""} {
                  puts "list JavaProcessDef serverid returned empty"
                  continue
               }

               set jvmEntries [$AdminConfig showall $jpd jvmEntries]

               if {$jvmEntries == ""} {
                  puts "showall jpd jvmEntries returned empty"
                  continue
               }

               puts ""
               puts "JVM information for server $sname"
               puts ""
               foreach jvmEntry $jvmEntries {
                   puts $jvmEntry
                   puts " "
               }
           }



           ###
           ### Find the applications running on this server. 
           ###

           set apps [$AdminControl queryNames type=Application,cell=$cname,node=$nname,process=$sname,*]

           if {$apps == ""} {
              puts "queryNames cname nname returned empty"
              continue
           }

           puts ""
           puts "Number of applications running on $sname: [llength $apps]"
           puts ""

           foreach app $apps {
             set aname [$AdminControl getAttribute $app name]

             if {$aname == ""} {
                puts "getAttribute app returned empty"
                continue
             }


             ### Get deployment configuration information

             set deployments [$AdminConfig getid /Deployment:$aname/]

             if {[llength $deployments] == 0} {
                 continue
             }

             #set appDeploy [$AdminConfig showAttribute $deployments deployedObject]

             set xdeploy [$AdminConfig showall $deployments]

             if {$xdeploy == ""} {
                puts "showall deployments returned empty"
                continue
             }

             puts "----------------------------------------------------"           
             puts ""
             puts ""
             puts "Deployment info for application $aname: " 
             puts ""
             puts "$xdeploy" 



           }

           puts ""
           puts "----------------------------------------------------"           
           puts ""


           ###
           ### Get data source info
           ###
         
         
           puts ""
           puts "JDBC Provider and Data Source Information"
           puts "Cell: $cname Node: $nname Server: $sname "
           puts ""
         
           set JDBCProviderIDs [$AdminConfig getid /Cell:$cname/Node:$nname/Server:$sname/JDBCProvider:/]
            
           if {[llength $JDBCProviderIDs] == 0} {
               puts "Cannot find JDBC Provider for $cname $nname $sname"
               continue
           }
         
           foreach JDBCProviderID $JDBCProviderIDs { 
         
               set JDBCName [$AdminConfig showAttribute $JDBCProviderID name]
         
               if {$JDBCName == ""} {
                  puts "showAttribute JDBCProviderId name returned empty"
                  continue
               }
         
               set DataSources [$AdminConfig getid /JDBCProvider:$JDBCName/DataSource:/]
         
               if {[llength $DataSources] == 0} {
                   puts "Cannot find data sources for JDBCProvider $JDBCname for $cname $nname $sname"
                   continue 
               }
         
               foreach  DataSource $DataSources {
                   set xyz [$AdminConfig showall $DataSource]
         
                   if {$xyz == ""} {
                      puts "showall DataSource returned empty"
                      continue
                   }
                   puts " "
                   puts "JDBCProvider $JDBCName DataSource $DataSource \{ $xyz \} "
                   puts ""
                   puts "----------------------------------------------------"           
                   puts ""
               }
         
           }


           ###
           ### Display the server version information. 
           ###

           set svreport [$AdminControl getAttribute $server serverVersion]

           if {$svreport == ""} {
              puts "getAttribute server serverVersion returned empty"
              continue
           }

           puts ""
           puts $svreport 
           puts ""
           puts "----------------------------------------------------"           
           puts ""
        } 
     }


  }



  puts " "
  puts "JAAS Auth IDs"
  puts ""
  
  set listOfJAASAuthdata [$AdminConfig list JAASAuthData]

  if {$listOfJAASAuthdata == ""} {
       puts "list JAASAuthData returned empty"
       continue
  }
  foreach JAASAuthDataId $listOfJAASAuthdata {
      set xJAAS [$AdminConfig showall $JAASAuthDataId]

      if {$xJAAS == ""} {
           puts "showall JAASAuthDataId returned empty"
           continue
      }
      puts " "
      puts $xJAAS 
  }




}

 


###
### Main
###

 if { !($argc == 1) } {
   puts "get_config: this script requires 1 parameter: a flag that should be \"all\" or \"config\""
   puts ""
   puts "e.g.:     get_config  all" 
} else { 
   set flag      [lindex $argv 0]  
   get_config $flag
}