Welcome, guest | Sign In | My Account | Store | Cart

Switch on PMI service. Set performance monitor specification level. Set JVM arguments.

Tcl, 241 lines
  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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
# 
# Set performance monitoring service on.
# Set performance monitoring flags. 
#
####################################################################
# Patrick Finnegan 28/09/2005.  V1. 
####################################################################
proc setPerMonOn { serverName } {

   puts "\n setPerMonOn \n "

   global AdminConfig 

   set serverId       [ $AdminConfig getid /Server:$serverName/ ]

   set PMIServiceList [ $AdminConfig list PMIService ]  
 
   # get PMI service object for target server 

   set serverIndex      [ lsearch -glob $PMIServiceList *$serverName* ]

   set PMIServiceId     [ lindex $PMIServiceList $serverIndex ] 

   set enable           [ $AdminConfig showAttribute $PMIServiceId enable ]

   set initialSpecLevel [ $AdminConfig showAttribute $PMIServiceId initialSpecLevel ]

   set msg "Current Performance Monitor Settings Spec level:\n"

   puts [ format "%-5s %s"  " " $msg  ]
       
   puts [ format "%-10s %-20s %-40s"  " " enable           $enable ]
   puts [ format "%-10s %-20s %-40s"  " " initialSpecLevel $initialSpecLevel ]

   set enable              [ list enable true ]

   append X beanModule=X: 
   append X acheModule=X:
   append X connectionPoolModule=X:
   append X j2cModule=X:
   append X jvmRuntimeModule=X:
   append X orbPerfModule=X:
   append X servletSessionsModule=X:
   append X systemModule=X:
   append X threadPoolModule=X:
   append X transactionModule=X:
   append X webAppModule=X:
   append X wlmModule=X:
   append X webServicesModule=X:
   append X wsgwModule=X:

   set initialSpecLevel   [ list initialSpecLevel $X ]

   set attrsList          [ list $enable $initialSpecLevel ]	

   if { [ catch { $AdminConfig modify $PMIServiceId $attrsList } r ] == 0 } {

       set enable           [ $AdminConfig showAttribute $PMIServiceId enable ]
       set initialSpecLevel [ $AdminConfig showAttribute $PMIServiceId initialSpecLevel ]

       set msg "New Performance Monitor Settings Spec level:"

       puts [ format "%-5s %s"  " " $msg  ]
	   
       puts [ format "%-10s %-20s %-40s"  " " enable           $enable ]
       puts [ format "%-10s %-20s %-40s"  " " initialSpecLevel $initialSpecLevel ]


       if { [ catch { setJVMProps $serverName } r ] == 0 } {

           setRunPerfAdvisor $serverName 
	   #puts $r

       } else {

	   puts $r
           return -code error

       }

   } else { 

       puts $r
       return -code error

   }

}
####################################################################
# Set JVM Properties.
####################################################################
proc setJVMProps { serverName } {

   global AdminConfig 

   set serverId       [ $AdminConfig getid /Server:$serverName/ ]

   # get JVM id 

   set jvmId [ $AdminConfig list JavaVirtualMachine $serverId ]

   # get existing arguments  

   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 ]

   }

   # 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 "-XrunpmiJvmpiProfiler" ] != -1 } {

       #puts "do nothing"
       set continue true 

   } else {

       set args                   [ list -XrunpmiJvmpiProfiler ] 

       # use eval concat to trim spaces.
       set genericJvmArguments    [ list genericJvmArguments [ eval 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
       }

   }

}
####################################################################
# Enable Runtime Performance Advisor.
# NB - server must be running to pick up MBean.
####################################################################
proc setRunPerfAdvisor { serverName } {

   puts "\n setRunPerfAdvisor \n "

   global AdminConfig 
   global AdminControl 

   set perfId [ $AdminControl queryNames mbeanIdentifier=ServerRuleDriverMBean,process=$serverName,*]

   # if the server is not running the mbean will be null. 

   if { [ string length $perfId ] != 0 } {
       
       # get existing arguments  

       set enabled [ $AdminControl getAttribute $perfId enabled ]

       puts "\nCurrent RPA Status is: $enabled\n " 

       $AdminControl setAttribute $perfId enabled true

       $AdminControl invoke $perfId reInit

       set enabled [ $AdminControl getAttribute $perfId enabled ]

       puts "New RPA Status is: $enabled\n " 

   } else {

       puts "$serverName is not running. Skip RPA enabling.\n" 

   }

}

####################################################################
# 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"

####################################################################
# setPerMonOn  
####################################################################

if { [ catch { setPerMonOn $serverName } r ] == 0 } {
    puts "************************************"
    puts "Performance monitoring set successfully" 
    puts "************************************\n"
    puts "\n###### Admin Config Save ######\n"
    $AdminConfig save
} else {
        puts "\nFailed to apply Performance Monitoring settings\n"
        puts $r 
        puts "************************************\n"
}

1 comment

Patrick Finnegan (author) 18 years, 6 months ago  # | flag

Typo in script. There is a typo in the script.

"append X acheModule=X:" should be "append X cacheModule=X:"

Regards.

Patrick.

Created by Patrick Finnegan on Tue, 18 Oct 2005 (MIT)
Tcl recipes (162)
Patrick Finnegan's recipes (56)

Required Modules

  • (none specified)

Other Information and Tasks