Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
Java™ Troubleshooting Guide for HP-UX Systems: > Chapter 1 Diagnostic and Monitoring Tools and Options

HPjmeter

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Glossary

 » Index

The latest version of HPjmeter can be downloaded from: :

http://www.hp.com/go/hpjmeter

HPjmeter can be used to identify and diagnose performance problems in Java applications running on HP-UX. It can be used for both static and dynamic data analysis. For static data analysis, HPjmeter can analyze profile, GC or heap data generated by the following command-line options:

  • -Xeprof

  • -Xverbosegc

  • -Xloggc

  • -XX:+HeapDump

  • -XX:+HeapDumpOnCtrlBreak

  • -XX:+HeapDumpOnOutOfMemoryError

  • -XX:+HeapDumpOnly

  • -Xrunhprof

When using JDK 1.5.04 or later, the Java VM can generate an Xeprof file using zero preparation (no command-line option required). HPjmeter can also perform dynamic data analysis with real-time monitoring of Java applications.

The following table lists the features of HPjmeter 3.1. The first two rows are static features and the remaining four rows are dynamic features.

Table 1-11 HPjmeter 3.1 Features

Drill down into application profile metrics
  • Graphic display of profiling data

  • Call graphs with call count, or with processor or clock time

  • Per thread display of time spent

  • Per thread or per process display

Integrated HPjtune functions with concurrent improvements in tool and help usability
Ability to examine Java Management Extension management beans (Mbeans) content and the Java VM internal memory configuration
Automatic problem detection and alerts
  • Memory leak detection alerts with leak rate

  • Thread deadlock detection

  • Abnormal thread termination detection

  • Expected out of memory error

  • Excessive method compilation

Dynamic real-time display of application behavior
  • Java heap size

  • Garbage collection events and percentage time spent in garbage collection

  • CPU usage per method for hottest methods

Object allocation percentage by method
  • Object allocation percentage by object type

  • Method compilation count in the Java VM dynamic compiler

  • Number of classes loaded by the Java VM

  • Thrown exception statistics

  • Multi-application, multi-node monitoring from a single console

 

HPjmeter can display data generated by the following Java product versions, on the specified architectures, with the specified HP-UX operating system, as detailed in the following table:

Table 1-12 Java SDKs and JDKs Supported by HPjmeter 3.1

Java VersionArchitectureHP-UX Versions
SDK 1.4.2.02 or later PA-RISC 1.1, PA-RISC 2.011i v1 (11.11), 11i v2 (11.23), 11i v3 (11.31)
JDK 5.0 or later PA-RISC 2.011i v1 (11.11), 11i v2 (11.23), 11i v3 (11.31)
JDK 6.0.00 or later PA-RISC 2.011i v1 (11.11), 11i v2 (11.23), 11i v3 (11.31)
SDK 1.4.2.02 or later Itanium®11i v2 (11.23), 11i v3 (11.31)
JDK 5.0 or laterItanium11i v2 (11.23), 11i v3 (11.31)
JDK 6.0.00 or laterItanium11i v2 (11.23), 11i v3 (11.31)

 

The HPjmeter console can be run on:

  • PA-RISC HP-UX 11i v1 (11.11), 11i v2 (11.23), 11i v3 (11.31)

  • Integrity HP-UX 11i v1.6 (11.22), 11i v2 (11.23), 11i v3 (11.31)

  • Windows XP/2000/NT

  • Linux

The user's guide for HPjmeter can be found at:

http://docs.hp.com/en/dev.html#Java

More information on HPjmeter, including free software downloads, can be found at:

http://www.hp.com/go/hpjmeter

Static Data Analysis

Using HPjmeter to Analyze Profiling Data

The following steps summarize how to collect and view profiling data from your application.

For applications running on HP-UX, use the extended profiling option -Xeprof to capture profile data, and then view the data in HPjmeter. For applications running on non-HP-UX platforms, you can use -Xrunhprof or -agentlib:hprof options, and use HPjmeter to view the data. (For more details, refer to thehprof section.) The examples in this section use the -Xeprof option.

  1. Change the command line of your Java application to use -Xeprof.

    To collect Xeprof data during the entire execution of the launched Java application, use:

    $ java -Xeprof <yourApp>

    You can send the Xeprof output to a specified file using the file= keyword as follows:

    $ java -Xeprof:file=<yourApp>.eprof <yourApp>

    The <pid> will be inserted automatically in the file name, for example, <yourApp><pid>.eprof.

    To collect Xeprof data for a specified time interval, there are two options.

    1. Turn on/off profiling based on specified time since program start:

      $ java -Xeprof:time_on=<start_time>,time_slice=<length_of_collection_time> <yourApp>
    2. Turn on/off profiling using signals (for example, sigusr1 and sigusr2):

      $ java -Xeprof:time_on=sigusr1,time_slice=sigusr2 <yourApp>

      The generated filename will include the time between the start of an application and the start of profiling, for example:

      java<pid>_<t>.eprof
    NOTE: If you are running JDK 1.5.0.04 or later, the command-line option is not required in order to capture eprof data. Instead you can toggle eprof data gathering on and off by sending signals to the currently running Java VM. One log file is produced per sample period; the name for the log file is java<pid>_<startTime>.eprof.

    The SIGUSR2 signal toggles the recording of eprof data. Use the following process to gather eprof data for specific periods:

    • Send SIGUSR2 to the Java VM process. The Java VM will begin recording eprof data.

    • Send SIGUSR2 to the Java VM process. The Java VM will flush eprof data and close the log file.

    See Profiling with Zero Preparation in the HPjmeter User's Guide for more information.

  2. Run the application to create a data file.

  3. Start the console from a local installation on your client machine. For example, here are two different ways:

    $ $JAVA_HOME/bin/java <heap_settings> -jar /opt/hpjmeter/lib/HPjmeter.jar
    $ /opt/hpjmeter/bin/hpjmeter
  4. Click File—>Open File to browse for and open the data file.

  5. A profile analysis screen opens, displaying a set of tabs containing summary and graphical metric data. The following screen shows an example:

    Figure 1-5 HPjmeter — Profile Data

    HPjmeter — Profile Data
  6. Click among the tabs to view available metrics. Use the Metrics or Estimate menus to select additional metrics to view. Each metric you select opens in a new tab. Hover your mouse over each category in the cascading menu to reveal the relevant metrics for that category. The following screen shows the available metrics for the threads/locks category:

    Figure 1-6 HPjmeter — Threads/Locks Metrics

    HPjmeter — Threads/Locks Metrics

Using HPjmeter to Analyze Garbage Collection Data

The following steps summarize how to collect and view garbage collection data from your application:

  1. When running on HP-UX, add the -Xverbosegc option to the Java command line. (On non-HP-UX platforms, use the -Xloggc option instead.)

    NOTE: On JDK 5.014 (or later) and JDK 6.0.02 (or later), the command-line option is not required to capture Xverbosegc data. Instead, you can toggle Xverbosegc on and off by sending a SIGPROF signal to JVM. For more information, see “Allocation Site Statistics and Zero Preparation Xverbosegc”.
  2. Run the application to create a data file.

  3. Start the console from a local installation on your client machine. For example, here are two different ways:

    $ $JAVA_HOME/bin/java <heap_settings> -jar /opt/hpjmeter/lib/HPjmeter.jar
    $ /opt/hpjmeter/bin/hpjmeter
  4. Click File—>Open File to browse for and open the data file.

  5. A GC viewer screen opens and displays a set of tabs containing metric data. The following figure shows the garbage collection analysis screen:

    Figure 1-7 HPjmeter — Garbage Collection Analysis

    HPjmeter — Garbage Collection Analysis

Dynamic Data Analysis

Using HPjmeter to Monitor Applications

The following steps show how to start the monitoring agent when launching the HPjmeter console. For most Java installations, linkage to the appropriate libraries is completed automatically as part of the installation process, and, therefore, the first step is not needed. Begin with the second step if you have a standard installation of the Java Runtime Environment.

  1. Set the SHLIB_PATH environment variable to include the location of the HPjmeter agent library as appropriate for 32 or 64-bit Java VM.

    The following examples show how to set this variable in both the csh and the ksh for the different libraries.

    To select the PA-RISC 32-bit library:

    (csh) $ setenv SHLIB_PATH /opt/hpjmeter/lib/PA_RISC2.0
    (ksh) $ export SHLIB_PATH=/opt/hpjmeter/lib/PA_RISC2.0       

    To select the PA-RISC 64-bit library:

    (csh) $ setenv SHLIB_PATH /opt/hpjmeter/lib/PA_RISC2.0W
    (ksh) $ export SHLIB_PATH=/opt/hpjmeter/lib/PA_RISC2.0W      

    To select the Integrity 32-bit library:

    (csh) $ setenv SHLIB_PATH /opt/hpjmeter/lib/IA64N
    (ksh) $ export SHLIB_PATH=/opt/hpjmeter/lib/IA64N       

    To select the Integrity 64-bit library:

    (csh) $ setenv SHLIB_PATH /opt/hpjmeter/lib/IA64W
    (ksh) $ export SHLIB_PATH=/opt/hpjmeter/lib/IA64W

  2. Confirm that the node agent is running. With a standard installation, the node agent should be running as a daemon on the system where it was installed. A node agent must be running before the console can connect to a managed node to discover applications and open monitoring sessions.

    To verify that the node agent is running, use the following ps command:

    $ ps -ef | grep node 
    The last output column (the args column) from ps should show the following:
     $ JMETER_HOME/bin/nodeagent -daemon 
    where JMETER_HOME=/opt/hpjmeter. The -daemon flag indicates that the node agent is running as a daemon.

    If the node agent is not running, follow these steps to enable it:

    1. Verify that you are logged in with root permissions.

    2. Verify that the following files exist:

      • /sbin/init.d/HPjmeter_NodeAgent

      • /sbin/rc3.d/S999HPjmeter_NodeAgent

    3. Issue the following command to start the node agent daemon manually. Note: substitute start with stop to stop the node agent.

      $ /sbin/init.d/HPjmeter_NodeAgent start

    If you cannot use the node agent as a daemon or you need to set up access restrictions, start the node agent manually by issuing the following command (no root access needed):
    $ /opt/hpjmeter/bin/nodeagent
    By default, the node agent listens for console connections on port 9505. Use the -port port_number option to specify an alternate port number.

  3. Start the Java application with the Java VM agent. For example, to start the myapp application on JDK 1.5, enter (For JDK 6.0, replace “java1.5” with “java6”):

    $ /opt/java1.5/bin/java -Xms256m -Xmx512m -agentlib:jmeter myapp   
    On SDK 1.4.2 versions enter:
    $ /opt/java1.4/bin/java -Xms256m -Xmx512m  \   
    -Xbootclasspath/a:$JMETER_HOME/lib/agent.jar -Xrunjmeter myapp       
    This enables the myapp process to be dynamically monitored with the console.

  4. Start the HPjmeter console by entering the command:

    $ /opt/hpjmeter/bin/hpjmeter

Connecting to the Node Agent From the HPjmeter Console

  1. Select Connect from the File menu or select the Connect to Server icon []. The following screen is displayed:

    Figure 1-8 HPjmeter — Connecting to Server

    HPjmeter — Connecting to Server
  2. In the Connect to Server dialog box, enter the host name where the Java application and corresponding node agent are running.

  3. If the node agent was started on a nonstandard port, specify the port number in the Optional Port box.

  4. Click Connect. The running Java VM for each application should appear in the console main screen pane marked with the symbol.

    NOTE: If there is a connection failure, the symbol is not displayed. Instead the symbol is displayed next to the server name to indicate the server connection failure. If this happens, verify the node agent is running on the specified server.

  5. If you want to connect to several node agents, repeat the previous steps.

Setting Session Preferences

  1. Double-click the Java VM icon in the data pane for the application that you want to monitor. This opens the Session Preferences dialog box shown in the following screen:

    Figure 1-9 HPjmeter — Setting Session Preferences

    HPjmeter — Setting Session Preferences
  2. Check the default settings for metrics, filters, and alerts, and enable the settings you want to activate.

  3. Click OK. The Session Preferences screen closes and the newly Open Session is visible, marked by the icon. Refer to the following screen for an example:

    Figure 1-10 HPjmeter — Collecting Metrics

    HPjmeter — Collecting Metrics
  4. Wait for the console to collect metrics. The length of time depends on the application size, the load imposed on the application, and the selected preferences. Typically, the wait will be from 5 to 30 minutes. Longer collection time gives you greater accuracy in the results.

Viewing Monitoring Metrics During Your Open Session

  1. Click the open session or time slice to highlight the data to be viewed.

  2. Use the Monitor menu on the console main screen to select the desired metrics. Refer to the following screen for an example:

    Figure 1-11 HPjmeter — Choosing Metrics to Monitor

    HPjmeter — Choosing Metrics to Monitor
  3. Select a metric. A metric visualizer displaying the chosen data opens. Refer to the HPjmeter User’s Guide for details on individual metrics and how to interpret the data.

Running the HPjmeter Sample Programs

HPjmeter includes two sample applications you can run to see live examples of a memory leak and a thread deadlock situation. You can use the visualizers to examine data during the demonstration session.

The following general steps show how to run the sample applications:

  1. Start the console.

  2. Start the node agent if it is not running as a daemon.

  3. Start the sample application from the command line:

    $ cd $JMETER_HOME/demo 
    $ export LD_LIBRARY_PATH=$JMETER_HOME/lib 
    $ java -agentlib:jmeter agent.jar -jar ML1.jar     
    As a convenience, HPjmeter includes a script that sets up the library path and bootclasspath using the Java VM found at installation time. Follow these instructions to use this script:
    $ cd $JMETER_HOME/demo 
    $ ../bin/run_simple_jvmagent -jar sample_program
       
    Use the file name of the specific sample you want to run in place of sample_program.

  4. In the console main screen, click Connect and enter the host name of the machine running the sample application. If you specified a port number when starting the node agent, use the same port number. Otherwise, leave the port number box empty.

  5. An icon representing the host appears in the main screen. After a few moments, the console also shows the sample application as a child node of the host.

  6. Double-click the application node to open a monitoring session with the application.

  7. Click OK to accept the default settings for metrics, filters, and alerts.

Sample Memory Leak Application

This application demonstrates how memory leak alerts work in HPjmeter. It uses a simple program which allocates some objects. The program uses a java.util.Vector object to retain references to some of the objects. This application is configured to leak memory at the rate of about 10 MB per hour. It is available from the HPjmeter installation directory:

Source: $JMETER_HOME/demo/ML1.java 
Binary: $JMETER_HOME/demo/ML1.jar 

Use the class name ML1 with the run_simple_jvmagent script to start the sample. When measuring the sample application, allow considerable time for the heap to mature and stabilize, and for the Java VM agent to collect memory leak data. Eventually, you will see the following two alerts:

  • Expected OutOfMemory Error Alert with the leaking rate

  • Memory Leak Locations Alert with the leak location

When using the default garbage collectors and heap size for SDK 1.4.2, the detection of a memory leak for this demonstration program occurs after about 20 minutes. This time may be substantially longer when using a different Java VM or nonstandard garbage collector or heap settings. In real situations, the detection time depends on the maximum heap size, the size of the leak, the application running time, and the application and load characteristics. Typically, the detection occurs in about one hour.

The following figure is a memory leak alert for the sample program:

Figure 1-12 HPjmeter — Memory Leak Alert

HPjmeter — Memory Leak Alert

The following figure is the heap screen:

Figure 1-13 HPjmeter — Heap Monitor Screen

HPjmeter — Heap Monitor Screen
Sample Thread Deadlock Application

This application demonstrates how HPjmeter detects deadlocked threads. It creates pairs of threads every 30 seconds, stopping at 50 threads, which synchronize work using shared locks. Occasionally, the program reverses the order on which locks are taken, eventually causing a deadlock, which generates a Thread Deadlock Alert.

The sample application is available from the HPjmeter installation directory:

Source: $JMETER_HOME/demo/DL1.java 
Binary: $JMETER_HOME/demo/DL1.jar 

Use the class name DL1 with the run_simple_jvmagent script to start the sample. Use the Thread Histogram screen to view the thread activity. Deadlocked threads show a solid red bar.

The following figure is the Thread Histogram screen:

Figure 1-14 HPjmeter — Thread Histogram Screen

HPjmeter — Thread Histogram Screen
Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 2009 Hewlett-Packard Development Company, L.P.