[sr-dev] git:5.2:1becba8e: app_sqlang: execution log message based on core latency_limit_action
Daniel-Constantin Mierla
miconda at gmail.com
Wed Apr 10 10:52:54 CEST 2019
Module: kamailio
Branch: 5.2
Commit: 1becba8ef4b901f3fd67842711b079e8011beb2e
URL: https://github.com/kamailio/kamailio/commit/1becba8ef4b901f3fd67842711b079e8011beb2e
Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2019-04-10T10:48:28+02:00
app_sqlang: execution log message based on core latency_limit_action
(cherry picked from commit 639db054d0d2e8b0bb50c9109750419654dedbe1)
---
Modified: src/modules/app_sqlang/app_sqlang_api.c
---
Diff: https://github.com/kamailio/kamailio/commit/1becba8ef4b901f3fd67842711b079e8011beb2e.diff
Patch: https://github.com/kamailio/kamailio/commit/1becba8ef4b901f3fd67842711b079e8011beb2e.patch
---
diff --git a/src/modules/app_sqlang/app_sqlang_api.c b/src/modules/app_sqlang/app_sqlang_api.c
index 302e78a3b3..b23f8dad61 100644
--- a/src/modules/app_sqlang/app_sqlang_api.c
+++ b/src/modules/app_sqlang/app_sqlang_api.c
@@ -1448,9 +1448,36 @@ int sr_kemi_sqlang_exec_func_ex(HSQUIRRELVM J, sr_kemi_t *ket)
int sr_kemi_sqlang_exec_func(HSQUIRRELVM J, int eidx)
{
sr_kemi_t *ket;
+ int ret;
+ struct timeval tvb, tve;
+ struct timezone tz;
+ unsigned int tdiff;
ket = sr_kemi_sqlang_export_get(eidx);
- return sr_kemi_sqlang_exec_func_ex(J, ket);
+
+ if(unlikely(cfg_get(core, core_cfg, latency_limit_action)>0)
+ && is_printable(cfg_get(core, core_cfg, latency_log))) {
+ gettimeofday(&tvb, &tz);
+ }
+
+ ret = sr_kemi_sqlang_exec_func_ex(J, ket);
+
+ if(unlikely(cfg_get(core, core_cfg, latency_limit_action)>0)
+ && is_printable(cfg_get(core, core_cfg, latency_log))) {
+ gettimeofday(&tve, &tz);
+ tdiff = (tve.tv_sec - tvb.tv_sec) * 1000000
+ + (tve.tv_usec - tvb.tv_usec);
+ if(tdiff >= cfg_get(core, core_cfg, latency_limit_action)) {
+ LOG(cfg_get(core, core_cfg, latency_log),
+ "alert - action KSR.%s%s%s(...)"
+ " took too long [%u us]\n",
+ (ket->mname.len>0)?ket->mname.s:"",
+ (ket->mname.len>0)?".":"", ket->fname.s,
+ tdiff);
+ }
+ }
+
+ return ret;
}
/**
More information about the sr-dev
mailing list