I need to obtain the id of a background process using JMeter.
I'm looking for the output of:
ps -ef | grep [b]ackend.js | awk '{ print $2 }'
I cannot use a shell script because I don't want the script to be a dependency; is there a way to execute the above command in JMeter via OS Process Sampler or another plugin?
I would recommend using -c
option of Bash shell, as per the manual page
-c
Read and execute commands from the first non-option argument command_string, then exit. If there are arguments after the command_string, the first argument is assigned to $0 and any remaining arguments are assigned to the positional parameters. The assignment to $0 sets the name of the shell, which is used in warning and error messages.
So:
Configure it as follows:
See How to Run External Commands and Programs Locally and Remotely from JMeter article for more information on launching 3rd-party programs from JMeter tests.