File: proxyustats.lua

package info (click to toggle)
memcached 1.6.39-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,320 kB
  • sloc: ansic: 62,281; perl: 12,500; sh: 4,569; makefile: 468; python: 402; xml: 59
file content (39 lines) | stat: -rw-r--r-- 990 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
-- 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+)")
    if pfx == "mask1" then
        mcp.add_stat(1, "maska")
        mcp.add_stat(2, "maskb")
    elseif pfx == "mask2" then
        mcp.add_stat(1, "")
        mcp.add_stat(2, "maskb")
    else
        local first = tonumber(f)
        local last = tonumber(l)
        while first <= last do
            mcp.add_stat(first, pfx .. first)
            first = first + 1
        end
    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