From bfeb9e4785d7accfd5e7f20b43ec5e57d00009e0 Mon Sep 17 00:00:00 2001 From: PhantomVl Date: Wed, 9 Jan 2019 16:29:24 +0300 Subject: [PATCH] Bug fix. - fix bug on install realtime. - Add realtime diagmostic. --- Sccp_manager.class.php | 1 + Sccp_manager.inc/extconfigs.class.php | 76 ++++++++++++++++++++++++- Sccp_manager.inc/srvinterface.class.php | 19 ++++++- Sccp_manager.inc/xmlinterface.class.php | 2 +- install.php | 5 +- views/server.info.php | 42 +++++++++++++- 6 files changed, 136 insertions(+), 9 deletions(-) diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index fbabba6..245e17b 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -92,6 +92,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { private $SCCP_LANG_DICTIONARY = 'be-sccp.jar'; // CISCO LANG file search in /tftp-path private $pagedata = null; private $sccp_driver_ver = '11.3'; + public $sccp_manager_ver = '13.0.0.4'; private $tftpLang = array(); // private $hint_context = '@ext-local'; /// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Get it from Config !!! private $hint_context = array('default' => '@ext-local'); /// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Get it from Config !!! diff --git a/Sccp_manager.inc/extconfigs.class.php b/Sccp_manager.inc/extconfigs.class.php index f632e46..5abcbcc 100644 --- a/Sccp_manager.inc/extconfigs.class.php +++ b/Sccp_manager.inc/extconfigs.class.php @@ -14,7 +14,7 @@ class extconfigs { } public function info() { - $Ver = '13.0.2'; + $Ver = '13.0.3'; return Array('Version' => $Ver, 'about' => 'Default Setings and Enums ver: ' . $Ver); } @@ -349,5 +349,79 @@ class extconfigs { return $base_config; } + + public function validate_RealTime() { + global $amp_conf; + $res = Array(); + + $cnf_int = \FreePBX::Config(); + $cnf_wr = \FreePBX::WriteConfig(); + $cnf_read = \FreePBX::LoadConfig(); + $def_config = array('sccpdevice' => 'mysql,sccp,sccpdeviceconfig', 'sccpline' => ' mysql,sccp,sccpline'); + $def_bd_config = array('dbhost' => $amp_conf['AMPDBHOST'], 'dbname' => $amp_conf['AMPDBNAME'], + 'dbuser' => $amp_conf['AMPDBUSER'], 'dbpass' => $amp_conf['AMPDBPASS'], + 'dbport' => '3306', 'dbsock' => '/var/lib/mysql/mysql.sock'); + $def_bd_sec = 'sccp'; + + $dir = $cnf_int->get('ASTETCDIR'); + $res_conf_sql = ini_get('pdo_mysql.default_socket'); + $res_conf_old = ''; + $res_conf = ''; + $ext_conf = ''; + + if (file_exists($dir . '/extconfig.conf')) { + $ext_conf = $cnf_read->getConfig('extconfig.conf'); + if (empty($ext_conf['settings']['sccpdevice'])) { + $res['extconfig'] = ' Options "Sccpdevice" not config '; + } + if (empty($ext_conf['settings']['sccpline'])) { + $res['extconfig'] .= ' Options "Sccpline" not config '; + } + if (empty($res['extconfig'])) { + $res['extconfig'] = 'OK'; + } + } else { + $res['extconfig'] = 'File extconfig.conf not exist'; + } + + if (!empty($res_conf_sql)) { + if (file_exists($res_conf_sql)) { + $def_bd_config['dbsock'] = $res_conf_sql; + } + } + if (file_exists($dir . '/res_mysql.conf')) { + $res_conf = $cnf_read->getConfig('res_mysql.conf'); + if (empty($res_conf[$def_bd_sec])) { + $res['mysqlconfig'] = 'Not Config in file: res_mysql.conf'; + } else { + if ($res_conf[$def_bd_sec]['dbsock'] != $def_bd_config['dbsock']) { + $res['mysqlconfig'] = 'Mysql Soket Error in file: res_mysql.conf'; + } + } + if (empty($res['mysqlconfig'])) { + $res['mysqlconfig'] = 'OK'; + } + } + if (file_exists($dir . '/res_config_mysql.conf')) { + $res_conf = $cnf_read->getConfig('res_config_mysql.conf'); + if (empty($res_conf[$def_bd_sec])) { + $res['mysqlconfig'] = 'Not Config in file: res_config_mysql.conf'; + } else { + if ($res_conf[$def_bd_sec]['dbsock'] != $def_bd_config['dbsock']) { + $res['mysqlconfig'] = 'Mysql Soket Error in file: res_config_mysql.conf'; + } + } + if (empty($res['mysqlconfig'])) { + $res['mysqlconfig'] = 'OK'; + } + + } + if (empty($res['mysqlconfig'])) { + $res['mysqlconfig'] = 'Realtime Error: not found res_config_mysql.conf or res_mysql.conf configutation on the path :'. $dir ; + } + return $res; +} + + } diff --git a/Sccp_manager.inc/srvinterface.class.php b/Sccp_manager.inc/srvinterface.class.php index bac7c6c..c6a09f5 100644 --- a/Sccp_manager.inc/srvinterface.class.php +++ b/Sccp_manager.inc/srvinterface.class.php @@ -28,7 +28,7 @@ class srvinterface { } public function info() { - $Ver = '13.0.2'; + $Ver = '13.0.3'; return Array('Version' => $Ver, 'about' => 'Server interface data ver: ' . $Ver); } @@ -52,6 +52,7 @@ class srvinterface { 'reset_phone' => array('cmd' => "sccp reset ", 'param' => 'name'), // Жесткая перезагрузка 'reload_phone' => array('cmd' => "sccp reload device ", 'param' => 'name'), 'reset_token' => array('cmd' => "sccp tokenack ", 'param' => 'name'), + 'get_realtime_status' => array('cmd' => "realtime mysql status", 'param' => ''), ); $result = true; if (!empty($params['cmd'])) { @@ -174,6 +175,22 @@ class srvinterface { return $ast_key; } + public function sccp_realtime_status() { + $ast_res = array(); + $ast_out = $this->sccp_core_commands(array('cmd'=>'get_realtime_status')); + $ast_out = preg_split("/[\n]/", $ast_out['data']); + if (strpos($ast_out[0], 'Privilege') !== false){ + $ast_out[0] = ""; + } + foreach ($ast_out as $line) { + if (strlen($line) > 3) { + $ast_key = strstr(trim($line), ' ', true); + $ast_res[$ast_key] = array('message' => $line, 'status'=> strpos($line, 'connected') ? 'OK' : 'ERROR'); + } + } + return $ast_res; + } + // !TODO!: -TODO-: install.php is still using the other version number. This is actually where I use another method ? diff --git a/Sccp_manager.inc/xmlinterface.class.php b/Sccp_manager.inc/xmlinterface.class.php index ce44a20..b0d2e1e 100644 --- a/Sccp_manager.inc/xmlinterface.class.php +++ b/Sccp_manager.inc/xmlinterface.class.php @@ -22,7 +22,7 @@ class xmlinterface { } public function info() { - $Ver = '13.0.2'; + $Ver = '13.0.3'; return Array('Version' => $Ver, 'about' => 'Create XML data interface ver: ' . $Ver); } diff --git a/install.php b/install.php index f60af3d..a1b1147 100644 --- a/install.php +++ b/install.php @@ -656,7 +656,6 @@ function Setup_RealTime() { $dir = $cnf_int->get('ASTETCDIR'); $res_conf_sql = ini_get('pdo_mysql.default_socket'); - $res_conf_old = ''; $res_conf = ''; $ext_conf = ''; if (file_exists($dir . '/extconfig.conf')) { @@ -698,14 +697,14 @@ function Setup_RealTime() { } if (file_exists($dir . '/res_config_mysql.conf')) { $res_conf = $cnf_read->getConfig('res_config_mysql.conf'); - if (empty($res_conf_old[$def_bd_sec])) { + if (empty($res_conf[$def_bd_sec])) { $res_conf[$def_bd_sec] = $def_bd_config; } $cnf_wr->writeConfig('res_config_mysql.conf', $res_conf, false); } if (empty($res_conf)) { $res_conf[$def_bd_sec] = $def_bd_config; - $res_conf['general']['dbsock'] = $def_bd_config['dbsock']; +// $res_conf['general']['dbsock'] = $def_bd_config['dbsock']; $cnf_wr->writeConfig('res_config_mysql.conf', $res_conf, false); } $cnf_wr->writeConfig('extconfig.conf', $ext_conf, false); diff --git a/views/server.info.php b/views/server.info.php index 9187bfe..6d92deb 100644 --- a/views/server.info.php +++ b/views/server.info.php @@ -11,6 +11,8 @@ $driver = $this->FreePBX->Core->getAllDriversInfo(); $core = $this->srvinterface->getSCCPVersion(); +$ast_realtime = $this->srvinterface->sccp_realtime_status(); +$conf_realtime = $this->extconfigs->validate_RealTime(); $info = array(); $info['srvinterface'] = $this->srvinterface->info(); $info['extconfigs'] = $this->extconfigs->info(); @@ -35,16 +37,50 @@ if (!empty($this->sccpvalues['SccpDBmodel'])) { $info['Сompatible']['about'] = '
Reinstall SCCP manager required
'; } } +if (empty($ast_realtime)) { + $info['RealTime'] = array('Version' => 'Error', 'about'=> '
No found Real Time connections
'); +} else { + $rt_info = ''; + $rt_sccp = 'Failed'; + foreach ($ast_realtime as $key => $value) { + if ($key == 'sccp') { + if ($value['status'] == 'OK') { + $rt_sccp = 'TEST OK'; + $rt_info .= 'SCCP conettions found'; + } else { + $rt_sccp = 'SCCP ERROR'; + $rt_info .= '
Error : '. $value['message']. '
'; + } + } else if ($value['status'] == 'ERROR') { + $rt_info .= '
Found error in realtime sectoin ['.$key.'] : '. $value['message']. '
'; + } + } + $info['RealTime'] = array('Version' => $rt_sccp, 'about'=> $rt_info); +} +if (empty($conf_realtime)) { + $info['ConfigsRealTime'] = array('Version' => 'Error', 'about'=> '
No found Real Time Configs
'); +} else { + $rt_info = ''; + foreach ($conf_realtime as $key => $value) { + if ($value != 'OK') { + $rt_info .= '
Found error in section '.$key.' :'. $value. '
'; + } + } + if (!empty($rt_info)) { + $info['ConfigsRealTime'] = array('Version' => 'Error', 'about'=> $rt_info); + } +} /* print_r("
Request:
");
  $json = '';
  print_r("
"); print_r("
"); print_r("
"); + print_r($this->srvinterface->sccp_realtime_status()); print_r("DIRECT START"); print_r("
"); - print_r($this->srvinterface->t_get_meta_data()); - +// print_r($this->srvinterface->t_get_meta_data()); + print_r($this->extconfigs->validate_RealTime()); print("
"); */ // $lang_arr = $this->extconfigs->getextConfig('sccp_lang','sk_SK'); @@ -75,7 +111,7 @@ if (!empty($this->class_error)) {
-

Sccp Manager Info

+

Sccp Manager V.sccp_manager_ver); ?> Info