+

Search Tips   |   Advanced Search

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.

We might want to enable, disable, or configure Diagnostic Providers from the admin console, but in some cases it might be more efficient or useful to do so with scripts using wsadmin.

Read the topic on the Wsadmin tool for more information about using the tool with scripts.

 

  1. 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
    

  2. Capture the ObjectName of the Diagnostic Provider in a variable.

    This enables you to reference the Diagnostic Provider more , 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 we 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.

  3. Save the ObjectName of the DiagnosticService MBean to a variable.

    For wsadmin, WAS provides this MBean so that the output of the Diagnostic Provider is more consumable. Enter

    set DS [lindex [$AdminControl queryNames name=DiagnosticService,*] 0] 
    
    

  4. 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 that the Diagnostic Provider used at start up (and possible current values). .


    Table 1. An excerpt of the configDump output

    Item Concatenated Name Value
    customProperties = Null
    defaultVirtualHostName = default_host
    jvmProps = Null
    localeProps = Null
    servletCachingEnabled = false
    aliases = *:9082;*:80;*:9443;

  5. Filter the output of the configDump. 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 that contain auto in them. Full (but strict) regular expression syntax is allowed.


    Table 2. Results

    Item Concatenated Name Value
    autoLoadFiltersEnabled = false
    autoRequestEncoding = false
    autoResponseEncoding = false
    autoLoadFiltersEnabled = false
    autoRequestEncoding = false
    autoResponseEncoding = false

    The syntax is the same for stateDumps and selfDiagnostics

 

Related tasks


Start wsadmin

 

Related


Wsadmin tool

 

Related information


Modify the State Collection Specification from wsadmin scripts