This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
osmith gerrit-no-reply at lists.osmocom.orgosmith has uploaded this change for review. ( https://gerrit.osmocom.org/11199
Change subject: Add rate counters for call handling
......................................................................
Add rate counters for call handling
This creates rate counters for:
* Initiated calls
* Failed calls
* Connected calls
* Released calls
Related: OS#1697
Change-Id: I6d7963266a93be631a4e0e03a39916d07a88fe01
---
A src/ctr.h
M src/main.c
M src/sip.c
M src/sip.h
4 files changed, 61 insertions(+), 11 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-sip-connector refs/changes/99/11199/1
diff --git a/src/ctr.h b/src/ctr.h
new file mode 100644
index 0000000..b3460de
--- /dev/null
+++ b/src/ctr.h
@@ -0,0 +1,25 @@
+#pragma once
+#include <osmocom/core/rate_ctr.h>
+#include <osmocom/core/stats.h>
+
+enum {
+ SIP_CTR_CALL_INITIATED,
+ SIP_CTR_CALL_FAILED,
+ SIP_CTR_CALL_CONNECTED,
+ SIP_CTR_CALL_RELEASED,
+};
+
+static const struct rate_ctr_desc sip_ctr_description[] = {
+ [SIP_CTR_CALL_INITIATED] = {"call:initiated", "Call(s) initiated."},
+ [SIP_CTR_CALL_FAILED] = {"call:failed", "Call(s) failed."},
+ [SIP_CTR_CALL_CONNECTED] = {"call:connected", "Call(s) connected."},
+ [SIP_CTR_CALL_RELEASED] = {"call:released", "Call(s) released."},
+};
+
+static const struct rate_ctr_group_desc sip_ctrg_desc = {
+ "sip-connector",
+ "SIP connector",
+ OSMO_STATS_CLASS_GLOBAL,
+ ARRAY_SIZE(sip_ctr_description),
+ sip_ctr_description
+};
diff --git a/src/main.c b/src/main.c
index 560995e..d07f51b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -26,6 +26,7 @@
#include "mncc.h"
#include "app.h"
#include "call.h"
+#include "ctr.h"
#include <osmocom/core/application.h>
#include <osmocom/core/utils.h>
@@ -113,6 +114,7 @@
{
int rc;
GMainLoop *loop;
+ struct rate_ctr_group *ctrg;
/* initialize osmocom */
tall_mncc_ctx = talloc_named_const(NULL, 0, "MNCC CTX");
@@ -120,6 +122,14 @@
osmo_init_logging2(tall_mncc_ctx, &mncc_sip_info);
osmo_stats_init(tall_mncc_ctx);
+ /* init statistics */
+ rate_ctr_init(tall_mncc_ctx);
+ ctrg = rate_ctr_group_alloc(tall_mncc_ctx, &sip_ctrg_desc, 0);
+ if (!ctrg) {
+ LOGP(DAPP, LOGL_ERROR, "Cannot allocate global counter group!\n");
+ exit(1);
+ }
+
mncc_sip_vty_init();
logging_vty_add_cmds(&mncc_sip_info);
osmo_stats_vty_add_cmds(&mncc_sip_info);
@@ -144,7 +154,7 @@
mncc_connection_start(&g_app.mncc.conn);
/* sofia sip */
- sip_agent_init(&g_app.sip.agent, &g_app);
+ sip_agent_init(&g_app.sip.agent, &g_app, ctrg);
rc = sip_agent_start(&g_app.sip.agent);
if (rc < 0)
LOGP(DSIP, LOGL_ERROR,
diff --git a/src/sip.c b/src/sip.c
index adf20d8..e7eeed6 100644
--- a/src/sip.c
+++ b/src/sip.c
@@ -21,6 +21,7 @@
#include "sip.h"
#include "app.h"
#include "call.h"
+#include "ctr.h"
#include "logging.h"
#include "sdp.h"
@@ -77,6 +78,15 @@
leg->state = SIP_CC_CONNECTED;
other->connect_call(other);
nua_ack(leg->nua_handle, TAG_END());
+ // rate_ctr_inc2(argent->ctrg, SIP_CTR_CALL_CONNECTED);
+}
+
+static void new_call_failure(struct sip_agent *agent, nua_handle_t *nh,
+ int status, char const* phrase)
+{
+ nua_respond(nh, status, phrase, TAG_END());
+ nua_handle_destroy(nh);
+ rate_ctr_inc2(agent->ctrg, SIP_CTR_CALL_FAILED);
}
static void new_call(struct sip_agent *agent, nua_handle_t *nh,
@@ -90,16 +100,14 @@
if (!sdp_screen_sdp(sip)) {
LOGP(DSIP, LOGL_ERROR, "No supported codec.\n");
- nua_respond(nh, SIP_406_NOT_ACCEPTABLE, TAG_END());
- nua_handle_destroy(nh);
+ new_call_failure(agent, nh, SIP_406_NOT_ACCEPTABLE);
return;
}
call = call_sip_create();
if (!call) {
LOGP(DSIP, LOGL_ERROR, "No supported codec.\n");
- nua_respond(nh, SIP_500_INTERNAL_SERVER_ERROR, TAG_END());
- nua_handle_destroy(nh);
+ new_call_failure(agent, nh, SIP_500_INTERNAL_SERVER_ERROR);
return;
}
@@ -110,8 +118,7 @@
if (!to || !from) {
LOGP(DSIP, LOGL_ERROR, "Unknown from/to for invite.\n");
- nua_respond(nh, SIP_406_NOT_ACCEPTABLE, TAG_END());
- nua_handle_destroy(nh);
+ new_call_failure(agent, nh, SIP_406_NOT_ACCEPTABLE);
return;
}
@@ -128,8 +135,7 @@
*/
if (!sdp_extract_sdp(leg, sip, true)) {
LOGP(DSIP, LOGL_ERROR, "leg(%p) no audio, releasing\n", leg);
- nua_respond(nh, SIP_406_NOT_ACCEPTABLE, TAG_END());
- nua_handle_destroy(nh);
+ new_call_failure(agent, nh, SIP_406_NOT_ACCEPTABLE);
call_leg_release(&leg->base);
return;
}
@@ -354,6 +360,8 @@
nua_bye(leg->nua_handle, TAG_END());
break;
}
+
+ // rate_ctr_inc2(argent->ctrg, SIP_CTR_CALL_RELEASED);
}
static void sip_ring_call(struct call_leg *_leg)
@@ -364,6 +372,7 @@
leg = (struct sip_call_leg *) _leg;
nua_respond(leg->nua_handle, SIP_180_RINGING, TAG_END());
+ // rate_ctr_inc2(argent->ctrg, SIP_CTR_CALL_INITIATED);
}
static void sip_connect_call(struct call_leg *_leg)
@@ -495,9 +504,11 @@
osmo_vlogp(DSIP, LOGL_NOTICE, "", 0, 0, fmt, ap);
}
-void sip_agent_init(struct sip_agent *agent, struct app_config *app)
+void sip_agent_init(struct sip_agent *agent, struct app_config *app,
+ struct rate_ctr_group *ctrg)
{
agent->app = app;
+ agent->ctrg = ctrg;
su_init();
su_home_init(&agent->home);
diff --git a/src/sip.h b/src/sip.h
index d25c0b1..e6b9b72 100644
--- a/src/sip.h
+++ b/src/sip.h
@@ -6,6 +6,7 @@
#include <sofia-sip/nua_tag.h>
#include <sofia-sip/su_glib.h>
#include <sofia-sip/nua.h>
+#include <osmocom/core/rate_ctr.h>
struct app_config;
struct call;
@@ -16,9 +17,12 @@
su_root_t *root;
nua_t *nua;
+
+ struct rate_ctr_group *ctrg;
};
-void sip_agent_init(struct sip_agent *agent, struct app_config *app);
+void sip_agent_init(struct sip_agent *agent, struct app_config *app,
+ struct rate_ctr_group *ctrg);
int sip_agent_start(struct sip_agent *agent);
int sip_create_remote_leg(struct sip_agent *agent, struct call *call);
--
To view, visit https://gerrit.osmocom.org/11199
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-sip-connector
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6d7963266a93be631a4e0e03a39916d07a88fe01
Gerrit-Change-Number: 11199
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181002/37e22ae6/attachment.htm>