lua 问题 open-falcon 出错

2018/05/17 22:35:44 [error] 54034#0: *11 lua entry thread aborted: runtime error: /usr/local/nginx/modules/ngx_metric_output.lua:3: module 'ngx_metric.counter' not found:
        no field package.preload['ngx_metric.counter']
        no file 'modules/ngx_metric/counter.lua'
        no file './ngx_metric/counter.lua'
        no file '/usr/local/LuaJIT/share/luajit-2.0.2/ngx_metric/counter.lua'
        no file '/usr/local/share/lua/5.1/ngx_metric/counter.lua'
        no file '/usr/local/share/lua/5.1/ngx_metric/counter/init.lua'
        no file '/usr/local/LuaJIT/share/lua/5.1/ngx_metric/counter.lua'
        no file '/usr/local/LuaJIT/share/lua/5.1/ngx_metric/counter/init.lua'
        no file './ngx_metric/counter.so'
        no file '/usr/local/lib/lua/5.1/ngx_metric/counter.so'
        no file '/usr/local/LuaJIT/lib/lua/5.1/ngx_metric/counter.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
        no file './ngx_metric.so'
        no file '/usr/local/lib/lua/5.1/ngx_metric.so'
        no file '/usr/local/LuaJIT/lib/lua/5.1/ngx_metric.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
coroutine 0:
        [C]: in function 'require'
        /usr/local/nginx/modules/ngx_metric_output.lua:3: in function </usr/local/nginx/modules/ngx_metric_output.lua:1>, client: 127.0.0.1, server: 127.0.0.1, request: "GET /monitor/basic_status HTTP/1.1", host: "127.0.0.1:9091"
2018/05/17 22:35:44 [error] 54034#0: *11 failed to run log_by_lua*: /usr/local/nginx/modules/ngx_metric.lua:4: module 'ngx_metric.util' not found:
        no field package.preload['ngx_metric.util']
        no file 'modules/ngx_metric/util.lua'
        no file './ngx_metric/util.lua'
        no file '/usr/local/LuaJIT/share/luajit-2.0.2/ngx_metric/util.lua'
        no file '/usr/local/share/lua/5.1/ngx_metric/util.lua'
        no file '/usr/local/share/lua/5.1/ngx_metric/util/init.lua'
        no file '/usr/local/LuaJIT/share/lua/5.1/ngx_metric/util.lua'
        no file '/usr/local/LuaJIT/share/lua/5.1/ngx_metric/util/init.lua'
        no file './ngx_metric/util.so'
        no file '/usr/local/lib/lua/5.1/ngx_metric/util.so'
        no file '/usr/local/LuaJIT/lib/lua/5.1/ngx_metric/util.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
        no file './ngx_metric.so'
        no file '/usr/local/lib/lua/5.1/ngx_metric.so'
        no file '/usr/local/LuaJIT/lib/lua/5.1/ngx_metric.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
        [C]: in function 'require'
        /usr/local/nginx/modules/ngx_metric.lua:4: in function </usr/local/nginx/modules/ngx_metric.lua:1> while logging request, client: 127.0.0.1, server: 127.0.0.1, request: "GET /monitor/basic_status HTTP/1.1", host: "127.0.0.1:9091"

提示 module 'ngx_metric.counter' not found: 没找到

但是我是有这个文件的

modules/
├── avg.lua
├── chunk_histogram.lua
├── counter.lua
├── histogram.lua
├── ngx_metric
│   ├── avg.lua
│   ├── chunk_histogram.lua
│   ├── counter.lua
│   ├── histogram.lua
│   ├── ngx_metric.lua
│   └── util.lua
├── ngx_metric.lua
├── ngx_metric_output.lua
└── util.lua   

cat /usr/local/nginx/modules/ngx_metric.lua 的部分代码

 

local util = require "ngx_metric.util"
local counter = require "ngx_metric.counter"
local chunkhisto = require "ngx_metric.chunk_histogram"

local _M = { _VERSION = '0.0.1' }
local mt = { __index = _M }

local function cut_uri(uri, section_len)
    local uri_a = util.str_split(uri, "/")
    local res = ""
    for i = 1, math.min(section_len, #uri_a) do
        res = res .. "/" .. uri_a[i]
    end
    return res
end
阅读 3.9k
2 个回答

这里是哪里出错了?帮忙看下

新手上路,请多包涵

这个一般是ngx的启动路径问题,ngx_metric.conf配置的是相对路径,所有你的环境需要在/usr/local/nginx下面启动图片描述

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进