Module: kamailio
Branch: 4.4
Commit: 3a32d65bbe103ea0caae418b946168ce774948c5
URL:
https://github.com/kamailio/kamailio/commit/3a32d65bbe103ea0caae418b946168c…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2016-10-10T12:12:04+02:00
counters: fixed rpc command to get counter by group and name
(cherry picked from commit f8e47835950fa472ef313b7f303b0989b76f9dbe)
---
Modified: modules/counters/counters.c
---
Diff:
https://github.com/kamailio/kamailio/commit/3a32d65bbe103ea0caae418b946168c…
Patch:
https://github.com/kamailio/kamailio/commit/3a32d65bbe103ea0caae418b946168c…
---
diff --git a/modules/counters/counters.c b/modules/counters/counters.c
index d90ead1..5fd8739 100644
--- a/modules/counters/counters.c
+++ b/modules/counters/counters.c
@@ -24,9 +24,9 @@
/*!
* \defgroup counters Counters/statistics
- *
+ *
*/
-
+
#include "../../modparam.h"
#include "../../dprint.h"
#include "../../compiler_opt.h"
@@ -239,7 +239,7 @@ static int cnt_int_fixup(void** param, int param_no)
static int cnt_inc_f(struct sip_msg* msg, char* handle, char* bar)
{
counter_handle_t h;
-
+
h.id = (long)(void*)handle;
counter_inc(h);
return 1;
@@ -251,7 +251,7 @@ static int cnt_add_f(struct sip_msg* msg, char* handle, char* val)
{
counter_handle_t h;
int v;
-
+
h.id = (long)(void*)handle;
if (unlikely(get_int_fparam(&v, msg, (fparam_t*)val) < 0)) {
ERR("non integer parameter\n");
@@ -266,7 +266,7 @@ static int cnt_add_f(struct sip_msg* msg, char* handle, char* val)
static int cnt_reset_f(struct sip_msg* msg, char* handle, char* bar)
{
counter_handle_t h;
-
+
h.id = (long)(void*)handle;
counter_reset(h);
return 1;
@@ -284,12 +284,13 @@ static void cnt_get_rpc(rpc_t* rpc, void* c)
char* name;
counter_val_t v;
counter_handle_t h;
-
+
if (rpc->scan(c, "s", &group) < 1)
return;
- if (rpc->scan(c, "*s", &name) < 1)
+ if (rpc->scan(c, "*s", &name) < 1) {
cnt_grp_get_all(rpc, c, group);
return;
+ }
/* group & name read */
if (counter_lookup(&h, group, name) < 0) {
rpc->fault(c, 400, "non-existent counter %s.%s\n", group, name);
@@ -308,7 +309,7 @@ static void cnt_get_raw_rpc(rpc_t* rpc, void* c)
char* name;
counter_val_t v;
counter_handle_t h;
-
+
if (rpc->scan(c, "ss", &group, &name) < 2) {
/* rpc->fault(c, 400, "group and counter name required"); */
return;
@@ -329,7 +330,7 @@ static void cnt_reset_rpc(rpc_t* rpc, void* c)
char* group;
char* name;
counter_handle_t h;
-
+
if (rpc->scan(c, "ss", &group, &name) < 2) {
/* rpc->fault(c, 400, "group and counter name required"); */
return;
@@ -383,7 +384,7 @@ static void rpc_print_name_val(void* param, str* g, str* n,
static void cnt_grps_list_rpc(rpc_t* rpc, void* c)
{
struct rpc_list_params packed_params;
-
+
packed_params.rpc = rpc;
packed_params.ctx = c;
counter_iterate_grp_names(rpc_print_name, &packed_params);
@@ -395,7 +396,7 @@ static void cnt_var_list_rpc(rpc_t* rpc, void* c)
{
char* group;
struct rpc_list_params packed_params;
-
+
if (rpc->scan(c, "s", &group) < 1) {
/* rpc->fault(c, 400, "group name required"); */
return;
@@ -411,7 +412,7 @@ static void cnt_grp_get_all(rpc_t* rpc, void* c, char* group)
{
void* s;
struct rpc_list_params packed_params;
-
+
if (rpc->add(c, "{", &s) < 0) return;
packed_params.rpc = rpc;
packed_params.ctx = s;
@@ -423,7 +424,7 @@ static void cnt_grp_get_all(rpc_t* rpc, void* c, char* group)
static void cnt_grp_get_all_rpc(rpc_t* rpc, void* c)
{
char* group;
-
+
if (rpc->scan(c, "s", &group) < 1) {
/* rpc->fault(c, 400, "group name required"); */
return;
@@ -439,7 +440,7 @@ static void cnt_help_rpc(rpc_t* rpc, void* ctx)
char* name;
char* desc;
counter_handle_t h;
-
+
if (rpc->scan(ctx, "ss", &group, &name) < 2) {
/* rpc->fault(c, 400, "group and counter name required"); */
return;