summaryrefslogtreecommitdiff
path: root/res/res_pjsip/location.c
diff options
context:
space:
mode:
authorMatt Jordan <mjordan@digium.com>2015-11-18 10:07:09 -0600
committerMatt Jordan <mjordan@digium.com>2015-11-23 08:44:21 -0600
commit75d90a9951b6b679d475335698544540089750a1 (patch)
treed215fa862c0a8622b7171bdb661039b234f27bb3 /res/res_pjsip/location.c
parent97d7b344de46236d153cdcc162371178c7b39854 (diff)
res_pjsip/pjsip_options: Add StatsD statistics for PJSIP contacts
This patch adds the ability to send StatsD statistics related to the state of PJSIP contacts. This includes: * A GUAGE statistic measuring the count of contacts in a particular state. This measures how many contacts are reachable, unreachable, etc. * The RTT time for each contact, if those contacts are qualified. This provides StatsD engines useful time-based data about each contact. ASTERISK-25571 Change-Id: Ib8378d73afedfc622be0643b87c542557e0b332c
Diffstat (limited to 'res/res_pjsip/location.c')
-rw-r--r--res/res_pjsip/location.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/res/res_pjsip/location.c b/res/res_pjsip/location.c
index eef1d43d2..9cc7f1629 100644
--- a/res/res_pjsip/location.c
+++ b/res/res_pjsip/location.c
@@ -26,6 +26,7 @@
#include "asterisk/sorcery.h"
#include "include/res_pjsip_private.h"
#include "asterisk/res_pjsip_cli.h"
+#include "asterisk/statsd.h"
/*! \brief Destructor for AOR */
static void aor_destroy(void *obj)
@@ -940,6 +941,8 @@ static int contact_apply_handler(const struct ast_sorcery *sorcery, void *object
int ast_sip_initialize_sorcery_location(void)
{
struct ast_sorcery *sorcery = ast_sip_get_sorcery();
+ int i;
+
ast_sorcery_apply_default(sorcery, "contact", "astdb", "registrar");
ast_sorcery_apply_default(sorcery, "aor", "config", "pjsip.conf,criteria=type=aor");
@@ -1006,6 +1009,15 @@ int ast_sip_initialize_sorcery_location(void)
ast_sip_register_cli_formatter(aor_formatter);
ast_cli_register_multiple(cli_commands, ARRAY_LEN(cli_commands));
+ /*
+ * Reset StatsD gauges in case we didn't shut down cleanly.
+ * Note that this must done here, as contacts will create the contact_status
+ * object before PJSIP options handling is initialized.
+ */
+ for (i = 0; i < REMOVED; i++) {
+ ast_statsd_log_full_va("PJSIP.contacts.states.%s", AST_STATSD_GUAGE, 0, 1.0, ast_sip_get_contact_status_label(i));
+ }
+
return 0;
}