Sets arguments required for appserver application profiling with WSAD or ASTK.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | #
# Set application profiling on.
#
####################################################################
# Patrick Finnegan 26/08/2004. V1.
####################################################################
proc setProfile { serverName } {
global AdminConfig
set serverId [ $AdminConfig getid /Server:$serverName/ ]
regexp {(.*)(\(cells.*)} $serverId 1 2 3
set serverName $2
# set JVM Properties.
if { [ catch { setJVMProps $serverId $serverName } r ] != 0 } {
return -code error $r
}
# set Process Definition Properties.
if { [ catch { setProcessDefProps $serverId $serverName } r ] != 0 } {
return -code error $r
}
}
####################################################################
# Set JVM Properties.
####################################################################
proc setJVMProps {serverId serverName } {
global AdminConfig
# get JVM id
set jvmId [ $AdminConfig list JavaVirtualMachine $serverId ]
set existingGenericJvmArguments [$AdminConfig showAttribute $jvmId genericJvmArguments ]
set msg "Current JVM genericJvmArguments are:"
puts [ format "%-5s %s" " " $msg ]
foreach i $existingGenericJvmArguments {
puts [ format "%-10s %-40s" " " $i ]
}
set arg1 -XrunpiAgent
set arg2 -DPD_DT_ENABLED=true
# the new generic arguments need to be appended to the existing args otherwise the existing args are overwritten. Check whether the arguments already exist. If not merge the existing list with the new list.
if { [ lsearch $existingGenericJvmArguments "-XrunpiAgent" ] != -1 \
|| \
[ lsearch $existingGenericJvmArguments "-DPD_DT_ENABLED=true" ] != -1 } {
puts "do nothing"
} else {
set args [ list $arg1 $arg2 ]
set genericJvmArguments [ list args ]
set genericJvmArguments [ list genericJvmArguments [ concat $existingGenericJvmArguments $args ] ]
set attrList [ list $genericJvmArguments ]
if { [ catch { $AdminConfig modify $jvmId $attrList } r ] == 0 } {
set msg "New JVM genericJvmArguments are:"
puts [ format "%-5s %s" " " $msg ]
set genericJvmArguments [$AdminConfig showAttribute $jvmId genericJvmArguments ]
foreach i $genericJvmArguments {
puts [ format "%-10s %-40s" " " $i ]
}
puts "\n************************************"
puts "$serverName - JVM properties created successfully."
puts "************************************\n"
} else {
puts "\nfailed to create Server JVM properties for $serverName\n"
puts "************************************\n"
return -code error $r
}
}
}
####################################################################
# Set Process Definition Properties.
####################################################################
proc setProcessDefProps {serverId serverName } {
global AdminConfig
set processDefId [ $AdminConfig showAttribute $serverId processDefinition ]
set existingExecutableArguments [$AdminConfig showAttribute $processDefId executableArguments]
set msg "Current JVM Executable arguments are:"
puts [ format "%-5s %s" " " $msg ]
foreach i $existingExecutableArguments {
puts [ format "%-10s %-40s" " " $i ]
}
# the new generic arguments need to be appended to the existing args otherwise the existing args are overwritten. Check whether the arguments already exist. If not merge the existing list with the new list.
if { [ lsearch $existingExecutableArguments "-XrunpiAgent" ] != -1 } {
puts "do nothing"
} else {
set args [ list -XrunpiAgent ]
set executableArguments [ list executableArguments [ eval concat $existingExecutableArguments $args ] ]
set attrList [ list $executableArguments ]
if { [ catch { $AdminConfig modify $processDefId $attrList } r ] == 0 } {
set executableArguments [$AdminConfig showAttribute $processDefId executableArguments]
set msg "New JVM Executable arguments are:"
puts [ format "%-5s %s" " " $msg ]
foreach i $executableArguments {
puts [ format "%-10s %-40s" " " $i ]
}
puts "\n************************************"
puts "$serverName - Process Definition properties created successfully."
puts "************************************\n"
} else {
puts "\nfailed to create Process Definition properties for $serverName\n"
puts "************************************\n"
return -code error $r
}
}
}
####################################################################
# Main Control.
####################################################################
puts "\n argc = $argc \n"
if {$argc < 1} {
return -code error "error - no arguments supplied. Supply server name"
puts "no arguments"
}
# Assume one cell, one deployment manager node and one application node.
set cellId [ lindex [ $AdminConfig list Cell ] 0 ]
set nodes [ $AdminConfig list Node ]
# delete the manager node from the list.
set manIndex [ lsearch -glob $nodes *Manager* ]
set nodeId [ lindex [ lreplace $nodes $manIndex $manIndex ] 0 ]
# get name attribute for cell and application node
set cellName [ $AdminConfig showAttribute $cellId name ]
set nodeName [ $AdminConfig showAttribute $nodeId name ]
set serverName [ lindex $argv 0 ]
puts "\nserver name = $serverName\n"
####################################################################
# setprofile
####################################################################
if { [ catch { setProfile $serverName } r ] == 0 } {
puts "************************************"
puts "Profile set successfully"
puts "************************************\n"
puts "\n###### Admin Config Save ######\n"
$AdminConfig save
} else {
puts "\nFailed to apply profile settings\n"
puts $r
puts "************************************\n"
}
|
Tags: websphere