[OpenSIPS-Users] Adding extra information into the acc table based on dr_rules

Bogdan-Andrei Iancu bogdan at opensips.org
Tue Jun 10 15:10:26 CEST 2014


Hi Gordon,

Note that $var(rule_attrs_pvar) is populated only after do_routing() is 
done successful and only if passed as parameter on the right position 
(see the function prototype). Do you have something like that in your 
script ?

Regards,

Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
http://www.opensips-solutions.com

On 08.06.2014 22:23, Gordon Sims wrote:
> Hello Bogdan-Andrei,
>
> I've looked over the link and tried to piece it into the config. 
>  Unfortunately I could not get it to log to the database.
>
> Here is the opensips.cfg file:
>
> #### ACCounting module
> loadmodule "acc.so"
> /* what special events should be accounted ? */
> modparam("acc", "early_media", 0)
> modparam("acc", "report_cancels", 0)
> /* by default we do not adjust the direct of the sequential requests.
>    if you enable this parameter, be sure the enable "append_fromtag"
>    in "rr" module */
> modparam("acc", "detect_direction", 0)
> modparam("acc", "cdr_flag", "ACC_CDR")
> #modparam("acc", "failed_transaction_flag", "ACC_FAILED")
> /* account triggers (flags) */
> modparam("acc", "db_flag", "ACC_DO")
> modparam("acc", "db_url",
>         "mysql://randomuser:p4ssw0rd@10.0.9.23/sip_gate") # CUSTOMIZE ME
> modparam("acc", "db_extra", "from_uri=$fU; to_uri=$tU; 
> attrs=$var(rule_attrs_pvar)")  #Extra data
> ...
>
> route{
>
>         if (method == "INVITE") {
>                 create_dialog();
>                 setflag(ACC_CDR);
>                 setflag(ACC_DO); # do accounting ...
>                 record_route();
>                 xlog("INBOUND 
> CALL,$dd,$ru,$ci,$fn,$fu,$var(rule_attrs_pvar)");
>                 route(10);
>                 exit;
>         }
>
> I also tried to put it into the xlog to see if I could find it in 
> there and no such luck.  I know I'm obviously doing something wrong, 
> but not sure what.  At this point I'm gong cross eyed looking at the code.
>
> If you have any additional advice, would be much appreciated.
>
> Thanks,
>
> Gordon
>
>
>
> From: Bogdan-Andrei Iancu <bogdan at opensips.org 
> <mailto:bogdan at opensips.org>>
> Reply-To: OpenSIPS users mailling list <users at lists.opensips.org 
> <mailto:users at lists.opensips.org>>
> Date: Sun, 8 Jun 2014 17:45:35 +0300
> To: OpenSIPS users mailling list <users at lists.opensips.org 
> <mailto:users at lists.opensips.org>>, Gordon Sims <gsims94 at gmail.com 
> <mailto:gsims94 at gmail.com>>
> Subject: Re: [OpenSIPS-Users] Adding extra information into the acc 
> table based on dr_rules
>
> Hi Gordon,
>
> Instead of adding a new column to the dr_rules, I suggest to use the 
> "attrs" column of that table. It is not used by the actual routing 
> engine, its only purpose is to allow the user to attach custom data to 
> the rules. So add your ID into the attrs columns - when the rule is 
> match, the attrs value will be available into script into a variable 
> (see 
> http://www.opensips.org/html/docs/modules/1.11.x/drouting.html#id294716, 
> rule_attrs_pvar parameter).
>
> Once you loaded into a variable, via db_extra you can push it to the 
> acc table.
>
> Regards,
> Bogdan-Andrei Iancu
> OpenSIPS Founder and Developer
> http://www.opensips-solutions.com
> On 08.06.2014 15:35, Gordon Sims wrote:
>> First off, I would like to thank Razvan for my cdr accounting issue 
>> and using db_extra.  Was exactly what I was looking for.
>>
>> Now I'm getting stumped on adding in extra information into the acc 
>> table.  I've added in another field to both my dr_rules and acc 
>> tables called account_id (int 6).  What I would like to do is when 
>> the call comes in, based on the destination, is to take the 
>> account_id information from the  dr_rules table and insert that same 
>> value into the acc table.  I've looked at avpops module, but not 
>> finding anything definitive that would do what I've looking for.  I 
>> hope I'm not the only one that is trying to do this.  I'm looking for 
>> a working example on how to accomplish this one.
>>
>> Thanks in advance,
>>
>> Gordon
>>
>>
>> _______________________________________________
>> Users mailing list
>> Users at lists.opensips.orghttp://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
> _______________________________________________ Users mailing list 
> Users at lists.opensips.org <mailto:Users at lists.opensips.org> 
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20140610/a3cdd1a9/attachment-0001.htm>


More information about the Users mailing list