Запускается второй астериск
Помогите, не мог понять в чем причина.
Во время работы поднимается еще один процесс астериска, тут же съедает все свободные ресурсы у процессора. Есть подозрение на agi. В логах ничего не нашел.
extensions.conf:
[balance-say]
exten => s,1, Noop(${NUMBER})
exten => s,n, agi,balance.agi|${NUMBER}
exten => s,n, GotoIf($[${ID}<=0]?ivr-balance-notfound,s,1:say)
exten => s,n(say), Set(CHANNEL(language)=ru)
exten => s,n, GotoIf($[${SIGN}<=0]?say_debt:say_is)
exten => s,n(say_debt), Playback(ivr/balance-say/debt)
exten => s,n, Goto(s,say_num)
exten => s,n(say_is), Playback(ivr/balance-say/is)
exten => s,n(say_num), Playback(rubl:${RUB}|say)
exten => s,n, Playback(kopeyka:${KOP}|say)
exten => s,n, Goto(ivr-mainmenu,s,1)
balance.agi:
#!/usr/bin/perl
use DBI;
use POSIX qw(floor ceil);
$|=1;
$DB_HOST="xxx.xxx.xxx.xxx";
$DB_USER='user';
$DB_PASSWORD='password';
$DB_SID="data";
$ENV{ORACLE_HOME}="/usr/local/oracle8-client";
$ENV{NLS_LANG}="American_America.Cl8MsWin1251";
$ENV{ORA_NLS33}="/usr/local/oracle8-client/ocommon/nls/admin/data";
my($FG_AGR_ID) = 'cc_asterisk_funcs.get_agreement_id_by_number';
my($FG_BAL) = 'excellent.balance_support.get_balance_with_deposit';
my($agr_num) = 166777;#'166777'
my($agr_id) = 0;
my($balance) = 0;
my($rub) = 0;
my($kop) = 0;
my($sign) = 0;
my(%AGI);
# setup folders
$agr_num = $ARGV[0];
print "Verbose(Hello world!!!($agr_num 1)\n";
my($dbh) = DBI->connect("dbi:Oracle:host=$DB_HOST;sid=$DB_SID;port=1521",
$DB_USER,$DB_PASSWORD,{PrintError=>0,AutoCommit=>0,RaiseError=>1})
or die "Couldnot connect to Oracle:$DBI::errstr\n";
$agr_id = get_agreement_id($dbh,$agr_num);
if ($agr_id > 0) {$balance = get_balance($dbh,$agr_id);} else {$balance = 0;}
$rub = floor(abs($balance));
$kop = floor((abs($balance) - $rub)*100);
if ($balance >= 0) {$sign = 1;} else {$sign=-1;}
print 'The balance of agreement with number '.$agr_num.'('.$agr_id.') is '.$balance."\n";
print 'SET VARIABLE ID '.$agr_id."\n";
print 'SET VARIABLE SIGN '.$sign."\n";
print 'SET VARIABLE RUB '.abs($rub)."\n";
print 'SET VARIABLE KOP '.abs($kop)."\n";
$dbh->disconnect;
exit(0);
sub get_agreement_id{
my($ldbh) = shift;
my($number) = shift;
my($id) = 0;
$sth=$ldbh->prepare('select '.$FG_AGR_ID.'(:agr_num) from dual');
$sth->bind_param( ':agr_num', $number, { TYPE => SQL_VARCHAR } );
$sth->execute();
$id = $sth->fetchrow_array;
$sth->finish();
return $id;
}
sub get_balance {
my($ldbh) = shift;
my($id) = shift;
my($bal) = 0;
$sth=$ldbh->prepare('select '.$FG_BAL.'(:agr_id) from dual');
$sth->bind_param( ':agr_id', $agr_id, { TYPE => SQL_VARCHAR } );
$sth->execute();
$bal = $sth->fetchrow_array;
$sth->finish();
return $bal;
}
sub check_result {
my ($res) = @_;
my $retval;
chomp $res;
if ($res =~ /^200/) {
$res =~ /result=(-?\d+)/;
if (!length($1)) {
print STDERR "FAIL ($res)\n";
$fail++;
}
else {
print STDERR "PASS ($1)\n";
$pass++;
}
}
else {
print STDERR "FAIL (unexpected result '$res')\n";
$fail++;
}
}
|