WebSphere Articles

Profiling WebSphere Applications with IBM Support Assistant

One of the tools available for improving performance of Java applications is application profiling.  This involves using a tool to gather detailed information about how an application executes to look for various ways to improve performance.

Although profiling information is often done by developers it can also be done by administrators using tools in the IBM Support Assistant.  These tools are free, easy to install, and can help gather information to indicate there may be problems to pass along to developers to fix.  Also, developers who do not use Rational Application Developer, which also has built-in profiling tools, could use the free tools in IBM Support Assistant.

The primary tool we will describe here is the “Health Center” tool for IBM JVMs.  Note that the instructions here would be valid for Windows and other operating systems may be slightly different but this article provides links to resources for all operating systems.

Want More?

The steps in this article and the use of advanced troubleshooting tools available in the IBM Support Assistant will be some of the new content added to our new course, WA2148 WebSphere Application Server 8.5 Problem Determination.

Install Profiling Tools to IBM Support Assistant

The first step would be to install the IBM Support Assistant (ISA) Workbench if you have not already installed it.  The main tool we will show requires the 4.1 version of the ISA Workbench so if you have a previous version it is usually best to uninstall and then reinstall 4.1.  You can find complete details of how to install the ISA Workbench here.

Once you have the ISA Workbench installed open the program.  If this is the first time you have run the ISA Workbench it will often start a “First Steps” wizard to provide links to open the network and updating preferences, two important settings that you may need to configure to allow the ISA Workbench to connect to IBM servers through a firewall.  If you do not see this wizard but you know you need to set preferences you can also go to the File –> Preferences menu item.

If you use the First Steps wizard it will usually launch a tool to update the “add-ons” installed with ISA.  If this tool does not launch you can select Update –> Find New.. –> Tools Add-ons.  The updating tool may not appear immediately and you may see a progress indicator in the lower right corner.

image

image

When the tool add-ons are shown there may be different categories depending on the software you have chosen to support with ISA.  You will almost always have a ‘JVM-based Tools’ category though as many IBM products use Java.  Expand this category and check the IBM Monitoring and Diagnostic Tools for Java – Health Center option.  Unlike the screenshot below you may see several tools with similar names so make sure you choose the ‘”Health Center” as that is the tool we will highlight here.

image

Once the proper tool is selected press the Next button, accept the license and press the Next button again, and then press the Finish button to begin installing the tool.  You may not notice anything is happening except a progress indicator in the lower right corner.  Wait for the installation to complete.  Once the installation is complete you will be prompted to restart the ISA Workbench.  Click Yes to allow the restart.

Health Center Tool Architecture

The architecture of the Health Center tool is to run an “agent” within the Java JVM of the application you wish to monitor.  You will then connect to this agent from the tool run from the ISA Workbench.  If the application you are monitoring is on a different system than the ISA Workbench you will need to make sure to connect to it through firewalls and use the hostname of the machine running the application being monitored when connecting from the tool.

Since you will be installing the agent software and connecting to a live environment it is likely that you may not use the Health Center with production systems.  There are other tools that may be used with the ISA Workbench that would not require an agent to connect from another tool or would not require installing any software that is not already part of normal fixpacks since both of these procedures might violate change management policies on production systems.

In general though the kind of information you are looking for with the Health Center will be better to collect early in the deployment cycle so it may be better to use the Health Center with test and QA systems anyway which may not have quite the same policies against running the Health Center agent.

image

Launch Health Center Tool

To launch the Health Center tool click on the “Analyze Problem” shortcut on the main Welcome page of the ISA Workbench.

image

You can also get here by clicking the Launch Activity button and selecting Analyze Problem.

image

If the list of installed tools is not displayed, click the Tools tab along the top to display the list.

From the list of tools select the IBM Monitoring and Diagnostic Tools for Java – Health Center.  Remember you may have different tools than shown below.

image

Once the proper tool is selected click the Launch button in the lower left.

Leave the first page of the Connection Wizard open for the next section.

image

Install Health Center Agent

The Health Center agent is packaged as a Zip file that you extract to your Java JRE of the environment you want to use the Health Center with.  The best way to get the correct package is from the help topics of the Health Center ISA add-on.  The steps in this section will only need to be done once.

To do this click the “Enabling an application for monitoring” link from the first page of the Connection Wizard shown above.  The ISA Workbench help will open.

On the first page that appears click the link for “installing the Health Center agent” in the prerequisite section.

image

On the page that appears click on the link for the operating system you will be running the agent on.  This may be different than the operating system you are using for the ISA Workbench.  The files listed are packaged with the tool.

image

Save the Zip file to the machine you will be running the agent on.  Save it to the directory above the root of the Java Runtime Environment, or JRE.  For example on WebSphere Application Server the JRE is usually at <WAS_ROOT>/java/jre so you would save the Zip file to <WAS_ROOT>/java.

Unzip the Zip file to the folder above the JRE root directory, making sure to preserve the folders contained in the zip file.  As shown below this zip file will extract different files, the most notable the healthcenter.jar file, into different locations in the JRE.  Depending on your fixpack of the IBM JVM you may be replacing some Health Center files already present but this is OK as it is best to use the files provided with the version of the Health Center you are using.

image

Double check that the following file is present to make sure files were extracted properly:

<JRE_ROOT>/lib/ext/healthcenter.jar

Enable Health Center Agent

The steps for enabling the Health Center agent differ depending on what type of Java application you are using the agent with.  There instructions will show using WebSphere Application Server v7.0 which uses Java 6.0.

Since we are using WebSphere Application Server you want to expand the ‘Configuring WebSphere or Rational product environments’ and select the ‘Configuring WebSphere Application Server environments’ topic.

image

Start the WebSphere Application Server using the normal method.

Login to the Administrative Console.

Go to the server properties by selecting ‘Servers –> Server Types –> WebSphere application servers’ in the Admin Console navigation and clicking the name of the server.

Expand ‘Java and Process Management’ and click the ‘Process Definition’ link.

Click on the ‘Java Virtual Machine’ link and find the setting for ‘Generic JVM arguments’.

The next step is highly dependent on the Operating System and version of Java (including fixpacks) so check the Health Center help for the correct values.

For the ‘Generic JVM arguments’ we will use the following since we are using Windows and Java 6 with no fixpack:

-agentlib:healthcenter -Xtrace:output=C:\temp\perfmon.%p.out

(This assumes you already have a C:\temp directory, create one if you don’t as the setting above indicates where the agent will store data)

image

Double check the value you enter because an incorrect JVM argument can prevent the server from starting.  If you are using a “standalone” server that performs it’s own administration you might even need to manually edit the server.xml file if there are problems.

Click the OK button at the bottom of the page and then save the changes to the configuration.

Restart the server to use the new settings.

Connect from Health Center

Once your server is started with the proper settings you can return to the Health Center tool and connect.

Close the ISA Workbench help if it is still open.

Return to the Health Center connection wizard.  You can select File –> New Connection… with the Health Center tool active if you closed it.

If you are connecting to the server running on the same machine you can use ‘localhost’, otherwise enter the host information.  We are also using the default port although you can change this in the <JRE_ROOT>/lib/healthcenter.properties file you extracted with the agent installation.  In this case we are also not using authentication from the Health Center.  It is possible to enable this by following steps in the Health Center help topics.

image

Once your settings are appropriate for your setup click the Next button and the tool will search for connections.

Once a valid connection is found select it and press the Finish button.

image

The Health Center tool will begin collecting data.  Give it a minute to “catch up”, especially if you just restarted the server.

image

Using the Health Center Tool

Note: Although this section will give you a brief overview of some of the things you can use the tool for the Help topics have much more detail and great references for more information about certain kinds of problems.

The first thing you might want to do, especially if you are looking at an application running on a server that just restarted is to clear the data from when the server was starting.  This way you will not be including the garbage collection and other data from that time period.  You can clear the data previously collected by selecting Data –> Reset Data in the menu or using the corresponding button.

The Status view of the tool, which is the first page shown when you connect, will provide links to show the other perspectives and messages about certain types of problems that may be occurring.  Unless you are investigating a specific problem one of the best ways to use the tool is to run a load test of a deployed application and look if there are any messages in the Status view of potential problems.  If there are messages about problems you can click the link for the view that will help you investigate further.

image

The “Garbage Collection” perspective shows memory statistics and can do some analysis of memory problems.  Although it does not seem able to directly detect a “memory leak” you can get a live picture of the state of the memory heap size and look for the symptom of a memory leak where the memory keeps increasing.  You can then use other tools of the ISA Workbench to specifically investigate a memory leak problem.

image

The “Locking” perspective shows how much application code is waiting for locks between synchronized blocks of code.  This graph is a little tough to interpret because the height of the bars is always the “slow” value for the lock monitor.  Even if you sort the list below by something else the height of the bar will stay the same.  The bars will be colored red or yellow if a lock has a high “% miss”.  This is one of the primary things to look for as it indicates one thread is trying to get a lock while it is help by another thread and results in blocking.

image

The “Profiling” perspective lets you see how much time executing particular methods took.  You generally want to sort by the “Self” value to show the methods which took the highest time without the other methods it called included.  You can also sort by “Tree” but you have to remember that in a server application many things will be threads just waiting to execute or handle asynchronous I/O.  If you do sort by “Tree” make sure to scroll down and find the methods that are part of the application and not necessarily methods running WebSphere code (com.ibm…).

image

There are a few other perspectives and types of data available from the Health Center but these are generally the most useful to help diagnose the most common kinds of application problems.

One thing to keep in mind when using the Health Center is that the data is collected incrementally and meant more to show longer terms trends so it might be several seconds or a minute before you see what has been happening in the application due to recent activity.  One thing you can do is to select File –> Save Data to save the data from particular tests to analyze after the test has been performed.

Summary

Hopefully you can see that the Health Center tool available from the IBM Support Assistant Workbench is a tool that can help you quickly start diagnosing common application performance problems.  Based on the data from this tool you can use other tools provided with ISA to dig deeper into specific problems and provide developers or administrators information they can use to help resolve these issues.

Want More?

The steps in this article and the use of advanced troubleshooting tools available in the IBM Support Assistant will be some of the new content added to our new course, WA1849 Advanced WebSphere Application Server v7.0 Administration.

11 Comments

Using the WASService.exe Command

The WASService.exe command allows you to setup a Windows service for a WebSphere server. The command has its own idiosyncratic behavior. Best way to learn about the program is through actual examples.

Removing a Service

Removing a  service seems pretty easy:

wasservice -remove SERVICE_NAME

What this command considers as service name is not same as Windows. A service has two names in Windows. A display name and service name. You can find out more about these names by running this Windows command

sc query state= all

Note: Notice the space after “state=”. Without the space, the command will fail.

WebSphere service names usually contain “IBM”. So, you can view all registered WebSphere services by running this command:

sc query state= all  | findstr IBM

If Windows shows the service name (not the display name) as “IBMWAS70Service – myNode01”, then you need to use myNode01 as the service name for the wasservice command. That is, use the name after “-“. For example:

wasservice  -remove  myNode01

This is effectively same as running the command:

sc  delete "IBMWAS70Service – myNode01"

Adding a Service

The example below will show you how to add a service that has administrative security enabled.

wasservice -add myNode01 -serverName server1
  -profilePath C:\WebSphere70\profiles\AppSrv01
  -wasHome C:\WebSphere70
  -logRoot C:\WebSphere70\profiles\AppSrv01\logs\server1
  -startType automatic
  -stopArgs "-username wasadmin -password waspass"

This will create a Windows service called “IBMWAS70Service – myNode01” for WAS7 and “IBMWAS80Service – myNode01” in WAS8.

Note: that the entire stopArgs argument has to be within double quotes.

2 Comments