From aad6deeb7814b4f53e366261f92444b5bc8d1983 Mon Sep 17 00:00:00 2001 From: midoks Date: Sat, 15 Oct 2022 23:28:36 +0800 Subject: [PATCH] Update init_worker.lua --- plugins/op_waf/waf/lua/init_worker.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/op_waf/waf/lua/init_worker.lua b/plugins/op_waf/waf/lua/init_worker.lua index bc82cd31e..39fb7f248 100644 --- a/plugins/op_waf/waf/lua/init_worker.lua +++ b/plugins/op_waf/waf/lua/init_worker.lua @@ -14,10 +14,13 @@ end ngx.shared.waf_limit:set("cpu_usage", 0, 10) - function timer_every_get_cpu(premature) - cpu_percent = 80 - ngx.shared.waf_limit:set("cpu_usage", cpu_percent, 10) + local cpu_percent = C:read_file_body(waf_root.."/cpu.info") + if cpu_percent then + ngx.shared.waf_limit:set("cpu_usage", cpu_percent, 10) + else + ngx.shared.waf_limit:set("cpu_usage", 0, 10) + end end if 0 == ngx.worker.id() then