lua-resty-gperftools
一个与 google_perftools 集成的 Nginx Lua API
$ opm get chronolaw/lua-resty-gperftools
lua-resty-gperftools
用于 `ngx_google_perftools_profiler_module` 的 Lua API
在使用这些工具之前,您必须使用 `ngx_google_perftools_profiler_module` 编译 nginx/openresty
安装
请使用 `opm`,例如
opm get chronolaw/lua-resty-gperftools
使用
一些简单的示例
location /gperftools {
content_by_lua_block {
local gperftools = require "resty.gperftools"
local profiler = ngx.var.arg_profiler
local action = ngx.var.arg_action
local name = ngx.var.arg_name
gperftools[profiler][action](name)
ngx.say("OK")
}
}
然后您可以使用 `curl` 启动/停止 gperftools,如下所示
curl 'http://127.0.0.1/gperftools?profiler=cpu&action=start&name=/tmp/ngx_prof'
curl 'http://127.0.0.1/gperftools?profiler=cpu&action=stop'
API
ok, err = proto.cpu.start(name, during)
启动 CPU 分析器,信息存储在 `name` 中。
如果指定了 `during`,则分析器将在 `during` 秒后停止。
注意:它不会为名称添加进程 ID 后缀。
proto.cpu.stop()
停止 CPU 分析器。
proto.heap.start(name, n, during)
启动堆分析器,信息存储在 `name` 中,每 `n` 秒转储一次。
如果指定了 `during`,则分析器将在 `during` 秒后停止。
注意:它不会为名称添加进程 ID 后缀。
proto.heap.dump(s)
转储堆分析器信息,`s` 表示原因。
proto.heap.stop()
停止堆分析器。
作者
chronolaw
许可证
2bsd
依赖
luajit
版本
-
一个与 google_perftools 集成的 Nginx Lua API 2018-06-29 02:26:24
-
一个与 google_perftools 集成的 Nginx Lua API 2018-06-28 09:26:48