We all know pretty well that JMeter is a server performance testing tool for both static and dynamic resources. I've had successfully used JMeter for the above written purpose through it's easy to use GUI interface. Recently we've been experiencing a lot of "server down" issue but we're unable to find out when exactly server is down until we're requesting something to it and get nothing in return.
So I thought of using JMeter as a solution here. Using JMeter I would be hitting the server at particular intervals, say once in every 3hours and get a response back which will correctly identify that server is working fine. Using it in GUI mode is not apt. It needs to be scheduled for every 3 hours.
Through a bit of Google's help I learnt JMeter could also be used in "non GUI mode". So I took the script and made a bat file of it. I then triggered the bat file using Java cod with the help of Timer class for scheduling. The script inside the bat file is :
jmeter -n -t E:\Jmeter.jmx -l E:\test.txt
Using above script I get summary report in test.txt which looks like:
1440049645804,576,SOAP/XML-RPC Request,200,OK,Thread Group 1-1,text,true,583,1,1,574
The result was same even when the server was down. I added "View Results Tree" as listener in GUI and saved it but still the result was same. By default the non GUI mode gets just the summary. I would want the Response data of Result tree as well.
The Response data shown above confirms whether server is returning valid data or not. Is there any way I could add up the Response data to my result file?
Also I found the test plans could be run inside the java code using the JMeter API's and Interface i.e JavaSamplerClient . I searched but could not find a live example that I could understand clearly.
Thanks in advance.
In order to see response data you need to do the following:
Switch JMeter output format to XML
"Tell" it to save response data
Command line solution will look like:
jmeter -Jjmeter.save.saveservice.output_format=xml -Jjmeter.save.saveservice.response_data=true -n -t E:\Jmeter.jmx -l E:\test.txt
In regards to running JMeter test from Java see chapter 4.2 Running an existing JMeter Test from Java code of the 5 Ways To Launch a JMeter Test without Using the JMeter GUI guide.
JavaSamplerClient - is the way of creating custom Java Request Samplers, I doubt that it is what you looking for
Related
I have some mex files that urgently need to be called via MATLAB, there is currently no way around. However, I really despise MATLAB's GUI (in)possibilities and would like to create some e.g. JavaFX Apps.
My question: how can a Java app's communicate with a running MATLAB instance?
I know that you can include Java objects into MATLAB, however I would prefere to have a standalone Java app.
Java can execute commands via command line for example:
Process process = Runtime.getRuntime().exec(command);
process.waitFor();
So it is possible to execute a MATLAB script via command line in Java.
In MATLAB it is possible to write files with any data needed. I don't remember the exact way you may do this. http://www.mathworks.com/help/matlab/ref/fprintf.html gives an example:
x = 0:.1:1;
A = [x; exp(x)];
fileID = fopen('exp.txt','w');
fprintf(fileID,'%6s %12s\n','x','exp(x)');
fprintf(fileID,'%6.2f %12.8f\n',A);
fclose(fileID);
It is some kind of a workaround but it should work and it is not really hard to implement.
Update.
If Matlab is already running and you want to communicate with it in another application (Java), it may be done using a network connection through the localhost. Matlab may listen to some predefined port (for code example see http://www.mathworks.com/matlabcentral/fileexchange/11802-matlab-tcp-ip-code-example ) and do some action when a "start" trigger is sent via Java (or even some data along with the trigger). In Java you may use the Socket class (some code example may be found here http://www.javaworld.com/article/2077322/core-java/core-java-sockets-programming-in-java-a-tutorial.html ).
Also it may be done writing data into files. For example, Java adds some command to some file with predefined name (command.txt). Matlab scans this file in a loop and when something is found there it starts calculation (and Java application waits for results in some results.txt file).
I would suggest to start a server in Matlab that listens on a specific port to send/receive data to/from a Java client. By using the eval Matlab command you could even invoke scripts/command/etc. remotely controlled by a Java client.
You might want to have a look at this code example.
i developed application which will converts tiff,jpeg,pdfs in a zip file to single pdf,and its working fine and size is also similar to original files , but i need to compress the pdf ( save my file server memory) i searched in google , i got ghost script which will reduce the size of 5mb pdf to 50kb,and i manually executed same in linux and its working fine,but i want to run same command in java programme,
but i dont know how to run linux command in java programme since i am new to java i am facing difficulties,can any one post sample programme how to run linux commands in java ,so i can try myself
What you want to do should be able to be achieved by simply running a bash script, which is pretty simple. Also it happens that someone has asked that question before so that answer should in turn answer yours. Please let me know if you want a more detailed response or need help with the implementation.
Running a bash shell script in java
I'm having a problem runnig Java class run through a Python script, that is in turn executed by an Apache web server.
I have the following file, accesible via an Apache webserver
script.cgi
#!/usr/bin/python
os.system("java HelloWorld")
sys.stdout.flush()
The I run the script from the shell, it runs properly. However, when I access it via a web browser, the os.system("java ...") returns exit status 1536.
Any idea why this is happening?
This is running on Linux Mint 13. Please let me know what extra information I can provide.
Thank you
When running the script from your command line you probably have different enviroment variables set and you have a different security content.
Make sure that your webserver finds the files (E.g. try using full path names) and check if everyone has the execute permission for java and read to the folder and file(For security reasons I'm not sure if that is a good idea tough).
Here's what I'm looking at doing. I've certain log files on a unix box. The files are in the range of 10-100 MB. What I'm looking at building is have a web application in which I can have the unix command line, where I can type my commands like grep,ls etc and then the output that the command gives can be displayed in a table/gridview in the web app. Is this possible to do? I'm looking at a solution possibly in Java. The only thing I cannot use is Microsoft stack.
Have you tried the web SSH clients listed here: http://en.wikipedia.org/wiki/Web-based_SSH
java Runtime can help you. It will allow you to create process and execute the command inside the process and get the results back.
I am not able to figure out how to upload bulk data to the Google's servers bypassing the 10mb upload limit and 30 sec session timeout. I want to design an application that takes my standard SQL data and pushes it to the Google's servers.
I might sound naive but your help is most valuable for my project.
There's not currently a native Java bulkloader, so what you need to do is use the Python one. The process goes like this:
First, you'll need to download the Python SDK and extract it. Then, create an empty directory, and in it create a file called app.yaml, containing the following:
application: yourappid
version: bulkload
runtime: python
api_version: 1
handlers:
- url: /remote_api
script: $PYTHON_LIB/google/appengine/ext/remote_api/handler.py
login: admin
Now, run "appcfg.py update yourdir" from the Python SDK, and enter your credentials when prompted. appcfg will upload a new version of your app, which will run side-by-side with your main version, and allow you to bulkload.
Now, to do the actual bulkloading, you need to use the Python Bulkloader. Follow the instructions here. You'll need to know a (very) little bit of Python, but it's mostly copy-and-paste. When you're done, you can run the bulkloader as described in the article, but add the "-s bulkload.latest.yourapp.appspot.com" argument to the command line, like this:
appcfg.py upload_data --config_file=album_loader.py --filename=album_data.csv --kind=Album -s bulkload.latest.yourapp.appspot.com <app-directory>
Finally, to load data directly from an SQL database instead of from a CSV file, follow the instructions in my blog post here.
I wanna do the same thing also. So, here's my naivest concept to achieve the goal.
Web Server Preparation
Create a servlet that will receive the uploaded data (e.g. for data type
XML, JSON)
(optional) store it as Blobstore
Parse the data using JAXB/JSoup and/or GSON
Dynamically interpret the data structure
Store it using Datastore/
Client Uploader Preparation
Using a local computer, create a Java/C++/PHP script that generates XML/JSON files and store it locally
Create a shell script (linux) or batch file (windows) to programatically upload the files using cURL.
Please drop a comment to this one if you have better idea guys.