Use Diagnostic Providers from wsadmin scripts
In addition to enabling Diagnostic Providers (DP) from the administration console, we can also use them through scripts from the Wsadmin tool.
You might want to enable, disable, or configure Diagnostic Providers from the dmgr console, but in some cases it might be more efficient or useful to do so with scripts using wsadmin.
Read wsadmin information about using the tool with scripts.
- List the MBeans that implement the Diagnostic Provider (DP) interface. Enter
$AdminControl queryNames diagnosticProvider=true,*
And you will see an output that displays all of the Diagnostic Providers in a format like this:"WebSphere:name=Default Datasource,process=server1,platform=dynamicproxy,node= camelhair,JDBCProvider=Derby JDBC Provider, diagnosticProvider=true,j2eeType=JDBCDataSource,J2EEServer=server1,Server=server1, version=6.1.0.0,type=DataSource, mbeanIdentifier=cells/camelhairCell/nodes/camelhair/servers/server1/resources.xml# DataSource_1131113688564, JDBCResource=Derby JDBC Provider,cell=camelhairCell" "WebSphere:name=DefaultEJBTimerDataSource,process=server1,platform=dynamicproxy, node=camelhair, JDBCProvider=Derby JDBC Provider (XA),diagnosticProvider=true,j2eeType= JDBCDataSource,J2EEServer=server1,Server=server1,version=6.1.0.0,type=DataSource, mbeanIdentifier=cells/camelhairCell/nodes/camelhair/servers/server1/ resources.xml#DataSource_1000001, JDBCResource=Derby JDBC Provider (XA),cell=camelhairCell" WebSphere:name=WebcontainerDiagnosticProvider,process=server1,platform= dynamicproxy,node=camelhair,diagnosticProvider=true, version=6.1.0.0,type=WebcontainerEventProvider,mbeanIdentifier=null, cell=camelhairCell- Capture the ObjectName of your Diagnostic Provider in a variable. This allows us to reference your Diagnostic Provider more easily, especially in a script. For example, instead of typing all of those lines, to work with the WebContainer Diagnostic Provider, for example, we can do the following:
- set DP [lindex [$AdminControl queryNames name=WebcontainerDiagnosticProvider,diagnosticProvider=true,*] 0]
This ObjectName stored in the DP variable can be used on the methods, or we can use the Diagnostic Provider name as text or a variable.
- Now that you have the ObjectName in a variable, we can get the Diagnostic Provider name in a variable with the command:
set DPNm [$AdminControl invoke $DS getDiagnosticProviderNameById $DP]
This provides the result:
WebContainerDP
Now the DiagnosticProvider (WebContainer) is addressable by its objectname in variable DP, or by its DiagnosticProvider name in variable DPNm. If we would prefer, we can hard-code the DPName WebContainerDP as it is short enough.
- Save the ObjectDiagnosticService MBean to a variable. For wsadmin, WebSphere Application Server provides this MBean so the output of the Diagnostic Provider is more easily consumable. Enter
set DS [lindex [$AdminControl queryNames name=DiagnosticService,*] 0]
- Run a configDump. We can run a configDump and capture all attributes with the command:
$AdminControl invoke $DS configDumpFormattedById [list $DP .* true null]
This lists the values the Diagnostic Provider used at start up (and possible current values). .
Item Concatenated Name Value customProperties = Null defaultVirtualHostName = default_host jvmProps = Null localeProps = Null servletCachingEnabled = false aliases = *:9080;*:80;*:9443; - Filter the output of your configDump. We can use configDumpFormatted (leaving off the ById) and switch $DP for $DPNm or the string WebContainerDP. This example uses $DPNm on this slightly modified version whereby it only picks up attributes dealing with automation:
$AdminControl invoke $DS configDumpFormatted [list $DPNm .*auto.* true null]
This results in just those attributes containing auto in them. Full (but strict) regular expression syntax is allowed.
The syntax is the same for stateDumps and selfDiagnostics
Item Concatenated Name Value autoLoadFiltersEnabled = false autoRequestEncoding = false autoResponseEncoding = false autoLoadFiltersEnabled = false autoRequestEncoding = false autoResponseEncoding = false
Related
Start the wsadmin scripting client using wsadmin.sh
wsadmin scripting tool
Modify the State Collection Specification from wsadmin scripts