struct tables {
char *connection;
char *table;
+ unsigned int usegmtime:1;
AST_LIST_HEAD_NOLOCK(odbc_columns, columns) columns;
AST_RWLIST_ENTRY(tables) list;
};
char columnname[80];
char connection[40];
char table[40];
- int lenconnection, lentable;
+ int lenconnection, lentable, usegmtime;
SQLLEN sqlptr;
int res = 0;
SQLHSTMT stmt = NULL;
ast_copy_string(connection, tmp, sizeof(connection));
lenconnection = strlen(connection);
+ if (!ast_strlen_zero(tmp = ast_variable_retrieve(cfg, catg, "usegmtime"))) {
+ usegmtime = ast_true(tmp);
+ }
+
/* When loading, we want to be sure we can connect. */
obj = ast_odbc_request_obj(connection, 1);
if (!obj) {
break;
}
+ tableptr->usegmtime = usegmtime;
tableptr->connection = (char *)tableptr + sizeof(*tableptr);
tableptr->table = (char *)tableptr + sizeof(*tableptr) + lenconnection + 1;
ast_copy_string(tableptr->connection, connection, lenconnection + 1);
}
AST_LIST_TRAVERSE(&(tableptr->columns), entry, list) {
+ int datefield = 0;
+ if (strcasecmp(entry->cdrname, "start") == 0) {
+ datefield = 1;
+ } else if (strcasecmp(entry->cdrname, "answer") == 0) {
+ datefield = 2;
+ } else if (strcasecmp(entry->cdrname, "end") == 0) {
+ datefield = 3;
+ }
+
/* Check if we have a similarly named variable */
- ast_cdr_getvar(cdr, entry->cdrname, &colptr, colbuf, sizeof(colbuf), 0,
- (strcasecmp(entry->cdrname, "start") == 0 ||
- strcasecmp(entry->cdrname, "answer") == 0 ||
- strcasecmp(entry->cdrname, "end") == 0) ? 0 : 1);
+ if (datefield && tableptr->usegmtime) {
+ struct timeval tv = (datefield == 1) ? cdr->start : (datefield == 2) ? cdr->answer : cdr->end;
+ struct ast_tm tm = { 0, };
+ ast_localtime(&tv, &tm, "UTC");
+ ast_strftime(colbuf, sizeof(colbuf), "%Y-%m-%d %H:%M:%S", &tm);
+ } else {
+ ast_cdr_getvar(cdr, entry->cdrname, &colptr, colbuf, sizeof(colbuf), 0, datefield ? 0 : 1);
+ }
if (colptr) {
/* Check first if the column filters this entry. Note that this
;[third]
;connection=sqlserver
;table=AsteriskCDR
+;usegmtime=yes ; defaults to no
;alias src => source
;alias channel => source_channel
;alias dst => dest
;filter src => 123
+; On Wednesday 10 September 2008 21:11:16 Tilghman Lesher wrote:
+;
+; I thought that the sample cdr_adaptive_odbc.conf was rather clear, but
+; apparently not. The point of this module is to allow you log whatever you
+; like in terms of the CDR variables. Do you want to log uniqueid? Then simply
+; ensure that your table has that column. If you don't want the column, ensure
+; that it does not exist in the table structure. If you'd like to call uniqueid
+; something else in your table, simply provide an alias in the configuration
+; file that maps the standard CDR field name (uniqueid) to whatever column
+; name you like. Perhaps you'd like some extra CDR values logged that aren't
+; in the standard repertoire of CDR variables (some that come to mind are
+; certain values used for LCR: route, per_minute_cost, and per_minute_price).
+; Simply set those CDR variables in your dialplan, i.e. Set(CDR(route)=27),
+; ensure that a corresponding column exists in your table, and cdr_adaptive_odbc
+; will do the rest.
+