Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Developer articles
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
open-catlog
nginxMonitor
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
nginxMonitor
/
general.lua
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
49 lines (41 loc) · 1.47 KB
master
Breadcrumbs
nginxMonitor
/
general.lua
Copy path
Top
File metadata and controls
Code
Blame
49 lines (41 loc) · 1.47 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
40
41
42
43
44
45
46
47
48
49
-- general.lua
local access = ngx.shared.access
local uri = ngx.var.uri
local host = ngx.var.host
local ip = ngx.var.remote_addr
local request_time = ngx.var.request_time
local isFilter = false
local find = string.find
local filter = {"-----"}
for k, v in ipairs(filter) do
if host == v then
isFilter = true
end
end
if isFilter == true then
-- 存储的过期时间,若为0,则永远不过期
local expire_time = 0
-- 请求时间
local req_time_key = table.concat({host, ":", uri, ":request_time"})
-- 请求总数
local total_req_key = table.concat({host, ":", uri, ":request_count"})
-- 平均响应时间
local average_time_key = table.concat({host, ":", uri, ":average_request_time"})
-- 客户端ip
local page_view_key = table.concat({host, ":", ip, ":page_view"})
-- 计算特定uri的请求次数
local count_req_sum = access:get(total_req_key) or 0
count_req_sum = count_req_sum + 1
access:set(total_req_key, count_req_sum, expire_time)
-- 计算特定uri的响应时间
local time_req_sum = access:get(req_time_key) or 0
time_req_sum = time_req_sum + request_time
access:set(req_time_key, time_req_sum, expire_time)
-- 计算特定uri的平均响应时间
local time_req_ave = time_req_sum / count_req_sum
access:set(average_time_key, time_req_ave, expire_time)
-- 计算每个ip的pv
local page_view_sum = access:get(page_view_key) or 0
page_view_sum = page_view_sum + 1
access:set(page_view_key, page_view_sum, expire_time)
end
You can’t perform that action at this time.