Wednesday, February 7, 2024

Tracking File Processing Time on a Remote Server with JMeter | Remote machine file processing times by JMeter

In many applications, files are processed on remote servers as part of their workflow. Monitoring the time it takes for files to be processed is crucial for performance evaluation and optimisation. In this blog post, we'll explore how to track the processing time of files on a remote server using Apache JMeter.


Prerequisites:

Before getting started, make sure you have the following:
- Apache JMeter installed
- SSH Protocol Support plugin installed in JMeter

Step 1: Setting Up the Test Plan
  • Adding SSH Command Samplers: We'll use the SSH Command Sampler in JMeter to execute commands on the remote server. Add SSH Command Samplers to the test plan for capturing start time, executing the processing command, and capturing end time.
  • Configuring SSH Connection: Configure the SSH connection details such as hostname, port, username, and password or SSH key.
  • Defining Processing Command: Define the command to process the file and move it to another folder on the remote server within the SSH Command Sampler.

Step 2: Capturing Start Time

Pre-processing:Before executing the processing command, capture the start time using a pre-processor or by executing a command to get the current timestamp.

Step 3: Executing Processing Command

Executing Command:  Execute the command to process the file and move it to another folder on the remote server using the SSH Command Sampler.

Step 4: Capturing End Time

Post-processing:   After executing the processing command, capture the end time using a post-processor or by executing a command to get the current timestamp.

Step 5: Calculating Processing Time

   - Calculate the processing time by subtracting the start time from the end time.

Here's how you can modify the JMeter test plan:

Test Plan
  Thread Group
    SSH Command Sampler (Pre-processor)
      Command: date +%s > /path/to/start_time.txt
    SSH Command Sampler
      Server Name: your_server_hostname
      Port: your_ssh_port
      Username: your_ssh_username
      Password: your_ssh_password_or_key
      Command: cd /path/to/source_folder && your_processing_command && mv processed_file /path/to/destination_folder
    SSH Command Sampler (Post-processor)
      Command: date +%s > /path/to/end_time.txt
    View Results Tree (or other listeners)


Replace placeholders like `your_server_hostname`, `your_ssh_port`, `your_ssh_username`, `your_ssh_password_or_key`, `/path/to/source_folder`, `your_processing_command`, and `/path/to/destination_folder` with your actual server details and commands.

After running the test plan, you can read the start time and end time from the files `/path/to/start_time.txt` and `/path/to/end_time.txt`, respectively, and calculate the processing time. You can use the `SSH Command Sampler` to read the contents of these files and extract the timestamps. Then, use a post-processor or a custom script to calculate the processing time.

Happy Testing !

No comments: