Posts

Starting Perfmon on all Windows machines with a single Batch file

In one of our project we have more than 4 Windows servers. We use perfmon to monitor the resource utilization. Each time we run load test we start the perfmon on all the servers. So created the below batch file to do the job. The batch file does the below: Create a directory with current date and time Start perfmon on all 4 AR servers Wait for 1 hr Copy the result file (.csv) from each server into the director created in step1. Stop perfmon on all 4 AR servers. @echo off for /f %%I in ('wmic os get localdatetime ^|find "20"') do set dt=%%I REM dt format is now YYYYMMDDhhmmss... REM set dt=%dt:~4,2%-%dt:~2,2%-%dt:~0,4% set dt=%dt:~6,2%%dt:~4,2%%dt:~2,2%%dt:~8,2%%dt:~10,2% echo %dt% mkdir D:\Perfmon\Perfmon_%dt% logman start "Counter" -s server1 logman start "Counter" -s server2 logman start "Counter" -s server3 logman start "Counter" -s server4 timeout /t 3600 copy \\server1\c...

Beaware!!! with NewRatio while using Concurrent Mark Sweep GC as Garbage Collector

In Sun JDK there were few bugs previously with subject “ JDK-6872335 : NewRatio ignored when UseConcMarkSweepGC set”. http://bugs.java.com/view_bug.do?bug_id=6872335 http://bugs.java.com/view_bug.do?bug_id=6862534 Although these bugs are fixed, but IMO the bug still exists for default settings of NewRatio when UseConcMarkSweepGC is used. We still have the bug where the default NewRatio=2 is not considered along with UseConcMarkSweepGC Option #1 : Default GC (-XX:+UseParallelGC) : PSYoungGen      total 1835008K = 1.75GB (As it considered the default NewRatio=2) # /usr/bin/java -server -Xms6144m -Xmx6144m -XX:MaxMetaspaceSize=256m -XX:+PrintCommandLineFlags -XX:+PrintGCDetails -version -XX:InitialHeapSize=6442450944 -XX:MaxHeapSize=6442450944 -XX:MaxMetaspaceSize=268435456 -XX:+PrintCommandLineFlags -XX:+PrintGCDetails -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseParallelGC java version "1.8.0_60" Java(TM) SE Runti...

To Obtain GC details from running java process whithout adding the GC monitoring parameters in jvm args

Just wanted to share a tool for GC Monitoring. If you’ve forgotten to enable GC logging, or wanted to monitor GC in the middle of the load test, there is a good substitute to watch how GC operates over time. jstat is the tool of choice. jstat can provide good visibility into GC for a live program. jstat provides nine options to print different information about the heap; jstat -options will provide the full list. One useful option is -gcutil, which displays the time spent in GC as well as the percentage of each GC area that is currently filled. Other options to jstat will display the GC sizes in terms of KB. jstat takes an optional argument—the number of milliseconds to repeat the command—so it can monitor over time the effect of GC in an application. Syntax : jstat -gcutil <pid> <Milli Sec to repeat> Here is some sample output repeated every second: Ø jstat -gcutil 90776 1000       S0     S1 ...

Command to obtain complete details of a process running in windows

Just wanted to share a command in Windows, to obtain complete details of the processes running in windows. In Unix/Linux we use the below command to obtain all the java processes running on particular server: ps -ef|grep java which shows the PID, command line and other details. The same can be obtained in windows OS. Using Task Manager to show the command line option, the display value is so long that the CLASSPATH setting gets cut off and complete details are not obtained. To show the entire command line including switches/options is to use the WMIC command: C:\> WMIC process where caption="java.exe" Open an windows CMD prompt, execute the following "Windows Management Instrumentation Command-line" (WMIC): To obtain processid and commandline provide the arguments as get C:\> WMIC process where caption="java.exe" get processid,commandline Note: You can pipe the result out to a file like below: (Open cmd prompt ...

Database Test Plan with JMeter

Image
Let us see how we can test the database in Jmeter using JDBC Request Sampler. In this tutorial we will use oracle jdbc driver. Required jar E.g. “ojdbc6.jar” is placed in <JMETER_Path>/lib. Prepare a Test Plan as shown below: Here we have added: User Defined Variables – Defined the required parameters for Database Connection JDBC Connection Configuration Thread Group JDBC Request under Thread Group BeanShell Sampler – To display the output of the JDBC Request. View Results Tree – To View the Results JDBC Request Sampler is used to send an JDBC Request to database. But before using this we need to setup the required JDBC connection and it is done via JDBC Connection Configuration element. Under JDBC Connection Configuration we have the below defined values: We defined the Variable Name as “JDBC_Pool”. The values required for Database Connection are defined in User Defined Variables and are used here. E.g: jdbc_url = jdbc:oracle:thin:@DB_Server:por...

Using a Custom Jar in BeanShell Sampler in Jmeter

Image
Let us see an example on how we can use a custom Java classes and methods in JMeter BeanShell sampler. Outline of the steps: Write Java classes and methods in IDE tools like Eclipse or NetBeans Create a Jar of the above project Import the Jar to JMeter location Use the Java method in Jmeter BeanShell sampler Run the test plan and check results Let us see the above step by step: For getting the concepts clear, let us create an example class which will generate factorial of a given number. The number will also be a random number. Let us create a class containing the method to calculate a factorial and this will be used in JMeter. I created the method as below in eclipse. Here we have created new project “FactorialJar”. Under the project, we created two projects named as “FactClass” and “TestFact”. Under each class we created a Class called “Fact” and “Facttest”. Code for Fact.java is as below: package  FactClass; public   class  Fact {  ...

How to use a value between two different threads in Jmeter

Image
How to use a value between two different threads: Let us see how we can use the extracted value in one thread can be used in a different thread: As shown below we have Two threads (Thread Group – 1 and Thread Group -2). Under Thread Group -1 we have a HTTP Request where we extracted Request_Id and Session_Id. In our example we will use the same Ids in Thread Group -2 We have BeanShell PostProcessor to log the output of the variables in the output log. The Lines in the both BeanShell is as below: log.info("Request Id in Thread 1 = " + "${Request_Id}"); log.info("Session Id in Thread 1 = " + "${Session_Id}"); Now if we run the Script we get the below output: As we see the values of both the IDs are not passed to Thread Group-2. Now we will add few lines in the BeanShell PostProcessor as below and run again: ${__setProperty(Request_Id,"${Request_Id}")}; ${__setProperty(Session_Id,"${Session_Id}")}; ...