From 795bacbaa1900127cd5e94847c4be401ab86966e Mon Sep 17 00:00:00 2001 From: "Olle E. Johansson" Date: Tue, 24 Feb 2015 22:03:53 +0100 Subject: [PATCH 1/2] uac Add counters for uac_reg --- modules/uac/uac_reg.c | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/modules/uac/uac_reg.c b/modules/uac/uac_reg.c index f0829fec074..fdcc92ef697 100644 --- a/modules/uac/uac_reg.c +++ b/modules/uac/uac_reg.c @@ -116,6 +116,7 @@ str auth_password_column = str_init("auth_password"); str auth_proxy_column = str_init("auth_proxy"); str expires_column = str_init("expires"); + #if 0 INSERT INTO version (table_name, table_version) values ('uacreg','1'); CREATE TABLE uacreg ( @@ -140,9 +141,22 @@ extern pv_spec_t auth_username_spec; extern pv_spec_t auth_realm_spec; extern pv_spec_t auth_password_spec; +counter_handle_t regtotal; /* Total number of registrations in memory */ +counter_handle_t regactive; /* Active registrations - 200 OK */ +counter_handle_t regdisabled; /* Disabled registrations */ + +/* Init counters */ +static void uac_reg_counter_init() +{ + LM_DBG("*** Initializing UAC reg counters\n"); + counter_register(®total, "uac", "regtotal", 0, 0, 0, "Total number of registration accounts in memory", 0); + counter_register(®active, "uac", "regactive", 0, 0, 0, "Number of successfully registred accounts (200 OK)", 0); + counter_register(®disabled, "uac", "regdisabled", 0, 0, 0, "Counter of failed registrations (not 200 OK)", 0); +} + /** - * + * Init the in-memory registration database in hash table */ int uac_reg_init_ht(unsigned int sz) { @@ -231,6 +245,9 @@ int uac_reg_init_ht(unsigned int sz) } } + /* Initialize uac reg counters */ + uac_reg_counter_init(); + return 0; } @@ -343,6 +360,10 @@ int uac_reg_reset_ht_gc(void) _reg_htable_gc->entries[i].byuser = NULL; _reg_htable_gc->entries[i].usize = 0; } + /* Reset all counters */ + counter_reset(regtotal); + counter_reset(regactive); + counter_reset(regdisabled); return 0; } @@ -364,7 +385,7 @@ int uac_reg_ht_shift(void) lock_get(_reg_htable_gc_lock); if(_reg_htable_gc->stime > tn-UAC_REG_GC_INTERVAL) { lock_release(_reg_htable_gc_lock); - LM_ERR("shifting the memory table is not possible in less than %d\n", UAC_REG_GC_INTERVAL); + LM_ERR("shifting the memory table is not possible in less than %d secs\n", UAC_REG_GC_INTERVAL); return -1; } uac_reg_reset_ht_gc(); @@ -516,6 +537,7 @@ int reg_ht_add(reg_uac_t *reg) reg_ht_add_byuser(nr); reg_ht_add_byuuid(nr); + counter_inc(regtotal); return 0; } @@ -876,14 +898,17 @@ void uac_reg_tm_callback( struct cell *t, int type, struct tmcb_params *ps) } error: - if(reg_retry_interval) + if(reg_retry_interval) { ri->timer_expires = time(NULL) + reg_retry_interval; - else + } else { ri->flags |= UAC_REG_DISABLED; + counter_inc(regdisabled); + } done: if(ri) ri->flags &= ~(UAC_REG_ONGOING|UAC_REG_AUTHSENT); shm_free(uuid); + counter_inc(regactive); } int uac_reg_update(reg_uac_t *reg, time_t tn) @@ -912,6 +937,7 @@ int uac_reg_update(reg_uac_t *reg, time_t tn) reg->timer_expires = tn; reg->flags |= UAC_REG_ONGOING; reg->flags &= ~UAC_REG_ONLINE; + counter_add(regactive, -1); /* Take it out of the active pool while re-registering */ uuid = (char*)shm_malloc(reg->l_uuid.len+1); if(uuid==NULL) { @@ -959,8 +985,10 @@ int uac_reg_update(reg_uac_t *reg, time_t tn) shm_free(uuid); if (reg_retry_interval) reg->timer_expires = (tn ? tn : time(NULL)) + reg_retry_interval; - else + else { reg->flags |= UAC_REG_DISABLED; + counter_inc(regdisabled); + } reg->flags &= ~UAC_REG_ONGOING; return -1; } @@ -1655,6 +1683,7 @@ static const char* rpc_uac_reg_enable_doc[2] = { static void rpc_uac_reg_enable(rpc_t* rpc, void* ctx) { rpc_uac_reg_update_flag(rpc, ctx, 0, UAC_REG_DISABLED); + counter_add(regdisabled, -1); } static const char* rpc_uac_reg_disable_doc[2] = { @@ -1665,6 +1694,7 @@ static const char* rpc_uac_reg_disable_doc[2] = { static void rpc_uac_reg_disable(rpc_t* rpc, void* ctx) { rpc_uac_reg_update_flag(rpc, ctx, 1, UAC_REG_DISABLED); + counter_inc(regdisabled); } static const char* rpc_uac_reg_reload_doc[2] = { From 18e250f15b02e3ea30ecc037f758e8d16be14969 Mon Sep 17 00:00:00 2001 From: "Olle E. Johansson" Date: Mon, 16 Mar 2015 19:37:17 +0100 Subject: [PATCH 2/2] Update documentation --- modules/uac/README | 70 ++++++++++++++++++++--------------- modules/uac/doc/uac_admin.xml | 14 +++++++ 2 files changed, 54 insertions(+), 30 deletions(-) diff --git a/modules/uac/README b/modules/uac/README index 79070c0e1c6..f139221e626 100644 --- a/modules/uac/README +++ b/modules/uac/README @@ -62,16 +62,17 @@ Ramona-Elena Modroiu 4.10. uac_reg_request_to(user, mode) 5. Pseudo Variables - 6. RPC Commands + 6. Counters + 7. RPC Commands - 6.1. uac.reg_dump - 6.2. uac.reg_info - 6.3. uac.reg_enable - 6.4. uac.reg_disable - 6.5. uac.reg_reload - 6.6. uac.reg_refresh + 7.1. uac.reg_dump + 7.2. uac.reg_info + 7.3. uac.reg_enable + 7.4. uac.reg_disable + 7.5. uac.reg_reload + 7.6. uac.reg_refresh - 7. Remote Registration + 8. Remote Registration List of Examples @@ -152,16 +153,17 @@ Chapter 1. Admin Guide 4.10. uac_reg_request_to(user, mode) 5. Pseudo Variables - 6. RPC Commands + 6. Counters + 7. RPC Commands - 6.1. uac.reg_dump - 6.2. uac.reg_info - 6.3. uac.reg_enable - 6.4. uac.reg_disable - 6.5. uac.reg_reload - 6.6. uac.reg_refresh + 7.1. uac.reg_dump + 7.2. uac.reg_info + 7.3. uac.reg_enable + 7.4. uac.reg_disable + 7.5. uac.reg_reload + 7.6. uac.reg_refresh - 7. Remote Registration + 8. Remote Registration 1. Overview @@ -689,16 +691,24 @@ failure_route[REMOTE_AUTH] { Exported pseudo-variables are documented at http://www.kamailio.org/wiki/. -6. RPC Commands +6. Counters - 6.1. uac.reg_dump - 6.2. uac.reg_info - 6.3. uac.reg_enable - 6.4. uac.reg_disable - 6.5. uac.reg_reload - 6.6. uac.reg_refresh + * regtotal: Total number of registrations + * regactive: Total number of active registrations (successfully + registred with service) + * regdisabled: Total number of disabled registrations (no longer + active) -6.1. uac.reg_dump +7. RPC Commands + + 7.1. uac.reg_dump + 7.2. uac.reg_info + 7.3. uac.reg_enable + 7.4. uac.reg_disable + 7.5. uac.reg_reload + 7.6. uac.reg_refresh + +7.1. uac.reg_dump Dump the content of remote registration table from memory. @@ -707,7 +717,7 @@ failure_route[REMOTE_AUTH] { kamcmd uac.reg_dump ... -6.2. uac.reg_info +7.2. uac.reg_info Return the details of a remote registration record based on a filter. The command has two parameter: attribute and value. The attribute can @@ -720,7 +730,7 @@ failure_route[REMOTE_AUTH] { kamcmd uac.reg_info l_uuid account123 ... -6.3. uac.reg_enable +7.3. uac.reg_enable Enable a remote registration record based on a filter. The command has two parameter: attribute and value. The attribute can be: l_uuid, @@ -733,7 +743,7 @@ failure_route[REMOTE_AUTH] { kamcmd uac.reg_enable l_uuid account123 ... -6.4. uac.reg_disable +7.4. uac.reg_disable Disable a remote registration record based on a filter. The command has two parameter: attribute and value. The attribute can be: l_uuid, @@ -746,7 +756,7 @@ failure_route[REMOTE_AUTH] { kamcmd uac.reg_disable l_uuid account123 ... -6.5. uac.reg_reload +7.5. uac.reg_reload Reload the records from database for remote registrations. @@ -755,7 +765,7 @@ failure_route[REMOTE_AUTH] { kamcmd uac.reg_reload ... -6.6. uac.reg_refresh +7.6. uac.reg_refresh Load one record by l_uuid from database for remote registrations. If the record exists in memory, its authentication password is updated, @@ -767,7 +777,7 @@ failure_route[REMOTE_AUTH] { kamcmd uac.reg_refresh account123 ... -7. Remote Registration +8. Remote Registration The module can register contact addresses to remote REGISTRAR servers. You have to add records to uacreg table. The table stores following diff --git a/modules/uac/doc/uac_admin.xml b/modules/uac/doc/uac_admin.xml index f4c5580b743..5bd7c9d2785 100644 --- a/modules/uac/doc/uac_admin.xml +++ b/modules/uac/doc/uac_admin.xml @@ -796,6 +796,20 @@ failure_route[REMOTE_AUTH] { Exported pseudo-variables are documented at &kamwikilink;. +
+ Counters + + + regtotal: Total number of registrations + + + regactive: Total number of active registrations (successfully registred with service) + + + regdisabled: Total number of disabled registrations (no longer active) + + +
RPC Commands