Introduction
The OS Process Sampler in JMeter allows to execute OS commands and scripts during a test. This can be particularly beneficial in executing batch, shell scripts or monitor disk usage during a performance test.
OS Process Sampler
Steps to add a OS Process Sampler in your test plan:
Add a Thread Group > Click on Add > Click on Sampler > Find OS Process Sampler from the list

Hands On to OS Process Sampler
Scenario
You have a file management system hosted on Linux based EC2 instance. This is the system of creating, reading, updating and deleting files. You are curious to monitor the disk space usage during your performance testing.
Assumptions
You are executing a performance test where multiple users are simultaneously uploading and deleting files on the system. Let’s say you have a test plan where multiple threads (users) are simulating file uploads and deletions utilizing HTTP Requests or whatever may be relevant for your File Management System.

Setting up OS Process Sampler
1. Add a OS Process Sampler to the above test plan
2. Configure the OS Process Sampler
- Command : df -h /
df : This command displays information of total space and available space of your linux system.
-h : This implies to display the information in human – readable format.
/ : directory for which you need to display the information

- Parameters : Leave this space blank, since we do not need this now.

- Check Return Code and set expected return code as 0 : Enable this option if you want to verify that the command executes successfully (exit code 0).

3. Timer for OS Process Sampler : Add a Constant Timer with a delay of 60000 ms (1 minute) before the OS Process Sampler. This ensures the sampler checks disk usage every minute.
4. Position of OS Process Sampler : Positioning the OS Process Sampler in a different thread group allows you to run it independently of the main test operations, which can be useful for continuous monitoring of system resources without affecting the primary load generation.

5. Finally, add a listener to capture the output
Sample Output
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 100G 40G 60G 40% /
After reading this so far, let me know your thoughts on how would/have you utilize OS Process Sampler for your need in performance. Below links will navigate you to more details on OS Process Sampler.
Leave a Reply