Sample scripts

 < Day Day Up > 



This section contains procedures that can be combined for different maintenance scenarios. The "drain application server procedure" is constructed from the many subprocedures as follows:

Drain Application Server Procedure

 .  changeServerWeightOnly .  regeneratePluginConfig o  getShellEnvVariable .  updateWebPlugin .  getLiveSessionsCount o  parsePMIdataForLiveSessions 

Drain Application Server Procedure

 #-------------------------------------------------------------------- # Drain application server of users by manipulating server weight and # regenerating WebSphere plug-in. Wait until live user sessions reaches 0 or # timeToWait expires on the application server being drained and then stop # the server. #---------------------------------------------------------------------- changeServerWeightOnly $clusterServerName $newWeight regeneratePluginConfig $pluginCfgName $srcPluginPath updateWebPlugin $pluginCfgName $srcPluginPath $desPluginPath $webServerList puts "Waiting for plugin to read new config file." after 30000 set activeSessionCount [getLiveSessionsCount $clusterServerName] puts "Currently there are $activeSessionCount sessions active on       $clusterServerName" set expireTime [clock seconds] incr expireTime $timeToWait puts "Current TimeToWait set to $timeToWait seconds" while {$activeSessionCount > 0 && $expireTime > [clock seconds]} {   after 10000   set activeSessionCount [getLiveSessionsCount $clusterServerName]   puts "Currently there are $activeSessionCount sessions active on         $clusterServerName ([expr $expireTime - [clock seconds]]s left)" } set server [$AdminControl completeObjectName cell=[$AdminControl             getCell],node=$nodeName,name=$clusterServerName,type=Server,*] if {[string compare $server ""] != 0} {   set serverState [$AdminControl getAttribute $server state]   puts "$appServer current state is $serverState"   if {[string compare $serverState "STARTED"] == 0} {     $AdminControl stopServer $appServer   } } else {   puts "Server $appServer is not running on node $nodeName" } 

changeServerWeightOnly

 #-------------------------------------------------------------------- # Change the weight of the server so that plug-in will direct traffic # accordingly #-------------------------------------------------------------------- if {$newWeight >= 0} {   set clusterServer [$AdminConfig getid /ClusterMember:$clusterServerName/]   $AdminConfig modify $clusterServer [list [list weight $newWeight]] } 

regeneratePluginconfig

 #-------------------------------------------------------------------- # Regenerate the Web Server plugin #-------------------------------------------------------------------- lappend pluginOptionsList [getShellEnvVariable "WAS_ND_HOME"] lappend pluginOptionsList [getShellEnvVariable "WAS_ND_CONFIG"] lappend pluginOptionsList [$AdminControl getCell] lappend pluginOptionsList null lappend pluginOptionsList null lappend pluginOptionsList $pluginCfgName if {[catch {$AdminControl completeObjectName type=PluginCfgGenerator,*}      pluginGenerator]} {   # Appropriate error handling code } $AdminControl invoke $pluginGenerator generate $pluginOptionsList set ndName   [getShellEnvVariable "ND_NAME"] set baseName [getShellEnvVariable "BASE_NAME"] exec ex -c %s/$ndName/$baseName/ -c wq $srcPluginPath/$pluginCfgName 

getShellEnvVariable

 #------------------------------------------------------------------------ # Retrieve environment variables that were set in a calling shell environment #------------------------------------------------------------------------ if {[catch {exec env} variables]} {   puts "Error getting Environment Variables"   puts "Error Message = $variables"   return } set regExp "^$envName=(.*)" regexp -nocase -- $regExp $variables tempStr tempValue regsub -all {\"} $tempValue {} envValue return $envValue 

updateWebPlugin

 #---------------------------------------------------------------------- # Update Web server with the new plugin #---------------------------------------------------------------------- set cfgFile $srcPluginPath append cfgFile /$pluginCfgName exec chmod a+r $cfgFile foreach webServer $webServerList {   exec rcp -p $cfgFile $webServer:$desPluginPath/$pluginCfgName } puts "-----> Done updating plugins" 

getLiveSessionsCount

 #---------------------------------------------------------------------- # Determine number of live sessions for a given server #---------------------------------------------------------------------- set perfName [$AdminControl completeObjectName   type=Perf,process=$clusterServerName,*] set perfObjName [$AdminControl makeObjectName $perfName] # Get the complete name of the server we are monitoring set serverName [$AdminControl completeObjectName     type=Server,process=$clusterServerName,*] # set the parameters for the invoke JMX call set params [java::new {java.lang.Object[]} 2] $params set 0 [$AdminControl makeObjectName $serverName] $params set 1 [java::new java.lang.Boolean true] # set the signatures for the invoke JMX call set sigs [java::new {java.lang.String[]} 2] $sigs set 0 javax.management.ObjectName $sigs set 1 java.lang.Boolean # Invoke the call to get the PMI Stats Object set object [$AdminControl invoke_jmx $perfObjName getStatsObject $params $sigs] # Cast the object to a Stats object to be safe set stats [java::cast com.ibm.websphere.pmi.stat.Stats $object] # We have the Stats object of all the PMI data on the server.  We # need to just get the SessionsModule data set sessionStats [$stats getStats "servletSessionsModule"] regexp "id=7.*current=(\\d*)" [$sessionStats toString] tempStr  liveSessionsCount return $liveSessionsCount 



 < Day Day Up > 



High-Volume Web Sites Team - More about High-Volume Web Sites
High-Volume Web Sites Team - More about High-Volume Web Sites
ISBN: N/A
EAN: N/A
Year: 2003
Pages: 117

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net