Limit monthly outbound calls with AGI script

Good day,

I have an agi script that limits the total minutes a user is able to dial out per month. The script stopped working 2 months or so ago (possibly from an update or accidental change).

My questions are:

  1. How do I check if the extension is executing the AGI script? I do not see the agi script called billsec.php beign triggered on outbound calls so where would I need to check this?

  2. Please review AGI script, maybe there are something silly like a typo (I doubt but you never know) and if the AGI script is setup correctly

    #!/usr/bin/php -q
    $username = "root";
    $password = "st1nk13";
    $hostname = "localhost";

    //connection to the database
    $dbhandle = mysql_connect($hostname, $username, $password)
     or die("Unable to connect to MySQL");

    $selected = mysql_select_db("asteriskcdrdb",$dbhandle)
      or die("Could not select examples");

    $ext = $argv[1];
    $agi = new AGI();
    //$agi -> answer();

    $MONTH=date("m"); //we just need the moth for now.

    if ($ext != 728) {

    $agi->verbose("No Limit Set for Extension");

    $query = mysql_query("SELECT sum(billsec) AS totalminute from cdr WHERE disposition = 'ANSWERED' AND dst like '0%' and src='$ext' and month(calldate) = $MONTH and year(calldate) = $YEAR LIMIT 1");

    if ($query) {

    if($row = mysql_fetch_array($query)) {


    if($row['totalminute']>16800) {


Thank you for the edit

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