nginx + lua收集网站状态码

110阅读 0评论2024-06-19 badb0y
分类:系统运维

在http中加入,可以统计5分钟网站所有状态码个数

点击(此处)折叠或打开

  1. lua_shared_dict my_status 32m;
  2.     log_by_lua_block {
  3.         local akin = ngx.shared.my_status
  4.         local five = math.floor(os.time()/300)*300
  5.         local date = os.date("%Y%m%d%H%M",five)
  6.         local httpcode = ngx.var.host .. "_" .. ngx.var.status .. "_" .. date
  7.         --- ngx.log(ngx.ERR, httpcode)
  8.         local value = akin:get(httpcode)
  9.         if not value then
  10.             akin:set(httpcode,1, 30*60)
  11.             --- akin:expire(httpcode, 30*60)
  12.             value=1
  13.         end
  14.         akin:incr(httpcode,1)

  15.     }
上一篇:python爬虫 js混淆与破解
下一篇:docker镜像安全扫描工具--grype