Показаны сообщения с ярлыком jmeter. Показать все сообщения
Показаны сообщения с ярлыком jmeter. Показать все сообщения

01.07.2012

How to parse JMeter logs and import it into database for further processing

Bellow two scripts which can help you to export JMeter logs into Oracle through sqlplus&sqlldr (it should be installed in your system)
With jtl_to_db_struct.sql you can create in Oracle two tables, "tests" - with information about tests iterations and "results" - with responses from jtl, and sequence "test_id_seq" for tests identification.
With jtltodb.py you can parse jtl into csv and load it into database, use Python 2.7+ for it.

13.02.2012

How to execute command on remote server through ssh from JMeter script

Now JMeter hasn't sampler for execute command on remote server, but it has beanshell & beanshell framework which can everything what can program languages like Java, Jpython&Jython, Javascript, Perl, Groovy, Ruby, Prolog, VBScript, XSLT, etc.
Below described how with ssh library Ganymed SSH-2 for Java we can write java code, which execute for us command on remote server.
It library you can download from http://code.google.com/p/ganymed-ssh-2/ and should put into JMeter\lib directory.
PS Don't forget check exit code and set IsSuccess constant in accordance with it!!!
import java.io.*;
import java.util.*;
import ch.ethz.ssh2.*;
String hostname = "server";
String username = login;
String password = password;
String command = "uname -a";
// Connect to the server
connection = new Connection( hostname );
connection.connect();
// Authenticate
connection.authenticateWithPassword( username, password );
// Open a session
Session session = connection.openSession();
// Execute the command
session.execCommand( command );
// Read the results
StringBuilder sbOut = new StringBuilder();
StringBuilder sbErr = new StringBuilder();
InputStream stdOut = new StreamGobbler( session.getStdout() );
InputStream stdErr = new StreamGobbler( session.getStderr() );
BufferedReader brOut = new BufferedReader(new InputStreamReader(stdOut));
BufferedReader brErr = new BufferedReader(new InputStreamReader(stdErr));
String lineOut = brOut.readLine();
String lineErr = brErr.readLine();
while( lineOut != null )
{
sbOut.append( lineOut + "\n" );
lineOut = brOut.readLine();
}
while( lineErr != null )
{
sbErr.append( lineErr + "\n" );
lineErr = brErr.readLine();
}
// Close the session
session.close();
// Logout from the server
connection.close();
//Check exit code from shell
if (session.getExitStatus() == 0)
{
//Set beanshell status
IsSuccess = true;
// Return stdout
return sbOut.toString();
}
else
{
//Set beanshell status
IsSuccess = false;
// Return stderr
return sbErr.toString();
}