forked from songweihang/knight
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b1c7f53
commit 190b13f
Showing
6 changed files
with
130 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,26 @@ | ||
local stats = require "apps.lib.stats".init() | ||
--local stats = require "apps.lib.stats".init() | ||
|
||
local statsCache = ngx.shared.stats | ||
local systemConf = require "config.init" | ||
local statsPrefixConf = systemConf.statsPrefixConf | ||
|
||
--[[ | ||
初始化统计缓存 | ||
@param cache ngx_shared | ||
@param table conf | ||
@return | ||
]]-- | ||
local function intStatsNumCache(cache,conf) | ||
|
||
local ok, err = cache:add(conf.http_total,0) | ||
if ok then | ||
cache:add(conf.http_fail,0) | ||
cache:add(conf.http_success_time,0) | ||
cache:add(conf.http_fail_time,0) | ||
cache:add(conf.http_success_upstream_time,0) | ||
cache:add(conf.http_fail_upstream_time,0) | ||
end | ||
end | ||
|
||
|
||
intStatsNumCache(statsCache,statsPrefixConf) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,31 @@ | ||
--[[ | ||
]]-- | ||
local statsCache = ngx.shared.stats | ||
local statsAllCache = ngx.shared.statsAll | ||
local statsMatchCache = ngx.shared.statsMatch | ||
|
||
local systemConf = require "config.init" | ||
local statsPrefixConf = systemConf.statsPrefixConf | ||
local statsMatchConf = systemConf.statsMatchConf | ||
local statsAllSwitchConf = systemConf.statsAllSwitchConf | ||
|
||
local ngx_var_status = ngx.var.status | ||
local ngx_var_uri = ngx.var.uri or '' | ||
local ngx_var_host = ngx.var.host | ||
local ngx_var_request_time = ngx.var.request_time or 0 | ||
local ngx_var_upstream_response_time = ngx.var.upstream_response_time or 0 | ||
|
||
local stats = require "apps.lib.stats" | ||
|
||
stats.run() | ||
stats.statsAll() | ||
stats.statsMatch() | ||
local statsRun = stats:new( | ||
ngx_var_status, | ||
ngx_var_uri, | ||
ngx_var_host, | ||
ngx_var_request_time, | ||
ngx_var_upstream_response_time | ||
) | ||
|
||
statsRun:incrStatsNumCache(statsCache,statsPrefixConf) | ||
--stats.statsAll() | ||
--stats.statsMatch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters