In my previous post I have outlined the usage of OS Sampler in JMeter for Windows operating system. In this blog post, let us see how you can use the OS Sampler in the Linux or macOS operating system.
What is OS Sampler in JMeter?
OS Sampler helps to execute the commands in the local system. There are use cases for OS Sampler: generating certificates for load testing or generating AWS temporary tokens for the subsequent AWS service calls.
Above is a simple example of listing all the S3 buckets using
The above sampler executes
aws s3 ls command and outputs all the S3 buckets, assuming the
aws is configured properly. This method is not advisable as we are storing the access and secret credentials locally to the system.
Instead, it is advisable to use AWS STS temporary credentials using the below command. Below sampler will output the temporary credentials which then you can extract using the JSON Extractor.
Points to Note
In a few instances, you need to provide the absolute path of the executable, e.g.
/usr/local/bin/aws in the
Another mistake engineers often make is passing the commands without
/c executes the command from the string e.g. below command will fail in JMeter.
But by passing
-c will work fine. In case of Windows, please use
I hope the above points will help in solving OS Process Sampler related issues while scripting. Please share if you have any tricks with the community.