Module: kamailio
Branch: master
Commit: 7da783ac03329f4934d36c9a574bb2cd44019688
URL:
https://github.com/kamailio/kamailio/commit/7da783ac03329f4934d36c9a574bb2c…
Author: Jason Penton <jason.penton(a)gmail.com>
Committer: Jason Penton <jason.penton(a)gmail.com>
Date: 2015-02-06T00:27:07+02:00
modules/cdp: added new counter(stat) for worker queuelenght
- this will give an indication that workers are not
keeping up with load if it gets too big
---
Modified: modules/cdp/cdp_stats.c
Modified: modules/cdp/cdp_stats.h
Modified: modules/cdp/worker.c
---
Diff:
https://github.com/kamailio/kamailio/commit/7da783ac03329f4934d36c9a574bb2c…
Patch:
https://github.com/kamailio/kamailio/commit/7da783ac03329f4934d36c9a574bb2c…
---
diff --git a/modules/cdp/cdp_stats.c b/modules/cdp/cdp_stats.c
index 6e2985d..37087bc 100644
--- a/modules/cdp/cdp_stats.c
+++ b/modules/cdp/cdp_stats.c
@@ -12,6 +12,8 @@ counter_def_t cdp_cnt_defs[] = {
"total number of replies received"},
{&cdp_cnts_h.replies_response_time, "replies_response_time", 0, 0, 0,
"total time waiting for replies"},
+ {&cdp_cnts_h.queuelength, "queuelength", 0, 0, 0,
+ "current length of worker queue tasks"},
{0, "average_response_time", 0,
cdp_internal_stats, (void*) (long) CDP_AVG_RSP,
"average response time for CDP replies"},
diff --git a/modules/cdp/cdp_stats.h b/modules/cdp/cdp_stats.h
index e6747fe..f85f17a 100644
--- a/modules/cdp/cdp_stats.h
+++ b/modules/cdp/cdp_stats.h
@@ -8,8 +8,11 @@ struct cdp_counters_h {
counter_handle_t replies_received;
counter_handle_t replies_response_time;
counter_handle_t avg_response_time;
+ counter_handle_t queuelength;
};
-#endif /* CDP_STATS_H */
int cdp_init_counters();
-void cdp_destroy_counters();
\ No newline at end of file
+void cdp_destroy_counters();
+
+#endif /* CDP_STATS_H */
+
diff --git a/modules/cdp/worker.c b/modules/cdp/worker.c
index 4a45bc4..cc1617d 100644
--- a/modules/cdp/worker.c
+++ b/modules/cdp/worker.c
@@ -58,12 +58,14 @@
#include "diameter_api.h"
#include "../../cfg/cfg_struct.h"
+#include "cdp_stats.h"
/* defined in ../diameter_peer.c */
int dp_add_pid(pid_t pid);
void dp_del_pid(pid_t pid);
extern dp_config *config; /**< Configuration for this diameter peer */
+extern struct cdp_counters_h cdp_cnts_h;
task_queue_t *tasks; /**< queue of tasks */
@@ -231,6 +233,8 @@ int put_task(peer *p, AAAMessage *msg) {
lock_get(tasks->lock);
}
+
+ counter_inc(cdp_cnts_h.queuelength);
gettimeofday(&stop, NULL);
elapsed_useconds = stop.tv_usec - start.tv_usec;
@@ -250,7 +254,7 @@ int put_task(peer *p, AAAMessage *msg) {
lock_release(tasks->lock);
if(workerq_length_threshold_percentage > 0) {
- num_tasks = tasks->end - tasks->start;
+ 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);
@@ -286,6 +290,7 @@ task_t take_task() {
lock_get(tasks->lock);
}
+ counter_add(cdp_cnts_h.queuelength, -1);
t = tasks->queue[tasks->start];
tasks->queue[tasks->start].msg = 0;
tasks->start = (tasks->start + 1) % tasks->max;