Fusionpbx device register – multiple device register

PhoneLite, register method 1
PhoneLite register method 2

the domain DNS must be the IP adress of fusionpbx

the softphone public IP need to be allowed in iptables

Multiple device register: Advanced -> sip profile -> edit internal

Status -> sip status -> (check rescan + restart) sip profile
# monitor device register, /home/wu/monitor_extension.php
# monitor fusionpbx extension registered
#*/5 * * * *  /usr/bin/php /home/wu/monitor_extension.php 8xxxxx.voipit.space 107 >> /dev/null 2>&1

 $argv[1]
);

/*******************************************
****** DO NOT EDIT BELOW THIS LINE *******
******************************************/

// Function to check extension registration status
function checkExtn($ext, $tenant){
    global $fscli;
    // $ext_tenant = $ext."@".$tenant;
    // $command = $fscli . ' -x "sofia status profile internal reg ' . $ext .'"' . " grep ". $tenant;
    // /usr/bin/fs_cli -x "sofia status profile internal user 101@8452639754.voipit.space " |grep "Ping-Status"
    $command = $fscli . ' -x "sofia status profile internal user ' . $ext . "@" . $tenant . '"';
print $command."\n";

    $res = shell_exec($command);
    $regex = '/returned:\s(\d+)/';
    preg_match($regex, $res, $matches);

    if($matches[1] > 0) {
        return true;
    }else {
        return false;
    }
}

// Function to send email
function sendMail($msg){
    global $fromname, $mailfrom, $mailsub, $mailto;
    // Format from name
    $from = $fromname . "\<" . $mailfrom . "\>";
    // Email command line
    $recipe = 'echo "%s" | mail -a "Content-Type: text/html" -s "%s" -aFrom:%s "%s"';
    // Format email command
    $cooked = sprintf($recipe,$msg,$mailsub,$from,$mailto);
print "\n";
print $cooked."\n";

    // Send email
    shell_exec($cooked);
}

// Function to check whether FreeSWITCH is running
function checkFS(){
    $fs = trim(shell_exec('pidof "freeswitch"'));
    if(! strlen($fs)){
        return false;
    }else{
         return true;
    }
}

// Set global variable to collect messages
$msg = "";
/* Check if FS is running; restart if it isn't
if(! checkFS()){
    $msg .= "FreeSWITCH isn't running, trying a service restart... 
"; $msg .= shell_exec('systemctl restart freeswitch.service'); sleep(5); if(! checkFS()){ $msg .= "
FreeSWITCH wouldn't start; exiting...
"; sendMail($msg); exit; }else{ $msg .= "
FreeSWITCH is running...
"; sleep(60); } } */ // Iterate through nominated extensions for registration status foreach($extensions as $ext => $tenant){ if(! checkExtn($ext, $tenant)) { if(strlen(trim($tenant))) { $tenant = ', ' . $tenant; } print $ext."\n"; sendMail($msg . 'Your phone ' . $ext . ' is offline; please check connectivity.', $tenant); } } ?>