[sr-dev] git:master:639db054: app_sqlang: execution log message based on core latency_limit_action

Daniel-Constantin Mierla miconda at gmail.com
Fri Apr 5 08:57:01 CEST 2019


Module: kamailio
Branch: master
Commit: 639db054d0d2e8b0bb50c9109750419654dedbe1
URL: https://github.com/kamailio/kamailio/commit/639db054d0d2e8b0bb50c9109750419654dedbe1

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2019-04-05T08:56:42+02:00

app_sqlang: execution log message based on core latency_limit_action

---

Modified: src/modules/app_sqlang/app_sqlang_api.c

---

Diff:  https://github.com/kamailio/kamailio/commit/639db054d0d2e8b0bb50c9109750419654dedbe1.diff
Patch: https://github.com/kamailio/kamailio/commit/639db054d0d2e8b0bb50c9109750419654dedbe1.patch

---

diff --git a/src/modules/app_sqlang/app_sqlang_api.c b/src/modules/app_sqlang/app_sqlang_api.c
index 79465940fd..0e878fa99a 100644
--- a/src/modules/app_sqlang/app_sqlang_api.c
+++ b/src/modules/app_sqlang/app_sqlang_api.c
@@ -1457,9 +1457,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