Using Diagnostic Providers from wsadmin scripts

In addition to enabling Diagnostic Providers (DP) from the administration console, you can also use them through scripts from the Wsadmin tool.

About this task

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

Read the wsadmin tool information about using the tool with scripts.

Procedure

  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:
    ":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"
    ":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 your Diagnostic Provider in a variable.
    This enables you to reference your Diagnostic Provider more easily, especially in a script. For example, instead of typing all of those lines, if you want to work with the WebContainer Diagnostic Provider, for example, you 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 you can use the Diagnostic Provider name as text or a variable.

    • Now that you have the ObjectName in a variable, you 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 you would prefer, you can hard-code the DPName WebContainerDP as it is short enough.

  3. Save the ObjectName of the DiagnosticService MBean to a variable.
    For wsadmin, WebSphere® Application Server provides this MBean so that the output of the Diagnostic Provider is more easily consumable. Enter
    set DS [lindex [$AdminControl queryNames name=DiagnosticService,*] 0] 
    
  4. Run a configDump.
    You 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 . The following table lists the values that 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;
  5. Filter the output of your configDump.
    You 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 that contain auto in them. Full (but strict) regular expression syntax is allowed.
    Table 2. Results . The following table lists the concatenated names and values.
    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