diff options
author | snuffy <snuffy@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-06-08 23:48:17 +0000 |
---|---|---|
committer | snuffy <snuffy@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-06-08 23:48:17 +0000 |
commit | b9d2b2684d6dfde3759cbbc84dfb6aa11d0e3b60 (patch) | |
tree | b9c0a6d9e565124104804ec2cb1e31a3c6b5ea41 /addons | |
parent | 6db8e08fa31bc24296db13621a207e435834fdcd (diff) |
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: http://svn.digium.com/svn/asterisk/trunk@269153 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'addons')
-rw-r--r-- | addons/cdr_mysql.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/addons/cdr_mysql.c b/addons/cdr_mysql.c index a6a527b24..504163a21 100644 --- a/addons/cdr_mysql.c +++ b/addons/cdr_mysql.c @@ -288,6 +288,40 @@ db_reconnect: ast_str_append(&sql2, 0, ","); } + if (!strcasecmp(cdrname, "billsec") && + (strstr(entry->type, "float") || + strstr(entry->type, "double") || + strstr(entry->type, "decimal") || + strstr(entry->type, "numeric") || + strstr(entry->type, "real"))) { + + if (!ast_tvzero(cdr->answer)) { + snprintf(workspace, sizeof(workspace), "%lf", + (double) (ast_tvdiff_us(cdr->end, cdr->answer) / 1000000.0)); + } else { + ast_copy_string(workspace, "0", sizeof(workspace)); + } + + if (!ast_strlen_zero(workspace)) { + value = workspace; + } + } + + if (!strcasecmp(cdrname, "duration") && + (strstr(entry->type, "float") || + strstr(entry->type, "double") || + strstr(entry->type, "decimal") || + strstr(entry->type, "numeric") || + strstr(entry->type, "real"))) { + + snprintf(workspace, sizeof(workspace), "%lf", + (double) (ast_tvdiff_us(cdr->end, cdr->start) / 1000000.0)); + + if (!ast_strlen_zero(workspace)) { + value = workspace; + } + } + ast_str_make_space(&escape, (valsz = strlen(value)) * 2 + 1); mysql_real_escape_string(&mysql, ast_str_buffer(escape), value, valsz); |