Module: sip-router
Branch: andrei/counters
Commit: ec3aca49a087e796a6324345346c05bf00b879f6
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=ec3aca4…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Wed Aug 11 01:27:46 2010 +0200
counters: 2nd parameter of cnt.get rpc is now optional
If the counter name is missing cnt.get will display the whole
group (equivalent to cnt.grp_get_all).
E.g.:
$ sercmd cnt.get tcp
{
con_reset: 0
con_timeout: 0
connect_failed: 0
connect_success: 0
current_opened_connections: 0
current_write_queue_size: 0
established: 0
local_reject: 0
passive_open: 0
send_timeout: 0
sendq_full: 0
}
$ sercmd cnt.get tcp current_opened_connections
0
---
modules/counters/counters.c | 31 ++++++++++++++++++++++---------
1 files changed, 22 insertions(+), 9 deletions(-)
diff --git a/modules/counters/counters.c b/modules/counters/counters.c
index 1755308..16da3c9 100644
--- a/modules/counters/counters.c
+++ b/modules/counters/counters.c
@@ -273,6 +273,10 @@ static int cnt_reset_f(struct sip_msg* msg, char* handle, char* bar)
+static void cnt_grp_get_all(rpc_t* rpc, void* c, char* group);
+
+
+
static void cnt_get_rpc(rpc_t* rpc, void* c)
{
char* group;
@@ -280,10 +284,11 @@ static void cnt_get_rpc(rpc_t* rpc, void* c)
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"); */
+ if (rpc->scan(c, "s", &group) < 1)
return;
- }
+ if (rpc->scan(c, "*s", &name) < 1)
+ return cnt_grp_get_all(rpc, c, group);
+ /* group & name read */
if (counter_lookup(&h, group, name) < 0) {
rpc->fault(c, 400, "non-existent counter %s.%s\n", group, name);
return;
@@ -400,16 +405,11 @@ static void cnt_var_list_rpc(rpc_t* rpc, void* c)
-static void cnt_grp_get_all_rpc(rpc_t* rpc, void* c)
+static void cnt_grp_get_all(rpc_t* rpc, void* c, char* group)
{
void* s;
- char* group;
struct rpc_list_params packed_params;
- if (rpc->scan(c, "s", &group) < 1) {
- /* rpc->fault(c, 400, "group name required"); */
- return;
- }
if (rpc->add(c, "{", &s) < 0) return;
packed_params.rpc = rpc;
packed_params.ctx = s;
@@ -418,6 +418,19 @@ static void cnt_grp_get_all_rpc(rpc_t* rpc, void* c)
+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;
+ }
+ return cnt_grp_get_all(rpc, c, group);
+}
+
+
+
static void cnt_help_rpc(rpc_t* rpc, void* ctx)
{
char* group;