[asterisk-users] create custom cdr's

William Piper william.piper at gmail.com
Wed Aug 2 21:02:10 MST 2006


On 8/2/06, Kevin P. Fleming <kpfleming at digium.com> wrote:
>
> ----- Carlos Chavez <cursor at telecomabmex.com> wrote:
> >       The only thing you can really do from the dialplan is to use the
> > CDR(userfield) function to add custom information, but I do not think
> > there is a way to put additional fields into the CDR database this
> > way.
>
> The CDR() function allows you to define your own variables in the CDR with
> any names/values you want. However, none of the existing CDR->database
> backends will dump these variables out to a database (although they could
> easily do so).
>
> --
> Kevin P. Fleming
> Senior Software Engineer
> Digium, Inc.
>
> Kevin,

I guess "cdr_addon_mysql.c" would need to be modified to accept the new
fields?
I'm not a C# programmer, but it looks like the following is what I need to
modify:

Do you have an example code that I could look at of this?

#ifdef MYSQL_LOGUNIQUEID
sprintf(sqlcmd, "INSERT INTO %s
(calldate,clid,src,dst,dcontext,channel,dstchannel,lastapp,lastdata,duration,billsec,disposition,amaflags,accountcode,uniqueid,userfield)
VALUES ('%s','%s','%s','%s','%s',
'%s','%s','%s','%s',%i,%i,'%s',%i,'%s','%s','%s')", dbtable, timestr, clid,
cdr->src, cdr->dst, dcontext, channel, dstchannel, lastapp, lastdata,
cdr->duration, cdr->billsec, ast_cdr_disp2str(cdr->disposition),
cdr->amaflags, cdr->accountcode, uniqueid, userfielddata);
#else
sprintf(sqlcmd, "INSERT INTO %s
(calldate,clid,src,dst,dcontext,channel,dstchannel,lastapp,lastdata,duration,billsec,disposition,amaflags,accountcode,userfield)
VALUES ('%s','%s','%s','%s','%s',
'%s','%s','%s','%s',%i,%i,'%s',%i,'%s','%s')", dbtable, timestr, clid,
cdr->src, cdr->dst, dcontext,channel, dstchannel, lastapp, lastdata,
cdr->duration, cdr->billsec, ast_cdr_disp2str(cdr->disposition),
cdr->amaflags, cdr->accountcode, userfielddata);
#endif
} else {
#ifdef MYSQL_LOGUNIQUEID
sprintf(sqlcmd, "INSERT INTO %s
(calldate,clid,src,dst,dcontext,channel,dstchannel,lastapp,lastdata,duration,billsec,disposition,amaflags,accountcode,uniqueid)
VALUES ('%s','%s','%s','%s','%s',
'%s','%s','%s','%s',%i,%i,'%s',%i,'%s','%s')", dbtable, timestr, clid,
cdr->src, cdr->dst, dcontext,channel, dstchannel, lastapp, lastdata,
cdr->duration, cdr->billsec, ast_cdr_disp2str(cdr->disposition),
cdr->amaflags, cdr->accountcode, uniqueid);
#else
sprintf(sqlcmd, "INSERT INTO %s
(calldate,clid,src,dst,dcontext,channel,dstchannel,lastapp,lastdata,duration,billsec,disposition,amaflags,accountcode)
VALUES ('%s','%s','%s','%s','%s', '%s','%s','%s','%s',%i,%i,'%s',%i,'%s')",
dbtable, timestr, clid, cdr->src, cdr->dst, dcontext, channel, dstchannel,
lastapp, lastdata, cdr->duration, cdr->billsec,
ast_cdr_disp2str(cdr->disposition), cdr->amaflags, cdr->accountcode);

Thanks,

bp
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20060802/a4f2ea05/attachment.htm


More information about the asterisk-users mailing list