Skip to content

Instantly share code, notes, and snippets.

@hostmaster
Last active February 27, 2020 10:44
Embed
What would you like to do?
Lua script for redis_exporter
$ redis-cli -eval Redis_queue.lua
local result = {}
local cur = "0"
local pat = "*:queue"
local keys = nil
local done = false
local t = redis.call('TIME')
repeat
local r = redis.call("SCAN", cur, "MATCH", pat);
cur = r[1]
keys = r[2]
for _, v in ipairs(keys) do
local z = redis.call("ZCOUNT", v, '0', t[1])
table.insert(result, v)
table.insert(result, tostring(z))
end
if cur == "0" then
done = true
end
until done
return result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment