HiFigured out this means creating a route in the config file that is triggered when this happens. Good idea, I'll work on putting this in.
Regards
Richard.
On 12 January 2015 at 18:11, Richard Good <richard.good@smilecoms.com> wrote:HiPlease can you elaborate more on what you mean by a script callback via dedicated route - or point me towards somewhere in kamailio where this is already used so I can re-use it.
Sounds like a good idea.
Regards
Richard Good Senior Manager: Applications & Services Smile Communications Pty (Ltd)
Mobile: +27 (0) 72 389 8365 Skype: richard.a.good richard.good@smilecoms.com www.smilecoms.com
On 12 January 2015 at 16:00, Ovidiu Sas <osas@voipembedded.com> wrote:In addition to the warning, it would be nice to run a script callback via a dedicated route, to let the admin take some decisions in real time.
Regards,
Ovidiu SasOn Jan 12, 2015 8:16 AM, "Richard Good" <richard.good@smilecoms.com> wrote:Module: kamailio
Branch: master
Commit: e688d656427dd00d48f1e309c5d8ef991e432b67
URL: https://github.com/kamailio/kamailio/commit/e688d656427dd00d48f1e309c5d8ef991e432b67
Author: Richard Good <richard.good@smilecoms.com>
Committer: Richard Good <richard.good@smilecoms.com>
Date: 2015-01-12T15:08:08+02:00
modules/cdp: new mod param: workerq_length_threshold_percentage
This is the threshold of the length of the worker queue as a percentage of
the maximum queue size - when exceeded a warning is written to the log
file. Nice to check if worker queue is growing.
---
Modified: modules/cdp/doc/cdp_admin.xml
Modified: modules/cdp/mod.c
Modified: modules/cdp/worker.c
---
Diff: https://github.com/kamailio/kamailio/commit/e688d656427dd00d48f1e309c5d8ef991e432b67.diff
Patch: https://github.com/kamailio/kamailio/commit/e688d656427dd00d48f1e309c5d8ef991e432b67.patch
---
diff --git a/modules/cdp/doc/cdp_admin.xml b/modules/cdp/doc/cdp_admin.xml
index cdf65d2..234e270 100644
--- a/modules/cdp/doc/cdp_admin.xml
+++ b/modules/cdp/doc/cdp_admin.xml
@@ -126,6 +126,24 @@ modparam("cdp", "latency_threshold", 1000)
</programlisting>
</example>
</section>
+ <section>
+ <title>workerq_length_threshold_percentage (int)</title>
+
+ <para>The threshold of the length of the worker queue as a percentage of
+ the maximum queue size - when exceeded a warning is written to the log
+ file. 0 means disabled</para>
+
+ <para><emphasis> Default value is <quote>0</quote>. </emphasis></para>
+
+ <example>
+ <title>Set <varname>workerq_length_threshold_percentage</varname> parameter</title>
+
+ <programlisting format="linespecific">...
+modparam("cdp", "workerq_length_threshold_percentage", 25)
+...
+ </programlisting>
+ </example>
+ </section>
</section>
<section>
diff --git a/modules/cdp/mod.c b/modules/cdp/mod.c
index 6857d82..90900d3 100644
--- a/modules/cdp/mod.c
+++ b/modules/cdp/mod.c
@@ -62,6 +62,7 @@ char* config_file="DiameterPeer.xml"; /**< default DiameterPeer configuration f
unsigned int latency_threshold = 500; /**< default threshold for Diameter calls (ms) */
unsigned int *latency_threshold_p = &latency_threshold;
unsigned int workerq_latency_threshold = 100; /**< default threshold for putting a task into worker queue (ms) */
+unsigned int workerq_length_threshold_percentage = 0; /**< default threshold for worker queue length, percentage of max queue length - by default disabled */
extern dp_config *config; /**< DiameterPeer configuration structure */
@@ -165,6 +166,7 @@ static param_export_t cdp_params[] = {
{ "config_file", PARAM_STRING, &config_file}, /**< configuration filename */
{ "latency_threshold", PARAM_INT, &latency_threshold}, /**<threshold above which we will log*/
{ "workerq_latency_threshold", PARAM_INT, &workerq_latency_threshold},/**<time threshold putting job into queue*/
+ { "workerq_length_threshold_percentage", PARAM_INT, &workerq_length_threshold_percentage},/**<queue length threshold - percentage of max queue length*/
{ 0, 0, 0 }
};
@@ -215,7 +217,7 @@ static int cdp_init( void )
LM_ERR("failed to register stat\n");
return -1;
}
-
+
if (register_module_stats( exports.name, mod_stats)!=0 ) {
LM_ERR("failed to register core statistics\n");
return -1;
diff --git a/modules/cdp/worker.c b/modules/cdp/worker.c
index 5ab215c..4a45bc4 100644
--- a/modules/cdp/worker.c
+++ b/modules/cdp/worker.c
@@ -70,6 +70,7 @@ task_queue_t *tasks; /**< queue of tasks */
cdp_cb_list_t *callbacks; /**< list of callbacks for message processing */
extern unsigned int workerq_latency_threshold; /**<max delay for putting task into worker queue */
+extern unsigned int workerq_length_threshold_percentage; /**< default threshold for worker queue length, percentage of max queue length */
/**
* Initializes the worker structures, like the task queue.
*/
@@ -207,6 +208,8 @@ void cb_remove(cdp_cb_t *cb) {
int put_task(peer *p, AAAMessage *msg) {
struct timeval start, stop;
+ int num_tasks, length_percentage;
+
long elapsed_useconds=0, elapsed_seconds=0, elapsed_millis=0;
lock_get(tasks->lock);
@@ -246,6 +249,13 @@ int put_task(peer *p, AAAMessage *msg) {
LM_WARN("Error releasing tasks->empty semaphore > %s!\n", strerror(errno));
lock_release(tasks->lock);
+ if(workerq_length_threshold_percentage > 0) {
+ num_tasks = tasks->end - tasks->start;
+ length_percentage = num_tasks/tasks->max*100;
+ if(length_percentage > workerq_length_threshold_percentage) {
+ LM_WARN("Queue length has exceeded length threshold percentage [%i] and is length [%i]", length_percentage, num_tasks);
+ }
+ }
//int num_tasks = tasks->end - tasks->start;
//LM_ERR("Added task to task queue. Queue length [%i]", num_tasks);
_______________________________________________
sr-dev mailing list
sr-dev@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
_______________________________________________
sr-dev mailing list
sr-dev@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
This email is subject to the disclaimer of Smile Communications at http://www.smilecoms.com/home/email-disclaimer/
_______________________________________________
sr-dev mailing list
sr-dev@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev