Logging Tivoli Performance Viewer data by using scripting

You can use the wsadmin tool to start and stop Tivoli® Performance Viewer logging in your environment.

About this task

Tivoli Performance Viewer provides an easy way to store real-time data for system resources, WebSphere® Application Server pools and queues, application-related statistics, and others in log files for later retrieval. The wsadmin tool helps you start and stop logging by using the command line. You can use the command line to start and stop Tivoli Performance Viewer logging.

The following task assumes that you are using Jython script.

Procedure

  1. Start the wsadmin scripting tool.
  2. Import the UserPreferences and jarray.
    import com.ibm.ws.tpv.engine.UserPreferences
    import jarray 
  3. Identify the server where you want logging to be started, and assign it to the following variable:
    tpvName = AdminControl.completeObjectName("type=TivoliPerfEngine,*" )
    tpvName = AdminControl.makeObjectName(tpvName 
  4. Create a UserPreferences object.
    Ensure that you add the preferences:
    • pref.setBufferSize(nnnn) - Sets the number of entries to store in the buffer, where nnnn is an integer.
    • pref.setLoggingDuration(nn) - Sets the logging duration. How long in seconds logging stays active after it is turned on, unless it is stopped manually by the user.
    • pref.setRefreshRate(n) - Sets the refresh rate in seconds. The number of seconds between requests for new data.
    • pref.setLogFileSize(nnnnnnnn) - Sets the log file size in bytes that an individual log file can grow to.
    • pref.setNumLogFiles(n) - Set the number of log files to use while logging.
    pref = com.ibm.ws.tpv.engine.UserPreferences()
    pref.setBufferSize(1200)
    pref.setLoggingDuration(60)
    pref.setRefreshRate(5)
    pref.setLogFileSize(1000000)
    pref setNumLogFiles(3)
    pref.setServerName("server1")
    pref.setNodeName("mynode")
    pref.setLogFileName("tpv_log_1")
    pref.setUserId("user")
  5. Create the necessary arguments and invoke monitorServer action on the Tivoli Performance Viewer MBean.
    list_p = java.util.ArrayList()
    list_p.add(pref)
    params=jarray.array(list_p,java.lang.Object)
    
    list_s = java.util.ArrayList()
    list_s.add("com.ibm.ws.tpv.engine.UserPreferences")
    sigs = jarray.array(list_s,java.lang.String)
    
    print "--- TPV Calling monitorServer ---"
    AdminControl.invoke_jmx(tpvName, "monitorServer", params, sigs )
  6. When you want to start logging, call the following operation:
    o	print "--- TPV Calling startLogging ---"
    o	AdminControl.invoke_jmx(tpvName, "startLogging", params, sigs )
  7. When you want to stop logging, call the following operation:
    print "--- TPV : Now Stop Logging ---"
    AdminControl.invoke_jmx(tpvName, "stopLogging", params, sigs )

What to do next

By default, the log files are stored in the profile_root /logs/tpv directory on the node on which the server is running. Tivoli Performance Viewer automatically compresses the log file when it finishes writing to it to conserve space. There must be a single log file only in each .zip file and it must have the same name as the .zip file. Complete the following steps to view the log files:

  1. Click Monitoring and Tuning > Performance Viewer > View Logs in the navigation tree.
  2. Select a log file to view by using either of the following options:
    • Explicit path to a log file

      Choose a log file from the machine on which the browser is running. Use this option if you create a log file and transferred it to your system. Click Browse to open a file browser on the local machine and select the log file to upload.

    • Server file
      1. Specify the path of a log file on the server.
      2. In a deployment management environment, click the Browse button next to the input to browse the various nodes and find the log file to view.
      3. Click View Log. The view displays the log with log control buttons.