1

I am using Opensips 2.3 and already doing accounting. But I have a very different database, where I already configure to do missing/channel exceed CDRS manually using avp_db.

Is there a way to do accounting for a call established, as in automatic it is doing all accounting in acc table, but it is also doing established, missing and busy calls same way, but I want to do only established calls CDRS. For an automatic account, I am using following acc commands

loadmodule "acc.so"
modparam("acc", "early_media", 0)
modparam("acc", "report_cancels", 0) 
modparam("acc", "detect_direction",0)
modparam("acc", "extra_fields", "db: a->caller_id; b->callee_id") #Extra Data

and in routing section I have put following script

if (is_method("BYE")) {
    $acc_extra(a) = $fu;
    $acc_extra(b) = $tu;
    do_accounting("db","failed");

I just want that where call actually terminate, then I already have $avp(timestart) value so I can just deduct and calculate payments and use avp_db to insert CDRS

Kamal Panhwar
  • 2,345
  • 3
  • 21
  • 37

1 Answers1

1

Using OpenSIPS 2.2+, you can enable accounting only for established calls (200 OK + (endpoint BYE, dialog expiry or forced ending)) by specifying the cdr option of do_accounting() upon receiving the initial INVITE:

route {

    if (has_totag()) {
        ...
        exit;
    }

    ...

    if (is_method("INVITE"))
        do_accounting("db", "cdr");

    ...

    t_relay();
}
Liviu Chircu
  • 1,000
  • 3
  • 11
  • 24
  • I have added this, but still only acc table created with rows of Invite but nothing about bye, as to calculate call I need also Bye when call is terminated! – Kamal Panhwar Jun 01 '18 at 06:27
  • Indeed, there is only one entry per call, but it contains full info, as some fields are computed at BYE time -- for example: duration, ms_duration, setuptime, created. If this isn't enough for you, you will have to log all INVITEs and BYEs using `acc_db_request()`, and filter them in your external app. – Liviu Chircu Jun 04 '18 at 05:19