mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-29 18:19:30 +00:00
Add High Resolution Times to CDRs for Asterisk
People expressed an interest in having access to the exact length of calls to a finer degree than seconds. See the CHANGES and UPGRADE.txt for usage also updated the sample configs to note the change. Patch by snuffy. (closes issue #16559) Reported by: cianmaher Tested by: cianmaher, snuffy Review: https://reviewboard.asterisk.org/r/461/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@269153 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -611,6 +611,23 @@ static int odbc_log(struct ast_cdr *cdr)
|
||||
continue;
|
||||
} else {
|
||||
double number = 0.0;
|
||||
|
||||
if (!strcasecmp(entry->cdrname, "billsec")) {
|
||||
if (!ast_tvzero(cdr->answer)) {
|
||||
snprintf(colbuf, sizeof(colbuf), "%lf",
|
||||
(double) (ast_tvdiff_us(cdr->end, cdr->answer) / 1000000.0));
|
||||
} else {
|
||||
ast_copy_string(colbuf, "0", sizeof(colbuf));
|
||||
}
|
||||
} else if (!strcasecmp(entry->cdrname, "duration")) {
|
||||
snprintf(colbuf, sizeof(colbuf), "%lf",
|
||||
(double) (ast_tvdiff_us(cdr->end, cdr->start) / 1000000.0));
|
||||
|
||||
if (!ast_strlen_zero(colbuf)) {
|
||||
colptr = colbuf;
|
||||
}
|
||||
}
|
||||
|
||||
if (sscanf(colptr, "%30lf", &number) != 1) {
|
||||
ast_log(LOG_WARNING, "CDR variable %s is not an numeric type.\n", entry->name);
|
||||
continue;
|
||||
@@ -628,6 +645,23 @@ static int odbc_log(struct ast_cdr *cdr)
|
||||
continue;
|
||||
} else {
|
||||
double number = 0.0;
|
||||
|
||||
if (!strcasecmp(entry->cdrname, "billsec")) {
|
||||
if (!ast_tvzero(cdr->answer)) {
|
||||
snprintf(colbuf, sizeof(colbuf), "%lf",
|
||||
(double) (ast_tvdiff_us(cdr->end, cdr->answer) / 1000000.0));
|
||||
} else {
|
||||
ast_copy_string(colbuf, "0", sizeof(colbuf));
|
||||
}
|
||||
} else if (!strcasecmp(entry->cdrname, "duration")) {
|
||||
snprintf(colbuf, sizeof(colbuf), "%lf",
|
||||
(double) (ast_tvdiff_us(cdr->end, cdr->start) / 1000000.0));
|
||||
|
||||
if (!ast_strlen_zero(colbuf)) {
|
||||
colptr = colbuf;
|
||||
}
|
||||
}
|
||||
|
||||
if (sscanf(colptr, "%30lf", &number) != 1) {
|
||||
ast_log(LOG_WARNING, "CDR variable %s is not an numeric type.\n", entry->name);
|
||||
continue;
|
||||
|
Reference in New Issue
Block a user