JMeter OS Sampler onLinux or macOS

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.

JMeter OS Sampler onLinux or macOS
JMeter OS Sampler to list S3 bucket lists

Above is a simple example of listing all the S3 buckets using aws command.

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.

aws sts caller identity
aws sts caller identity

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 Command path.

Absolute Path of Executable
Absolute Path of Executable

Another mistake engineers often make is passing the commands without /c option. /c executes the command from the string e.g. below command will fail in JMeter.

Failed Command
Failed Command

But by passing -c will work fine. In case of Windows, please use /c

-c in OS Process Sampler
-c in OS Process Sampler

Conclusion

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.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

10000+ students are learning for FREESUBSCRIBE NOW
+ +
Share via
Copy link