Page 1 of 1

Max Trunks on the basis of vicidial_auto_calls is faulty

PostPosted: Tue Jun 05, 2012 6:21 am
by marmu
Hi guys,

I just want to let you know that we wondered about vicidial needing more trunks than our previous dialer. We found the following mistake in the calculation of used trunks within vicidial. I don't know if that is still present in the current vicidial version, in our it is.
In AST_VDauto_dial.pl:
Code: Select all
$stmtA = "SELECT count(*) FROM vicidial_auto_calls where server_ip='$server_ip' and status IN('SENT','RINGING','LIVE','XFER','CLOSER','IVR');";

is used to calculated the used channels. We compared that to the number of channels from "sip show channels" on the CLI and the difference ranged from 30-80 channels. In a nutshell: Vicidial thought it was using up to 80 channels more than were actually used. Now we calculate that number based on "sip show channels" and are much much more productive.

"PATCH" idea using "Asterisk::AMI":
Code: Select all
use Asterisk::AMI;
my $astmgr = Asterisk::AMI->new(PeerAddr => 'xxx.xxx.xxx.xxx', PeerPort => 'xxxxxx',
                                Username => 'user', Secret   => 'secret'
                               ) or die "Unable to connect to asterisk";
#
# ip's of the carriers used. They are used to determine the
# count of channels which are currently in call.
#
my @carrierips = ("xxx.xxx.xxx.xxx", "xxx.xxx.xxx.xxx");
#
# function to determine active phone lines per campaign
#    returns e.g.  {5067 => 32, 6025 => 97, total => 129}
sub getCarrierStatus($$) {
    my ($astmgr, $dbh) = @_;

    my $peerip;
    my $number;
    my @numbers = ();
    my $result;
    my $line;
    my %rethash;
    my $stmt;
    my $sth;
    my $vdm;
    my $count;
    my $campaign;
    my $total = 0;

    #
    # send 'sip show channels' to asterisk
    #
    $result = $astmgr->action({Action  => 'Command',
                                   Command => 'sip show channels'});
    foreach $line (@{$result->{CMD}}) {
        if ($line =~ m/(\d+\.\d+\.\d+\.\d+)\s+98(\d+)\s+/) {
            $peerip = $1;
            $number = $2;
            if ($peerip ~~ @carrierips) {
                push(@numbers, $number);
            }
        }
    }
    if (scalar(@numbers) > 0) {
        $stmt = "SELECT count(*) as cnt,campaign_id FROM vicidial_auto_calls where phone_number IN('" . join("','", @numbers) . "') group by campaign_id";
        $sth = $dbh->prepare($stmt) or die "preparing: ",$dbh->errstr;
        $sth->execute or die "executing: $stmt ", $dbh->errstr;

        while ($vdm = $sth->fetchrow_hashref) {
            $count = $vdm->{cnt};
            $campaign = $vdm->{campaign_id};
            $rethash{$campaign} = $count;
            $total += $count;
        }
        $rethash{total} = $total;
    }
    return %rethash;
}


Comment out the select statement mentioned above and use the new sub routine like that:
Code: Select all
my %astchannels = getCarrierStatus($astmgr, $dbhA);
$active_line_counter = $astchannels{total};


Hopefully this will help you get the most out of vicidial :)

Cheers,
Marcus

Re: Max Trunks on the basis of vicidial_auto_calls is faulty

PostPosted: Tue Jun 05, 2012 9:56 am
by mflorell
I have no idea how you ended up with that kind of difference based upon the information in mention here. We haven't seen these kind of problems on our systems that we have installed.

Re: Max Trunks on the basis of vicidial_auto_calls is faulty

PostPosted: Wed Jun 06, 2012 3:11 am
by marmu
have you ever compared the values from AST_VDauto_dial.pl with the ones from "sip show channels" on a running system? I can only tell you that we were about to order 30-60 more ISDN lines from our carrier and now we don't have to. The system works way better now. Perhaps others got that problem too, I don't know, I can only speak for our setup. But good to know that we might be the only ones having this kind of problem.

Re: Max Trunks on the basis of vicidial_auto_calls is faulty

PostPosted: Wed Jun 06, 2012 6:26 am
by mflorell
Vicidial pulls it's call counts from vicidial_auto_calls, and if those are not accurate then there is probably something else going on with your system in terms of something configured improperly.

Re: Max Trunks on the basis of vicidial_auto_calls is faulty

PostPosted: Thu Jun 07, 2012 5:10 am
by marmu
hi matt,

my colleague said yesterday, that I can't say it is faulty. It is (kind of) correct but to delayed for the best utilization of the available channels. At least that is what we found out in our installation. I can't think of any misconfiguration, is there a common mistake we might have done?

All the best,
Marcus