How to limit the total time to a trunk?

I’m very new to asterisk, I would like to cut my mobile bill routing all calls through asterisk connetted to a gsm gateway with a monthly flat minutes tarif by a fxo port.

This is a 2 part problem.


[li] Routing Calls
[li] Checking if I’m exceeding the free monthly minutes and eventually drop the call or set a message that the monthly credit is over [/li][/ol]

The first part (routing calls) is quite easy and I know that is possible, but how is it possible to set asterisk to check if I’m exceeding my monthly time credit?

Any help is greatly appreciated