在http中加入,可以统计5分钟网站所有状态码个数
-
lua_shared_dict my_status 32m;
-
log_by_lua_block {
-
local akin = ngx.shared.my_status
-
local five = math.floor(os.time()/300)*300
-
local date = os.date("%Y%m%d%H%M",five)
-
local httpcode = ngx.var.host .. "_" .. ngx.var.status .. "_" .. date
-
--- ngx.log(ngx.ERR, httpcode)
-
local value = akin:get(httpcode)
-
if not value then
-
akin:set(httpcode,1, 30*60)
-
--- akin:expire(httpcode, 30*60)
-
value=1
-
end
-
akin:incr(httpcode,1)
-
-
}