1
0
mirror of https://github.com/cmur2/nginx-metrics-graphite.git synced 2024-12-22 12:54:23 +01:00

Fix hints of luacheck

This commit is contained in:
cn 2018-11-09 14:48:39 +01:00
parent 5b82851967
commit 559ad81a0d
2 changed files with 9 additions and 9 deletions

View File

@ -53,7 +53,7 @@ Intermittent network errors while communicating with Graphite might leed to perm
apt-get install luarocks # on Debian apt-get install luarocks # on Debian
luarocks --local install luacheck luarocks --local install luacheck
luacheck --globals ngx -- metrics_graphite.lua luacheck --globals ngx --no-max-line-length -- metrics_graphite.lua
``` ```
## License ## License

View File

@ -49,15 +49,15 @@ function MetricsGraphite.init(carbon_hosts, interval, mbase)
self.stats:set("request_time_sum", 0) self.stats:set("request_time_sum", 0)
self.stats:set("request_time_num", 0) self.stats:set("request_time_num", 0)
for k,v in pairs(self.query_status) do for k,_ in pairs(self.query_status) do
self.stats:set(k, 0) self.stats:set(k, 0)
end end
for k,v in pairs(self.query_method) do for k,_ in pairs(self.query_method) do
self.stats:set(k, 0) self.stats:set(k, 0)
end end
for k,v in pairs(self.query_http) do for k,_ in pairs(self.query_http) do
self.stats:set(k, 0) self.stats:set(k, 0)
end end
@ -97,9 +97,9 @@ function MetricsGraphite:worker()
end end
-- connect to carbon host with submission port via TCP -- connect to carbon host with submission port via TCP
local ok, err = sock:connect(carbon_host, 2003) local ok, err2 = sock:connect(carbon_host, 2003)
if not ok then if not ok then
ngx.log(ngx.ERR, "nginx-metrics-graphite callback failed to connect carbon host #" .. i .. " socket: ", err) ngx.log(ngx.ERR, "nginx-metrics-graphite callback failed to connect carbon host #" .. i .. " socket: ", err2)
return return
end end
@ -118,15 +118,15 @@ function MetricsGraphite:worker()
sock:send(this.mbase .. ".nginx_metrics.avg_request_time " .. avg_request_time .. " " .. ngx.time() .. "\n") sock:send(this.mbase .. ".nginx_metrics.avg_request_time " .. avg_request_time .. " " .. ngx.time() .. "\n")
for k,v in pairs(self.query_status) do for k,_ in pairs(self.query_status) do
sock:send(this.mbase .. ".nginx_metrics.num_" .. k .. " " .. this.stats:get(k) .. " " .. ngx.time() .. "\n") sock:send(this.mbase .. ".nginx_metrics.num_" .. k .. " " .. this.stats:get(k) .. " " .. ngx.time() .. "\n")
end end
for k,v in pairs(self.query_method) do for k,_ in pairs(self.query_method) do
sock:send(this.mbase .. ".nginx_metrics.num_" .. k .. " " .. this.stats:get(k) .. " " .. ngx.time() .. "\n") sock:send(this.mbase .. ".nginx_metrics.num_" .. k .. " " .. this.stats:get(k) .. " " .. ngx.time() .. "\n")
end end
for k,v in pairs(self.query_http) do for k,_ in pairs(self.query_http) do
sock:send(this.mbase .. ".nginx_metrics.num_" .. k .. " " .. this.stats:get(k) .. " " .. ngx.time() .. "\n") sock:send(this.mbase .. ".nginx_metrics.num_" .. k .. " " .. this.stats:get(k) .. " " .. ngx.time() .. "\n")
end end