Saturday, August 27, 2011
Friday, August 26, 2011
dynaTrace evaluation
Download the dynatrace full install for linux x86 and windows x86 here product download page
Obtain a license key for evaluation (file will have a name like dynaTrace_license_201107201015.key)
You must have a dynatrace account to download them (dynatrace-3.5.2.2393.msi, dynatrace-3.5.2.2393-linux-x86.jar, dynaTrace_license_201107201015.key)
page dedicated to installation
Define a dedicated VM for dynatrace server/collector, I put the full install jar on a RedHat VM which acted as my server (make sure it has 4GB of RAM)
Run this to install the jar:
java -jar dynatrace-3.5.2.2393-linux-x86.jar
With this extracted to a folder (I put it in ~\dynatrace..) you can start the dyna collector and server with these commands:
cd dynatrace
nohup ./dtserver &
nohup ./dtanalysisserver &
nohup ./dtcollector &
I then ran the install for dynatrace-3.5.2.2393.msi on my desktop, I only installed the dynatrace client on my desktop.
Now you need to copy the dynatrace/agent/lib folder to the servers you want to profile/monitor (do not copy the folder to a path with a space in it like "program files", I put them in c:\tools\dynatrace\agent\lib)
Now you can change the websphere application server JVM arguments to add the dynatrace agent :
-agentpath:"C:\Tools\dynaTrace\dynaTrace 3.5.2\agent\lib\dtagent.dll"=name=OCMWS,server=192.168.1.122
-agentpath:/root/dynatrace-3.5.2/agent/lib/libdtagent.so=name=OCM,server=192.168.1.122
Note: Edit the line above to match the path to where you copied the dynatrace agent dll/so, also give each JVM you are monitoring a different name, and finaly the IP address is the dynatrace server IP address which may be different for you.
To add this to the JVM startup on WebSphere open the IBM console and go to
Servers | application server | server1 | Java Process and Management | Process Definition | Java Virtual Machine | Generic JVM Arguments
prepent the full -agentpath value to the Generic JVM arguments
Click ok and Save your changes, double check that the save took place by entering the console again and checking the generic jvm argument for the new value.
You will have to restart WebSphere to have the JVM startup with the new startup JVM arguments.
Launch the dynaTrace client after doing the above, tools | settings | dynatrace server | connectivity | put in the host IP address.
default values for login are admin:admin, port 2021, test the connection, it should be a green arrow and say success.
Click License, attach the license .key file for dynatrace evaluation: dynaTrace_license_201107201015.key.
Use online videos to see how to use the client to slice and dice the data from the agents and profile your application.
Thursday, July 28, 2011
*nix/cygwin find commands
I need to keep a record of some Linux/cygwin "find" commands that I find useful. This is sort of a cookbook or quick reference of find commands that are handy to have around.
Print files which were modified within the last 10 days but and NOT in a "CVS", "build" or "classes" folder:
find . -type d -name CVS -prune -o -name build -prune -o -name classes -prune -o -mtime -10 \! -type d -print
Print a sorted list of the largest files above 20000k minimum size
find . -type f -size +20000k -printf '%kk %p\n' | sort -n -r
Print files with XML extensions containing the phrase "search string"
find . -type f -name "*.xml" -exec grep "search string" '{}' /dev/null \; -print
Copy files newer than file X
Where file-x.txt is the file, and /tmp/copy-destination/ is the place you want to copy the files to:
find . -newer file-x.txt $1 | xargs -I {} cp -p $1{} /tmp/copy-destination/
Use OutputStreamWriter not FileWriter
Here is an example of how to use OutputStreamWriter for UTF-8 encoded output.
OutputStreamWriter out = null;
try {
try {
out = new OutputStreamWriter(new FileOutputStream(outputFile),"UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e.getMessage,e);
}
try {
out.append(yourStringDataToWriteToOutputFile);
out.flush();
} catch (IOException e) {
throw new RuntimeException(e.getMessage,e);
}
} catch (FileNotFoundException e) {
throw new RuntimeException(e.getMessage,e);
} finally {
try {
out.close();
} catch (IOException e) {
throw new RuntimeException(e.getMessage,e);
}
}
Hope this helps you get past file character encoding bugs with Java. Here is a great link on various Java Anti-Patterns which should be avoided when writing enterprise class robust code:
Saturday, June 18, 2011
How do I use my web resource bundle within my Spring controller?
Here is how I did it:
In my controller:
import org.springframework.context.ApplicationContext; ...
@Autowired private ApplicationContext context;
In the resource bundle ApplicationResources.properties
gotocode.error.notfound=Sorry {0} is not recognized as a code.
Back in the controller
public static final String GOTOCODE_NOTFOUND_KEY = "gotocode.error.notfound";
public static final String CODE_NOT_FOUND_MESSAGE = "Sorry the entry {0} is not recognized as a code.";
...
public ModelAndView findNextInSeries(String code,.. String errorMessage = context.getMessage(GOTOCODE_NOTFOUND_KEY, new Object[] { code }, CODE_NOT_FOUND_MESSAGE, Locale.getDefault());
Previously my ApplicationResources.properties was configured in the web.xml
http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" id="WebApp_1270163143862"></web-app>
<display-name>Sample Spring Resource Bundle
<distributable>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext
<param-value>ApplicationResources
As well as in the Spring Application context configuration (dispatcher-servlet.xml):
Setting up Eclipse TPTP for performance monitoring of Jetty run from Maven
This is a document to help you setup Eclipse TPTP plugin for performance monitoring of J2EE application deployed to Jetty using the jetty-maven-plugin.
Open MyEclipse Configuration center and search for TPTP, download the newest version of TPTP plugin, restart your IDE after the install finishes.
Next go to the TPTP homepage and download the Agent controller for your architecture (I downloaded windows IA32).
Extract the Agent controller zip to C:\Tools\agntctrl.win_ia32-TPTP-4.7.2
Edit your system environment variables and add
RASERVER_HOME=C:\Tools\agntctrl.win_ia32-TPTP-4.7.2 PATH=C:\Tools\agntctrl.win_ia32-TPTP-4.7.2\bin;%PATH% Open a command prompt and goto agent controller cd C:\Tools\agntctrl.win_ia32-TPTP-4.7.2\bin SetConfig.bat This should display the following:
C:\Tools\agntctrl.win_ia32-TPTP-4.7.2\bin>SetConfig.bat Specify the fully qualified path of "javaw.exe" (e.g. c:\jdk1.4\jre\bin\javaw.ex e): Default>"C:\Program Files\IBM\WebSphere\AppServer\java\jre\bin\javaw.exe" (Pre ss to accept the default value) New value> Network access mode (ALL=allow any host, LOCAL=allow only this host, CUSTOM=list of hosts): Default>"LOCAL" (Press to accept the default value) New value>ALL Security enabled. (true/false): Default>"FALSE" (Press to accept the default value) New value> Start the Agent Controller by launching a command console window with Administrator privledges (Run as Admni..) The change your working directory to
cd C:\Tools\agntctrl.win_ia32-TPTP-4.7.2\bin
ACServer.exe
See this link for more agent controller info http://dev.eclipse.org/viewcvs/viewvc.cgi/platform/org.eclipse.tptp.platform.agentcontroller/src-native-new/packaging_md/windows/getting_started.html?root=TPTP_Project&view=co
This is also a link with good info on TPTP http://eclipse.sys-con.com/node/508048?page=0,2
Configure piAgent and start your application with Maven by adding this to MAVEN_OPTS environment variable:
-XrunpiAgent:server=enabled
From eclipse navigate to Run | Profile Configurations... | Attach to Agent | New
ACServer should be running on localhost port 10002, check this with netstat -a -b -n command or test button in eclipse
Jetty JVM Agent should be detected on the Agent tab. select ONLY ONE of the profile probes, CPU --or-- MEMORY etc.. do NOT select more than one, treat them as mutually exclusive radio buttons rather than check boxes.
You can then perform tasks in your application and save the data captured. Also you can create new reports from the captured data with TPTP eclipse tools.
See http://www.eclipse.org/articles/Article-TPTP-Profiling-Tool/tptpProfilingArticle.html
About Me
blogs
Tags
- Personal (77)
- weigh-in (59)
- development (29)
- Java (23)
- loss (18)
- gain (15)
- tools (15)
- Software Engineering (13)
- Software (12)
- Austin (10)
- eclipse (7)
- J2EE (6)
- Maven (6)
- Family (4)
- XSLT (4)
- Linux (2)
- career (2)
- finance (2)
- gardening (2)
- Belts (1)
- Eleanor (1)
- IE7 (1)
- LDS (1)
- atg (1)
- car (1)
- javascript (1)
- resume (1)
- taxes Personal (1)

