{"id":21970805,"url":"https://github.com/kingluo/ngx_lua_block_check","last_synced_at":"2025-03-22T22:44:08.319Z","repository":{"id":70272704,"uuid":"100857778","full_name":"kingluo/ngx_lua_block_check","owner":"kingluo","description":"This tool is used to find out long running coroutine resume, which means CPU intensive computations and/or blocking on system calls (e.g. disk read/write, os.execute).","archived":false,"fork":false,"pushed_at":"2017-08-21T05:18:59.000Z","size":17,"stargazers_count":2,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-28T02:27:24.447Z","etag":null,"topics":["blocking","nginx","openresty"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kingluo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-08-20T11:45:29.000Z","updated_at":"2024-11-30T20:49:13.000Z","dependencies_parsed_at":"2023-02-22T03:46:02.929Z","dependency_job_id":null,"html_url":"https://github.com/kingluo/ngx_lua_block_check","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kingluo%2Fngx_lua_block_check","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kingluo%2Fngx_lua_block_check/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kingluo%2Fngx_lua_block_check/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kingluo%2Fngx_lua_block_check/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kingluo","download_url":"https://codeload.github.com/kingluo/ngx_lua_block_check/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245031362,"owners_count":20549913,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blocking","nginx","openresty"],"created_at":"2024-11-29T14:43:10.975Z","updated_at":"2025-03-22T22:44:08.300Z","avatar_url":"https://github.com/kingluo.png","language":"C++","readme":"# ngx_lua_block_check\n\nThis tool is used to find out long running coroutine resume,\nwhich means CPU intensive computations and/or blocking on system calls (e.g. disk read/write, os.execute).\n\nLong resume would cause many issues, e.g. cosocket timeout.\n\n**Just like systemtap, this tool do not touch openresty source codes, and it is NOT nginx module too!**\n\n**It just hooks `lua_resume()` via LD_PRELOAD to do the check.**\n\n## Why not systemtap?\n\n* systemtap would impact the runtime performance more or less, but this tool would not.\n* it seems hard to obtain infomations inside `lua_State` via systemtap.\n\n## Compile\n\n```\n# build ngx_lua_block_check.so\nmake\n```\n\n## Configure nginx.conf\n\n```\n# enabled or not\nenv NGX_LUA_BLOCK_CHECK=true;\n# log threshold, in ms\nenv NGX_LUA_BLOCK_CHECK_MIN_MS=10;\n# log file prefix\nenv NGX_LUA_BLOCK_CHECK_OUTPUT_FILE=/tmp/ngx_lua_block_check.log;\n```\n\nif you change configs, you could reload the nginx to take effect.\n\n## Restart openresty (only once)\n\n```\n/usr/local/openresty/bin/openresty -s stop\nLD_PRELOAD=./ngx_lua_block_check.so /usr/local/openresty/bin/openresty\n```\n\n## Check the log file\n\n```\ntail -f /tmp/ngx_lua_block_check.log*\n```\n\n```\n==\u003e /tmp/ngx_lua_block_check.log.2282 \u003c==\n2017-08-20 23:56:44.424166 30ms /test (null),content_by_lua(nginx.conf:56),1 test,/usr/local/openresty/lualib/test.lua,7 yield\n\n==\u003e /tmp/ngx_lua_block_check.log.2287 \u003c==\n2017-08-20 23:56:54.556875 10ms /test (null),content_by_lua(nginx.conf:56),1 test,/usr/local/openresty/lualib/test.lua,7 yield\n```\n\nThe log files are suffix by worker process pid.\n\n## Log format\n\n```\n\u003cresume begin timestamp\u003e \u003cresume duration\u003e \u003curl\u003e \u003cfunc1,src1,lineno1\u003e \u003cfunc2,src2,lineno2\u003e \u003cresume status\u003e\n```\n\nHere the `func1` is the resume entry function, while the `func2` is the resume exit function.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkingluo%2Fngx_lua_block_check","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkingluo%2Fngx_lua_block_check","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkingluo%2Fngx_lua_block_check/lists"}