How to increase performance on asterisk servers
Posted: Sun Jul 15, 2012 3:10 am
Run the AST_update.pl scritps on a seperate server.. pissibly the server that runs AST_VDauto_dial.pl runs on or maybe the database server.
You can have the keep_alive scrript look through the servers table and use them to create and maintain the AST_update.pl processes. this way you can keep the load down on the asterisk servers to handle more calls =)
example snippets:
You can have the keep_alive scrript look through the servers table and use them to create and maintain the AST_update.pl processes. this way you can keep the load down on the asterisk servers to handle more calls =)
example snippets:
- Code: Select all
use DBI;
$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass")
or die "Couldn't connect to database: " . DBI->errstr;
my @server_list;
my $server_list_count = 0;
### Grab all server to run AST_update.pl on
$stmtA = "SELECT server_ip FROM servers where server_ip != '$VARserver_ip' and server_description not like \"%master%\";";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$rec_count=0;
while ($sthArows > $rec_count)
{
@aryA = $sthA->fetchrow_array;
$server_list[$rec_count]= $aryA[0];
$rec_count++;
}
$sthA->finish();
- Code: Select all
$i=0;
foreach (@psoutput)
{
chomp($psoutput[$i]);
if ($DBX) {print "$i|$psoutput[$i]| \n";}
@psline = split(/\/usr\/bin\/perl /,$psoutput[$i]);
$server_list_count = 0;
foreach (@server_list)
{
if ($psline[1] =~ /$REGhome\/AST_update\.pl $server_list[$server_list_count]/)
{
undef $server_list[$server_list_count];
if ($DB) {print "AST_update $server_list[$server_list_count] RUNNING: |$psline[1]|\n";}
}
$server_list_count++;
}
if ($psline[1] =~ /$REGhome\/AST_manager_send_hangup\.pl/)
{
$runningAST_send_hangup++;
if ($DB) {print "AST_send_hangup RUNNING: |$psline[1]|\n";}
}
.....
- Code: Select all
@psoutput2 = `/bin/ps -o "%p %a" --no-headers -A`;
$i=0;
foreach (@psoutput2)
{
chomp($psoutput2[$i]);
if ($DBX) {print "$i|$psoutput2[$i]| \n";}
@psline = split(/\/usr\/bin\/perl /,$psoutput2[$i]);
$server_list_count = 0;
foreach (@server_list)
{
if ($psline[1] =~ /$REGhome\/AST_update\.pl $server_list[$server_list_count]/)
{
undef $server_list[$server_list_count];
if ($DB) {print "AST_update $server_list[$server_list_count] RUNNING: |$psline[1]|\n";}
}
}
- Code: Select all
$server_list_count = 0;
foreach (@server_list)
{
$server_list[$server_list_count];
if ($DB) {print "starting AST_update on server $server_list[$server_list_count]...\n";}
if($AST_update > 0)
{
`/usr/bin/screen -d -m -S $server_list[$server_list_count] $PATHhome/AST_update.pl $server_list[$server_list_count]`;
}
$server_list_count++;
}
if ( ($AST_send_listen > 0) && ($runningAST_send_hangup < 1) )
{
#if ($DB) {print "starting AST_manager_send_hangup...\n";}
# add a '-L' to the command below to activate logging
`/usr/bin/screen -d -m -S ASTsend_hangup $PATHhome/AST_manager_send_hangup.pl`;
}