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