Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to pass arguments to the LUA script #31

suni1mp opened this issue Oct 4, 2016 · 1 comment

How to pass arguments to the LUA script #31

suni1mp opened this issue Oct 4, 2016 · 1 comment


Copy link

@suni1mp suni1mp commented Oct 4, 2016

How to pass argument to LUA script

./wrk -d 20 -p 5 -s ./luascripts/wrkscript_get.lua arg1,arg2 -R 4 http://URL

Copy link

@steers steers commented Oct 14, 2016

As per the scripting API documentation, the init function takes a parameter args, an array whose values are populated by arguments provided to the wrk binary after --, e.g.

$ wrk -t1 -c1 -d10 -R10 -s /tmp/args.lua http://localhost:1337 -- arg1 arg2

Try experimenting using an init function like the following:

function init(args) 
     for i, v in ipairs(args) do

Which, when invoked as listed above, should output the following:

1       arg1
2       arg2

You can also use environment variables, e.g.

$ env foo=1 bar=2 wrk -t1 -c1 -d10 -R10 -s /tmp/args.lua http://localhost:1337

Which can be accessed in Lua using os.getenv(), e.g.

local environment =  {
   foo = tonumber(os.getenv("foo")),
   bar = tonumber(os.getenv("bar")),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants