Max call duration

Hello,

I want to let asterisk allow a maximum of “x duration” (say 1000 min) via the sip trunk each day. Can this be achieved via asterisk? I am running asterisk 16.30.1

Any suggestions?

you can using func_odbc y cdr table. For each call count the duration of all calls using the trung using a query to the cdr table and if the values is more than 60000 seconds, reject the call.

Regards

Asterisk 16.30.1 is over a month beyond end of life.

“Trunk” is not a term used by SIP or Asterisk, but tends to imply multiple simultaneous calls. The only hard limits that Asterisk dialplan can impose are on individual calls, so, as well as having to count up how much you had used before the start of the call, probably by trawling the CDR files, you would have set a lower limit on calls, and refuse calls when all the current calls would, if using the full limit, take you over your aggregate limit.

To actually cut all calls in progress when the limit is reached, you would have to monitor them with something like AMI.

One way or another, there isn’t an overall mechanism for doing this and you will need to put together cumulative usage figures from lower level data.

As you don’t want real-time data, I won’t use AMI in this case. I suggest getting the sum using the CDR billsec value before allowing a call using that trunk.

The problem comes if more than one caller wants to use the trunk. You have to reserve time for the first caller. If you give them all the remaining time, you can’t give any other caller any time at all, so you basically have to limit the endpoint to one call at a time. Even if you give them a reasonable amount of time, when you are coming to the end of the day’s allocation, you may end up having to refuse calls that would actually have succeeded, because the other calls didn’t actually use their full allowance.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.