Moderators: gerski, enjay, williamconley, Op3r, Staydog, gardo, mflorell, MJCoate, mcargile, Kumba, Michael_N
if ($is_webphone = 'Y') {
$stmt = "SELECT srvs.server_ip, srvs.server_description, count(vla.server_ip) as live_agents_count
FROM vicidial_live_agents vla RIGHT JOIN servers srvs ON vla.server_ip = srvs.server_ip
GROUP BY srvs.server_ip
ORDER BY live_agents_count ASC LIMIT 1";
$sql = mysqli_query($stmt, $link);
$row = mysqli_fetch_row($sql);
$new_server_ip = $row[0];
$domain_name = $row[1];
$conf_override = "avpf=yes" . PHP_EOL;
$conf_override .= "encryption=yes" . PHP_EOL;
$conf_override .= "icesupport=yes" . PHP_EOL;
$conf_override .= "avpf=yes" . PHP_EOL;
$conf_override .= "nat=comedia" . PHP_EOL;
$conf_override .= "directmedia=no " . PHP_EOL;
$conf_override .= "dtlsenable=yes" . PHP_EOL;
$conf_override .= "dtlsverify=no " . PHP_EOL;
$conf_override .= "dtlscertfile=/etc/certbot/live/$domain_name/cert.pem" . PHP_EOL;
$conf_override .= "dtlsprivatekey=/etc/certbot/live/$domain_name/privkey.pem" . PHP_EOL;
$conf_override .= "dtlssetup=actpass" . PHP_EOL;
$stmt = "UPDATE phones SET active='Y', server_ip='$new_server_ip', conf_override='$conf_override' WHERE extension='$phone_login' ";
mysqli_query($stmt, $link);
$stmt = "UPDATE servers SET rebuild_conf_files = 'Y' WHERE active_asterisk_server = 'Y' ";
mysqli_query($stmt, $link);
$stmt = "SELECT server_description FROM servers WHERE active_asterisk_server = 'Y' ";
$sql = mysqli_query($stmt, $link);
while ($row = mysqli_fetch_row($sql)) {
$domain_name = $row[0];
$url = "https://$domain_name/conf_rebuild_phones.php";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);
curl_setopt($ch, CURLOPT_USERAGENT, 'dialer_agent');
curl_exec($ch);
curl_close($ch);
}
}
<?php
if ($_SERVER['HTTP_USER_AGENT'] == 'dialer_agent') {
exec("sudo /usr/share/astguiclient/ADMIN_keepalive_ALL.pl > /dev/null 2>/dev/null &");
}
?>
echo "wwwrun ALL=(ALL:ALL) NOPASSWD: /usr/share/astguiclient/ADMIN_keepalive_ALL.pl" >> /etc/sudoers
Invictus wrote:just write FQDNs to server description field in servers.
then if phone_login is set as webphone
in agc/vicidial.php
- Code: Select all
if ($is_webphone = 'Y') {
$stmt = "SELECT srvs.server_ip, srvs.server_description, count(vla.server_ip) as live_agents_count
FROM vicidial_live_agents vla RIGHT JOIN servers srvs ON vla.server_ip = srvs.server_ip
GROUP BY srvs.server_ip
ORDER BY live_agents_count ASC LIMIT 1";
$sql = mysqli_query($stmt, $link);
$row = mysqli_fetch_row($sql);
$new_server_ip = $row[0];
$domain_name = $row[1];
$conf_override = "avpf=yes" . PHP_EOL;
$conf_override .= "encryption=yes" . PHP_EOL;
$conf_override .= "icesupport=yes" . PHP_EOL;
$conf_override .= "avpf=yes" . PHP_EOL;
$conf_override .= "nat=comedia" . PHP_EOL;
$conf_override .= "directmedia=no " . PHP_EOL;
$conf_override .= "dtlsenable=yes" . PHP_EOL;
$conf_override .= "dtlsverify=no " . PHP_EOL;
$conf_override .= "dtlscertfile=/etc/certbot/live/$domain_name/cert.pem" . PHP_EOL;
$conf_override .= "dtlsprivatekey=/etc/certbot/live/$domain_name/privkey.pem" . PHP_EOL;
$conf_override .= "dtlssetup=actpass" . PHP_EOL;
$stmt = "UPDATE phones SET active='Y', server_ip='$new_server_ip', conf_override='$conf_override' WHERE extension='$phone_login' ";
mysqli_query($stmt, $link);
$stmt = "UPDATE servers SET rebuild_conf_files = 'Y' WHERE active_asterisk_server = 'Y' ";
mysqli_query($stmt, $link);
$stmt = "SELECT server_description FROM servers WHERE active_asterisk_server = 'Y' ";
$sql = mysqli_query($stmt, $link);
while ($row = mysqli_fetch_row($sql)) {
$domain_name = $row[0];
$url = "https://$domain_name/conf_rebuild_phones.php";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);
curl_setopt($ch, CURLOPT_USERAGENT, 'dialer_agent');
curl_exec($ch);
curl_close($ch);
}
}
create conf_rebuild_phones.php in every asterisk server in cluster;
- Code: Select all
<?php
if ($_SERVER['HTTP_USER_AGENT'] == 'dialer_agent') {
exec("sudo /usr/share/astguiclient/ADMIN_keepalive_ALL.pl > /dev/null 2>/dev/null &");
}
?>
in sudoers you need to give permission to apache to run keepalive script.
in ssh
- Code: Select all
echo "wwwrun ALL=(ALL:ALL) NOPASSWD: /usr/share/astguiclient/ADMIN_keepalive_ALL.pl" >> /etc/sudoers
mflorell wrote:Very ingenious solution to the multi-entry phone alias requirement there
Although the additional load from forcing a reloading of the conf files every time an agent logs in might in itself cause some issues on high-volume systems.
mflorell wrote:The only reason I mention it is that I have seen forced conf file reloading causing problems on a high-volume system. Not specifically your solution, but a client's custom code which forced reloads based upon custom IVR entries. The rapid forced reloads caused Asterisk to freeze sometimes when Asterisk was under high load.
Invictus wrote:just write FQDNs to server description field in servers.
then if phone_login is set as webphone
in agc/vicidial.php
- Code: Select all
if ($is_webphone = 'Y') {
$stmt = "SELECT srvs.server_ip, srvs.server_description, count(vla.server_ip) as live_agents_count
FROM vicidial_live_agents vla RIGHT JOIN servers srvs ON vla.server_ip = srvs.server_ip
GROUP BY srvs.server_ip
ORDER BY live_agents_count ASC LIMIT 1";
$sql = mysqli_query($stmt, $link);
$row = mysqli_fetch_row($sql);
$new_server_ip = $row[0];
$domain_name = $row[1];
$conf_override = "avpf=yes" . PHP_EOL;
$conf_override .= "encryption=yes" . PHP_EOL;
$conf_override .= "icesupport=yes" . PHP_EOL;
$conf_override .= "avpf=yes" . PHP_EOL;
$conf_override .= "nat=comedia" . PHP_EOL;
$conf_override .= "directmedia=no " . PHP_EOL;
$conf_override .= "dtlsenable=yes" . PHP_EOL;
$conf_override .= "dtlsverify=no " . PHP_EOL;
$conf_override .= "dtlscertfile=/etc/certbot/live/$domain_name/cert.pem" . PHP_EOL;
$conf_override .= "dtlsprivatekey=/etc/certbot/live/$domain_name/privkey.pem" . PHP_EOL;
$conf_override .= "dtlssetup=actpass" . PHP_EOL;
$stmt = "UPDATE phones SET active='Y', server_ip='$new_server_ip', conf_override='$conf_override' WHERE extension='$phone_login' ";
mysqli_query($stmt, $link);
$stmt = "UPDATE servers SET rebuild_conf_files = 'Y' WHERE active_asterisk_server = 'Y' ";
mysqli_query($stmt, $link);
$stmt = "SELECT server_description FROM servers WHERE active_asterisk_server = 'Y' ";
$sql = mysqli_query($stmt, $link);
while ($row = mysqli_fetch_row($sql)) {
$domain_name = $row[0];
$url = "https://$domain_name/conf_rebuild_phones.php";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);
curl_setopt($ch, CURLOPT_USERAGENT, 'dialer_agent');
curl_exec($ch);
curl_close($ch);
}
}
create conf_rebuild_phones.php in every asterisk server in cluster;
- Code: Select all
<?php
if ($_SERVER['HTTP_USER_AGENT'] == 'dialer_agent') {
exec("sudo /usr/share/astguiclient/ADMIN_keepalive_ALL.pl > /dev/null 2>/dev/null &");
}
?>
in sudoers you need to give permission to apache to run keepalive script.
in ssh
- Code: Select all
echo "wwwrun ALL=(ALL:ALL) NOPASSWD: /usr/share/astguiclient/ADMIN_keepalive_ALL.pl" >> /etc/sudoers
mflorell wrote:Very ingenious solution to the multi-entry phone alias requirement there
Although the additional load from forcing a reloading of the conf files every time an agent logs in might in itself cause some issues on high-volume systems.
if ($is_webphone == 'Y') {
$stmt = "SELECT srvs.server_ip, srvs.server_description, count(vla.server_ip) as live_agents_count
FROM vicidial_live_agents vla RIGHT JOIN servers srvs ON vla.server_ip = srvs.server_ip
GROUP BY srvs.server_ip
ORDER BY live_agents_count ASC LIMIT 1";
$sql = mysql_to_mysqli($stmt, $link);
$row = mysqli_fetch_row($sql);
echo "<!-- SQL Statement: {$stmt} " . print_r($row, true) . " -->";
$new_server_ip = $row[0];
$domain_name = $row[1];
$conf_override = "context=default" . PHP_EOL;
$conf_override .= "transport=ws,wss,udp" . PHP_EOL;
$conf_override .= "encryption=yes" . PHP_EOL;
$conf_override .= "icesupport=yes" . PHP_EOL;
$conf_override .= "avpf=yes" . PHP_EOL;
$conf_override .= "nat=comedia" . PHP_EOL;
$conf_override .= "directmedia=no " . PHP_EOL;
$conf_override .= "dtlsenable=yes" . PHP_EOL;
$conf_override .= "dtlsverify=no " . PHP_EOL;
$conf_override .= "dtlscertfile=/etc/certbot/live/$domain_name/cert.pem" . PHP_EOL;
$conf_override .= "dtlsprivatekey=/etc/certbot/live/$domain_name/privkey.pem" . PHP_EOL;
$conf_override .= "dtlssetup=actpass" . PHP_EOL;
$stmt = "UPDATE phones SET active='Y', server_ip='$new_server_ip', conf_override='$conf_override' WHERE
extension='$phone_login' ";
mysql_to_mysqli($stmt, $link);
$stmt = "UPDATE servers SET rebuild_conf_files = 'Y' WHERE active_asterisk_server = 'Y' ";
mysql_to_mysqli($stmt, $link);
$stmt = "SELECT server_description FROM servers WHERE active_asterisk_server = 'Y' ";
$sql = mysql_to_mysqli($stmt, $link);
while ($row = mysqli_fetch_row($sql)) {
$domain_name = $row[0];
$url = "https://$domain_name/conf_rebuild_phones.php";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);
curl_setopt($ch, CURLOPT_USERAGENT, 'dialer_agent');
curl_exec($ch);
curl_close($ch);
}
echo "<!-- >> Phone {$phone_login} moved to server: {$domain_name} with ip: {$new_server_ip} -->";
}
vkad wrote:Having issues with the script guys "reg failed" showing on these servers on webrtc after login.
Thanks
Invictus wrote:vkad wrote:Having issues with the script guys "reg failed" showing on these servers on webrtc after login.
Thanks
did you create conf_rebuild_phones.php file on each server? did you give sudo permissions to apache2?
mflorell wrote:The only reason I mention it is that I have seen forced conf file reloading causing problems on a high-volume system. Not specifically your solution, but a client's custom code which forced reloads based upon custom IVR entries. The rapid forced reloads caused Asterisk to freeze sometimes when Asterisk was under high load.
Users browsing this forum: No registered users and 100 guests