Skip to content

Instantly share code, notes, and snippets.

Last active July 1, 2022 18:53
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Read sticky table of HA proxy from lua action
function dump_str(o)
-- transform a table into a string for the printing.
-- found it on google
-- better to use print_r from here
if type(o) == 'table' then
local s = '{ '
for k,v in pairs(o) do
if type(k) ~= 'number' then k = '"'..k..'"' end
s = s .. '['..k..'] = ' .. dump_str(v) .. ','
return s .. '} '
return tostring(o)
-- name of the sticky table we are lookgin for
-- in the hapory.cfg something like
-- backend per_auth_rates
-- stick-table type string len 180 size 200k expire 60s store gpc1,http_req_rate(60s),conn_rate(60s)
my_stk_name = 'per_auth_rates'
function read_stk(txh)
-- get the proxy, since we have to first get it and read it sticky
my_stk = core.proxies[my_stk_name]
-- get the sicky and use it's dump function.
-- in lua, functions of an object are called with : not .
-- thanks to Thierry Fournier
core.register_action("read_stk", {'tcp-req', 'http-req'}, read_stk, 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment