Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
59 lines (44 sloc) 1.48 KB
daemon off;
worker_processes 2;
error_log /tmp/nginx_error.log warn;
events {
}
http {
# Lua configuration
lua_package_path "$prefix/?.lua;;";
lua_shared_dict log_dict 1M;
server {
listen 8080;
location / {
# Replace with your web application
content_by_lua "
ngx.say('Hello');
";
# this logging code can be added to any existing nginx.conf
log_by_lua '
local logging = require("logging")
local request_time = ngx.now() - ngx.req.start_time()
logging.add_plot(ngx.shared.log_dict, "request_time", request_time)
';
}
}
# log server - print the log generated by our web application
server {
listen 127.0.0.1:6080;
location / {
content_by_lua '
local logging = require("logging")
local count, avg, elapsed_time =
logging.get_plot(ngx.shared.log_dict, "request_time")
local qps = 0
ngx.say("Since last measure:\t", elapsed_time, " secs")
ngx.say("Request Count:\t\t", count)
ngx.say("Average req time:\t", avg, " secs")
if elapsed_time > 0 then
qps = count / elapsed_time
end
ngx.say("Requests per Secs:\t", qps)
';
}
}
}