mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-11 07:13:20 +00:00
Merge "res_pjsip/pjsip_options: Add StatsD statistics for PJSIP contacts" into 13
This commit is contained in:
8
CHANGES
8
CHANGES
@@ -55,6 +55,14 @@ res_pjsip
|
|||||||
* The ability to use "like" has been added to the pjsip list and show
|
* The ability to use "like" has been added to the pjsip list and show
|
||||||
CLI commands. For instance: CLI> pjsip list endpoints like abc
|
CLI commands. For instance: CLI> pjsip list endpoints like abc
|
||||||
|
|
||||||
|
* If res_statsd is loaded and a StatsD server is configured, basic statistics
|
||||||
|
regarding the state of PJSIP contacts will not be emitted. This includes:
|
||||||
|
- A GUAGE statistic for the overall number of contacts in a particular
|
||||||
|
state, e.g.:
|
||||||
|
PJSIP.contacts.states.Reachable
|
||||||
|
- A TIMER statistic for the RTT time for each qualified contact, e.g.:
|
||||||
|
PJSIP.contacts.alice@@127.0.0.1:5061.rtt
|
||||||
|
|
||||||
func_callerid
|
func_callerid
|
||||||
-------------------
|
-------------------
|
||||||
* CALLERID(pres) is now documented as a valid alternative to setting both
|
* CALLERID(pres) is now documented as a valid alternative to setting both
|
||||||
|
@@ -26,6 +26,7 @@
|
|||||||
#include "asterisk/sorcery.h"
|
#include "asterisk/sorcery.h"
|
||||||
#include "include/res_pjsip_private.h"
|
#include "include/res_pjsip_private.h"
|
||||||
#include "asterisk/res_pjsip_cli.h"
|
#include "asterisk/res_pjsip_cli.h"
|
||||||
|
#include "asterisk/statsd.h"
|
||||||
|
|
||||||
/*! \brief Destructor for AOR */
|
/*! \brief Destructor for AOR */
|
||||||
static void aor_destroy(void *obj)
|
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)
|
int ast_sip_initialize_sorcery_location(void)
|
||||||
{
|
{
|
||||||
struct ast_sorcery *sorcery = ast_sip_get_sorcery();
|
struct ast_sorcery *sorcery = ast_sip_get_sorcery();
|
||||||
|
int i;
|
||||||
|
|
||||||
ast_sorcery_apply_default(sorcery, "contact", "astdb", "registrar");
|
ast_sorcery_apply_default(sorcery, "contact", "astdb", "registrar");
|
||||||
ast_sorcery_apply_default(sorcery, "aor", "config", "pjsip.conf,criteria=type=aor");
|
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_sip_register_cli_formatter(aor_formatter);
|
||||||
ast_cli_register_multiple(cli_commands, ARRAY_LEN(cli_commands));
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -29,6 +29,7 @@
|
|||||||
#include "asterisk/cli.h"
|
#include "asterisk/cli.h"
|
||||||
#include "asterisk/time.h"
|
#include "asterisk/time.h"
|
||||||
#include "asterisk/test.h"
|
#include "asterisk/test.h"
|
||||||
|
#include "asterisk/statsd.h"
|
||||||
#include "include/res_pjsip_private.h"
|
#include "include/res_pjsip_private.h"
|
||||||
|
|
||||||
#define DEFAULT_LANGUAGE "en"
|
#define DEFAULT_LANGUAGE "en"
|
||||||
@@ -113,6 +114,9 @@ struct ast_sip_contact_status *ast_res_pjsip_find_or_create_contact_status(const
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ast_statsd_log_string_va("PJSIP.contacts.states.%s", AST_STATSD_GUAGE,
|
||||||
|
"+1", 1.0, ast_sip_get_contact_status_label(status->status));
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,6 +147,12 @@ static void update_contact_status(const struct ast_sip_contact *contact,
|
|||||||
|
|
||||||
update->last_status = status->status;
|
update->last_status = status->status;
|
||||||
update->status = value;
|
update->status = value;
|
||||||
|
if (update->last_status != update->status) {
|
||||||
|
ast_statsd_log_string_va("PJSIP.contacts.states.%s", AST_STATSD_GUAGE,
|
||||||
|
"-1", 1.0, ast_sip_get_contact_status_label(update->last_status));
|
||||||
|
ast_statsd_log_string_va("PJSIP.contacts.states.%s", AST_STATSD_GUAGE,
|
||||||
|
"+1", 1.0, ast_sip_get_contact_status_label(update->status));
|
||||||
|
}
|
||||||
|
|
||||||
/* if the contact is available calculate the rtt as
|
/* if the contact is available calculate the rtt as
|
||||||
the diff between the last start time and "now" */
|
the diff between the last start time and "now" */
|
||||||
@@ -151,6 +161,8 @@ static void update_contact_status(const struct ast_sip_contact *contact,
|
|||||||
|
|
||||||
update->rtt_start = ast_tv(0, 0);
|
update->rtt_start = ast_tv(0, 0);
|
||||||
|
|
||||||
|
ast_statsd_log_full_va("PJSIP.contacts.%s.rtt", AST_STATSD_TIMER,
|
||||||
|
update->rtt / 1000, 1.0, ast_sorcery_object_get_id(update));
|
||||||
ast_test_suite_event_notify("AOR_CONTACT_QUALIFY_RESULT",
|
ast_test_suite_event_notify("AOR_CONTACT_QUALIFY_RESULT",
|
||||||
"Contact: %s\r\n"
|
"Contact: %s\r\n"
|
||||||
"Status: %s\r\n"
|
"Status: %s\r\n"
|
||||||
|
Reference in New Issue
Block a user