Module: kamailio
Branch: master
Commit: b72996c7b1ad95b89f1b34e849c713bfe3fb50a9
URL:
https://github.com/kamailio/kamailio/commit/b72996c7b1ad95b89f1b34e849c713b…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2019-03-08T20:51:29+01:00
app_lua: execution log message based on core latency_limit_action
---
Modified: src/modules/app_lua/app_lua_sr.c
---
Diff:
https://github.com/kamailio/kamailio/commit/b72996c7b1ad95b89f1b34e849c713b…
Patch:
https://github.com/kamailio/kamailio/commit/b72996c7b1ad95b89f1b34e849c713b…
---
diff --git a/src/modules/app_lua/app_lua_sr.c b/src/modules/app_lua/app_lua_sr.c
index 6119aefa46..ee655c3e54 100644
--- a/src/modules/app_lua/app_lua_sr.c
+++ b/src/modules/app_lua/app_lua_sr.c
@@ -1931,9 +1931,33 @@ int sr_kemi_exec_func(lua_State* L, str *mname, int midx, str
*fname)
int sr_kemi_lua_exec_func(lua_State* L, int eidx)
{
sr_kemi_t *ket;
+ int ret;
+ unsigned int ms = 0;
+ lua_Debug dinfo;
ket = sr_kemi_lua_export_get(eidx);
- return sr_kemi_lua_exec_func_ex(L, ket, 0);
+ if(unlikely(cfg_get(core, core_cfg, latency_limit_action)>0)) {
+ ms = TICKS_TO_MS(get_ticks_raw());
+ }
+
+ ret = sr_kemi_lua_exec_func_ex(L, ket, 0);
+
+ if(unlikely(cfg_get(core, core_cfg, latency_limit_action)>0)) {
+ ms = TICKS_TO_MS(get_ticks_raw()) - ms;
+ if(ms >= cfg_get(core, core_cfg, latency_limit_action)
+ && is_printable(cfg_get(core, core_cfg, latency_log))) {
+ lua_getinfo(L, "nSl", &dinfo);
+ LOG(cfg_get(core, core_cfg, latency_log),
+ "alert - action KSR.%s%s%s(...)"
+ " took too long [%u ms] (%s:%d - %s [%s])\n",
+ (ket->mname.len>0)?ket->mname.s:"",
+ (ket->mname.len>0)?".":"", ket->fname.s, ms,
+ dinfo.short_src, dinfo.currentline,
+ (dinfo.name?dinfo.name:"<unknown>"), dinfo.what);
+ }
+ }
+
+ return ret;
}
/**