Add option for logging congested calls as CONGESTION instead of NO_ANSWER in CDR

This patch adds a CDR option to cdr.conf that will allow CDR files to log calls ending
with congestion in a way that is unique from other unanswered calls.

(closes issue ASTERISK-14842)
Reported by: Alec Davis
Patches:
	cdr_congestion.diff.txt (License #5546) patch uploaded by Alec Davis


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@332760 65c4cc65-6c06-0410-ace0-fbb531ad65f3
certified/11.2
Jonathan Rose 15 years ago
parent 91d3a7d3a1
commit 901e275c4c

@ -84,6 +84,7 @@ CDR
--------------------------
* The filter option in cdr_adaptive_odbc now supports negating the argument,
thus allowing records which do NOT match the specified filter.
* Added ability to log CONGESTION calls to CDR
CODECS
--------------------------

@ -29,6 +29,11 @@
; channel.)
;unanswered = no
; Define whether or not to log congested calls. Setting this to "yes" will
; report each call that fails to complete due to congestion conditions. Default
; is "no".
;congestion = no
; Normally, CDR's are not closed out until after all extensions are finished
; executing. By enabling this option, the CDR will be ended before executing
; the "h" extension so that CDR values such as "end" and "billsec" may be

@ -58,6 +58,7 @@ enum {
AST_CDR_FAILED = (1 << 1),
AST_CDR_BUSY = (1 << 2),
AST_CDR_ANSWERED = (1 << 3),
AST_CDR_CONGESTION = (1 << 4),
};
/*!
@ -133,6 +134,7 @@ struct ast_cdr {
};
int ast_cdr_isset_unanswered(void);
int ast_cdr_isset_congestion(void);
void ast_cdr_getvar(struct ast_cdr *cdr, const char *name, char **ret, char *workspace, int workspacelen, int recur, int raw);
int ast_cdr_setvar(struct ast_cdr *cdr, const char *name, const char *value, int recur);
int ast_cdr_serialize_variables(struct ast_cdr *cdr, struct ast_str **buf, char delim, char sep, int recur);
@ -266,6 +268,15 @@ void ast_cdr_answer(struct ast_cdr *cdr);
*/
extern void ast_cdr_noanswer(struct ast_cdr *cdr);
/*!
* \brief A call was set to congestion
* \param cdr the cdr you wish to associate with the call
* Markst he channel disposition as "CONGESTION"
* Will skip CDR's in chain with ANS_LOCK bit set. (see
* forkCDR() application
*/
extern void ast_cdr_congestion(struct ast_cdr *cdr);
/*!
* \brief Busy a call
* \param cdr the cdr you wish to associate with the call

@ -93,6 +93,9 @@ static const int BATCHMODE_DEFAULT = 0;
static int unanswered;
static const int UNANSWERED_DEFAULT = 0;
static int congestion;
static const int CONGESTION_DEFAULT = 0;
static int batchsize;
static const int BATCH_SIZE_DEFAULT = 100;
@ -181,6 +184,11 @@ int ast_cdr_isset_unanswered(void)
return unanswered;
}
int ast_cdr_isset_congestion(void)
{
return congestion;
}
struct ast_cdr *ast_cdr_dup_unique(struct ast_cdr *cdr)
{
struct ast_cdr *newcdr = ast_cdr_dup(cdr);
@ -776,6 +784,34 @@ void ast_cdr_noanswer(struct ast_cdr *cdr)
}
}
void ast_cdr_congestion(struct ast_cdr *cdr)
{
char *chan;
ast_verb (1, "congestion value: %d\n INYOURFACE", congestion);
/* if congestion log is disabled, pass the buck to ast_cdr_failed */
if (!congestion) {
ast_cdr_failed(cdr);
}
while (cdr && congestion) {
if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) {
chan = !ast_strlen_zero(cdr->channel) ? cdr->channel : "<unknown>";
if (ast_test_flag(cdr, AST_CDR_FLAG_POSTED)) {
ast_log(LOG_WARNING, "CDR on channel '%s' already posted\n", chan);
}
if (cdr->disposition < AST_CDR_CONGESTION) {
cdr->disposition = AST_CDR_CONGESTION;
}
}
cdr = cdr->next;
}
}
/* everywhere ast_cdr_disposition is called, it will call ast_cdr_failed()
if ast_cdr_disposition returns a non-zero value */
@ -792,6 +828,9 @@ int ast_cdr_disposition(struct ast_cdr *cdr, int cause)
case AST_CAUSE_NO_ANSWER:
ast_cdr_noanswer(cdr);
break;
case AST_CAUSE_NORMAL_CIRCUIT_CONGESTION:
ast_cdr_congestion(cdr);
break;
case AST_CAUSE_NORMAL:
break;
default:
@ -961,6 +1000,8 @@ char *ast_cdr_disp2str(int disposition)
return "BUSY";
case AST_CDR_ANSWERED:
return "ANSWERED";
case AST_CDR_CONGESTION:
return "CONGESTION";
}
return "UNKNOWN";
}
@ -1416,7 +1457,8 @@ static char *handle_cli_status(struct ast_cli_entry *e, int cmd, struct ast_cli_
ast_cli(a->fd, " Logging: %s\n", enabled ? "Enabled" : "Disabled");
ast_cli(a->fd, " Mode: %s\n", batchmode ? "Batch" : "Simple");
if (enabled) {
ast_cli(a->fd, " Log unanswered calls: %s\n\n", unanswered ? "Yes" : "No");
ast_cli(a->fd, " Log unanswered calls: %s\n", unanswered ? "Yes" : "No");
ast_cli(a->fd, " Log congestion: %s\n\n", congestion ? "Yes" : "No");
if (batchmode) {
ast_cli(a->fd, "* Batch Mode Settings\n");
ast_cli(a->fd, " -------------------\n");
@ -1477,6 +1519,7 @@ static int do_reload(int reload)
struct ast_config *config;
const char *enabled_value;
const char *unanswered_value;
const char *congestion_value;
const char *batched_value;
const char *scheduleronly_value;
const char *batchsafeshutdown_value;
@ -1507,6 +1550,7 @@ static int do_reload(int reload)
enabled = ENABLED_DEFAULT;
batchmode = BATCHMODE_DEFAULT;
unanswered = UNANSWERED_DEFAULT;
congestion = CONGESTION_DEFAULT;
if (config == CONFIG_STATUS_FILEMISSING || config == CONFIG_STATUS_FILEINVALID) {
ast_mutex_unlock(&cdr_batch_lock);
@ -1523,6 +1567,10 @@ static int do_reload(int reload)
if ((unanswered_value = ast_variable_retrieve(config, "general", "unanswered"))) {
unanswered = ast_true(unanswered_value);
}
if ((congestion_value = ast_variable_retrieve(config, "general", "congestion"))) {
ast_verb(1, "INTHEFACEPUNCH!\n");
congestion = ast_true(congestion_value);
}
if ((batched_value = ast_variable_retrieve(config, "general", "batch"))) {
batchmode = ast_true(batched_value);
}

@ -9323,11 +9323,16 @@ static int pbx_builtin_busy(struct ast_channel *chan, const char *data)
*/
static int pbx_builtin_congestion(struct ast_channel *chan, const char *data)
{
ast_verb(1, "pbx_builtin_congestion HITINTHEFACE!\n");
ast_verb(1, "AST_STATE = %d INTHEFACE\n", chan->_state);
ast_indicate(chan, AST_CONTROL_CONGESTION);
/* Don't change state of an UP channel, just indicate
congestion in audio */
if (chan->_state != AST_STATE_UP)
if (chan->_state != AST_STATE_UP) {
ast_setstate(chan, AST_STATE_BUSY);
ast_verb(1, "ast_cdr_congestion INTHEFACE\n");
ast_cdr_congestion(chan->cdr);
}
wait_for_hangup(chan, data);
return -1;
}

Loading…
Cancel
Save