Server Status "Error" for Asterisk

Hi all!

This is my first message on the forum.

I recently upgraded Asterisk. I was using Certified Asterisk 11.6-cert1 and now I am using Certified Asterisk 11.6-cert13. The FreePBX version I am currently using is the same that I was using before doing the Asterisk upgrade: FreePBX 2.11.0.43.

Asterisk seems to run smoothly. However, FreePBX shows ERROR for Asterisk Server Status. I was reviewing the log in /var/log/asterisk/freepbx.log:

root@asterisk:/var/log/asterisk# grep CRITICAL freepbx.log
[2016-Feb-21 13:07:42] [CRITICAL] (admin/bootstrap.php:122) - Connection attmempt to AMI failed
[2016-Feb-21 13:07:50] [CRITICAL] (admin/bootstrap.php:122) - Connection attmempt to AMI failed
[2016-Feb-21 13:28:44] [CRITICAL] (admin/bootstrap.php:122) - Connection attmempt to AMI failed
[2016-Feb-21 14:43:24] [CRITICAL] (admin/bootstrap.php:122) - Connection attmempt to AMI failed
[2016-Feb-21 14:44:03] [CRITICAL] (admin/bootstrap.php:122) - Connection attmempt to AMI failed
[2016-Feb-21 16:58:31] [CRITICAL] (admin/bootstrap.php:122) - Connection attmempt to AMI failed
[2016-Feb-21 17:09:14] [CRITICAL] (admin/bootstrap.php:122) - Connection attmempt to AMI failed
[2016-Feb-21 17:09:16] [CRITICAL] (admin/bootstrap.php:122) - Connection attmempt to AMI failed
[2016-Feb-21 17:09:21] [CRITICAL] (admin/bootstrap.php:122) - Connection attmempt to AMI failed

Is it possible that this error in Asterisk server status is because of this?

The strange thing is I have a plugin for Nagios which makes a check on the registration status of a SIP trunk through AMI, and this plugin is running smoothly after the Asterisk upgrade.

Thanks in advance for your replies.

Kind regards,
Daniel

Hi again.

To add some more of information, I am also observing this error:

root@asterisk:/space/www# /var/lib/asterisk/bin/retrieve_conf
found language dir fr for directory, not installed on system, skipping
[FATAL] retreive_conf failed to get engine information and cannot configure up a softwitch with out it. Error: ERROR-UNABLE-TO-PARSE

According to what I read in the FreePBX Issue tracker [1], it seems that this error occurs because FreePBX does not recognize the version of Asterisk. Although my version of FreePBX does not have any way to force the Asterisk version.

Can this “FATAL” error be related to the problem of server status? I found also this error when I try to apply some change on the FreePBX GUI.

I would appreciate any help.

Thanks.

Best regards,
Daniel

[1] http://issues.freepbx.org/browse/FREEPBX-9225

Hi again!

Well, it seems that the previous problem was related to the way in which Asterisk version is identified. It seems that FreePBX 2.11.0.43 is not able to identify this type of identification of Asterisk:

root@asterisk:~# asterisk -V
Asterisk certified/11.6-cert13

So I added the following lines in /var/www/freepbx/admin/functions.inc.php:

} elseif (preg_match('/Asterisk certified\/(\d+(\.\d+)*)(-?(\S*))/', $verinfo, $matches)) {

$engine_info = array('engine'=>'asterisk', 'version' => $matches[1], 'additional' => $matches[4],
'raw' => $verinfo);

$gotinfo = true;

After applying the change and reload the website, the Server Status for Asterisk changed to “OK”. So it’s great! It’s weird because I did not do any update to FreePBX; I just updated the version of Asterisk. So it seems that Certified Asterisk 11.6-cert1 (the version I was using before updating) would be identified so that FreePBX could recognize it.

However, although the Asterisk Server Status changed to “OK” on the website, when manually run the command retrieve_conf, I keep getting an error:

root@asterisk:~# /var/lib/asterisk/bin/retrieve_conf --debug
Checking for PEAR Console::Getopt..OK
found language dir fr for directory, not installed on system, skipping
[FATAL] retreive_conf failed to get engine information and cannot configure up a softwitch with out it. Error: asterisk

Before to fix the error on the Server Status of Asterisk, I had tried to install on FreePBX the “FreePBX Upgrader” module to upgrade to a newer version of FreePBX assuming that this was prepared to deal with this identification problem I was having. But although the module was downloaded, the installation of it was not effective given that was pending press on the “Apply Config” button. The issue is that when I tried to do it, it failed.

Now that I do not get the Server Status error, I tried again by pressing the “Apply Config” button but I get the following error:

Reload failed because retrieve_conf encountered an error: 1

exit: 1
found language dir fr for directory, not installed on system, skipping
[FATAL] retreive_conf failed to get engine information and cannot configure up a softwitch with out it. Error: asterisk

1 error(s) occurred, you should view the notification log on the dashboard or main screen to check for more details.

That is, the same error I mentioned above, when manually run the script. Reviewing in /var/log/asterisk/freepbx.log, I found something like this after to press on “Apply Config”:

[2016-Mar-07 19:41:34] [INFO] (bin/retrieve_conf:110) - found language dir fr for directory, not installed on system, skipping 
[2016-Mar-07 19:41:34] [FATAL] (libraries/utility.functions.php:443) - retreive_conf failed to get engine information and cannot configure up a softwitch with out it. Error: asterisk 
[2016-Mar-07 19:41:35] [CRITICAL] (admin/functions.inc.php:386) - [NOTIFICATION]-[freepbx]-[RCONFFAIL] - retrieve_conf failed, config not applied (Reload failed because retrieve_conf encountered an error: 1)

So I was watching what we have in the mentioned lines for FATAL and CRITICAL type errors. This is what I found:

For admin/functions.inc.php (I copy a few more lines, to get an idea from where comes that exit_val).

360         $exit_val = null;
361 
362         if ($setting_pre_reload)  {
363                 exec( $setting_pre_reload, $output, $exit_val );
364 
365                 if ($exit_val != 0) {
366                         $desc = sprintf(_("Exit code was %s and output was: %s"), $exit_val, "\n\n".implode("\n",$output));
367                         $notify->add_error('freepbx','reload_pre_script', sprintf(_('Could not run %s script.'), $setting_pre_reload), $desc);
368 
369                         $return['num_errors']++;
370                 } else {
371                         $notify->delete('freepbx', 'reload_pre_script');
372                 }
373         }
374 
375         $retrieve = $setting_ampbin . '/retrieve_conf 2>&1';
376         //exec($retrieve.'&>'.$asterisk_conf['astlogdir'].'/freepbx-retrieve.log', $output, $exit_val);
377         exec($retrieve, $output, $exit_val);
378 
379         // retrieve_conf html output
380         $return['retrieve_conf'] = 'exit: '.$exit_val.'<br/>'.implode('<br/>',$output);
381 
382         if ($exit_val != 0) {
383                 $return['status'] = false;
384                 $return['message'] = sprintf(_('Reload failed because retrieve_conf encountered an error: %s'),$exit_val);
385                 $return['num_errors']++;
386                 $notify->add_critical('freepbx','RCONFFAIL', _("retrieve_conf failed, config not applied"), $return['message']);
387                 return $return;
388         }

The line 443 on the admin/libraries/utility.functions.php file does not say much. It appears to be a function to record on a log:

440 function fatal($text,$log=true) {
441         echo "[FATAL] ".$text.EOL;
442         if ($log) {
443                 freepbx_log(FPBX_LOG_FATAL,$text);
444         }
445         exit(1);
446 }

I appreciate if someone could help me with this.

Thanks in advance.

Kind regards,
Daniel