When you start those slaves you have to pass the variable with -J argument like that:
for slave in slaves:
serial_index += 1
run_jmeter_server_cmd = 'nohup java -jar "/bin/ApacheJMeter.jar" "-Djava.rmi.server.hostname={0}" -Dserver_port={1} -Jserial_index={3} > /dev/null 2>&1 '.format(hostname, port, serial_index)
And serial_index must be in User Defined Variables in test plan:
serial_index: ${__P(serial_index)}
Windows batch:
for /l %x in (1, 1, 100) do (
echo %x
jmeter -n -t C:\User\Scriptname.jmx -Jusers=0 -Jserial_number=%x
)
Linux bash:
for i in {1..5}
cd $JMETER_DIR/bin/
DIRNAME=`dirname $0`
nohup java $JVM_ARGS -jar "$JMETER_DIR/bin/ApacheJMeter.jar" "$@" "-Djava.rmi.server.hostname=$host" -Dserver_port=\$port -s -Jpoll=\$i > /dev/null 2>&1 &
done;