diff options
Diffstat (limited to 't/proxyustats.lua')
-rw-r--r-- | t/proxyustats.lua | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/t/proxyustats.lua b/t/proxyustats.lua new file mode 100644 index 0000000..e0302cb --- /dev/null +++ b/t/proxyustats.lua @@ -0,0 +1,31 @@ +-- get some information about the test being run from an external file +-- so we can modify ourselves. +local config = dofile("/tmp/proxyustats.lua") + +local idx = 1 + +function mcp_config_pools(old) + mcp.backend_read_timeout(4) + mcp.backend_connect_timeout(5) + local pfx, f, l = string.match(config, "(%S+)%s*(%S+)%s*(%S+)") + local first = tonumber(f) + local last = tonumber(l) + while first <= last do + mcp.add_stat(first, pfx .. first) + first = first + 1 + end + + return {} +end + +function route_fn(zones) + return function(r) + local key = r:key() + mcp.stat(math.abs(tonumber(key)), tonumber(key)) + return "HD\r\n" + end +end + +function mcp_config_routes(zones) + mcp.attach(mcp.CMD_MG, route_fn(zones)) +end |