Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class OltTelnetReq
- {
- public $commands_olt = array(
- 'GET_ALL_ONU_INFO' => 'show epon onu-information',
- 'GET_MAC_INTERFACE' => 'show mac address-table dynamic interface ', // concat interface
- 'GET_ALL_OPT_PARAMS' => 'show epon optical-transceiver-diagnosis',
- 'GET_ALL_MAC_ON_INTERFACES' => 'show mac address-table',
- );
- public $telnet;
- public $num_olt;
- /**
- * Устанавливает телнет соединение с Олтом
- * @param $olt_num
- */
- public function telnet_connected($IP)
- {
- $this->telnet = new Telnet($IP, '23', '60', 'User Access Verification');
- $this->telnet->login('login', 'pass');
- $this->telnet->setPrompt('#');
- $this->telnet->exec('enable');
- }
- /**
- * 2 - EPON0/1:1 - port
- * 3 - temp data - BDCM 3022
- * 4 - BDCM - onu brand
- * 5 - 3022 - onu type 3024/3023/3022 P1004/P1504/P1501
- * 6 - fcfa.f79d.02ff - onu mac
- * 7 - auto_conf - status onu - deregiste/auto_conf(online)/lost
- * 8 - power off - reson dereg - power off/N/A(online)/wire down(lost link)
- */
- public function get_epon_onu_info()
- {
- $preg_epon_all_info = '/((EPON0\/[\d]{1,2}:[\d]{1,2})\s*(([A-Za-z]{3,4})\s*([0-9a-zA-Z]{3,4})){0,1}\s*([a-f0-9]{4}.[a-f0-9]{4}.[a-f0-9]{4})[\w\W]*(deregiste|auto_conf|lost)[\w\W]*(N\/A|power\soff|wire\sdown|unknow))+/iU';
- preg_match_all($preg_epon_all_info, $this->telnet->exec($this->commands_olt['GET_ALL_ONU_INFO']), $match);
- return $match;
- }
- /**
- * 2 - 11 - VLAN ID
- * 3 - fcfa.f79d.02ff - onu mac
- * 4 - DYNAMIC - address type
- * 5 - epon0/1:1 - port
- */
- public function get_macs_on_interface($interface)
- {
- $preg_get_address_info = '/(([\d]{2})[\s]*([a-f0-9]{4}.[a-f0-9]{4}.[a-f0-9]{4})[\w\W]*(DYNAMIC)[\w\W]*(epon0\/[\d]{1,2}:[\d]{1,2})(?=\s|$))+/iU';
- preg_match_all($preg_get_address_info, $this->telnet->exec($this->commands_olt['GET_MAC_INTERFACE'] . $interface), $match);
- return $match;
- }
- /**
- * 2 - 11 - VLAN ID
- * 3 - fcfa.f79d.02ff - onu mac
- * 4 - DYNAMIC - address type
- * 5 - epon0/1:1 - port
- */
- public function get_all_macs_on_interfaces()
- {
- $pairs_data = array();
- $preg_get_address_info = '/(([\d]*)\s*([a-f0-9]{4}.[a-f0-9]{4}.[a-f0-9]{4})\s*(DYNAMIC)\s*(epon0\/[\d]{1,2}:[\d]{1,2})(?=\s|$))+/iU';
- preg_match_all($preg_get_address_info, $this->telnet->exec($this->commands_olt['GET_ALL_MAC_ON_INTERFACES']), $match);
- foreach ($match[3] as $k => $mac) {
- if ($match[2][$k] == 1)
- $pairs_data[$match[5][$k]]['mac_onu'] = $mac;
- else {
- $pairs_data[$match[5][$k]]['info_client'][] = array('mac' => $mac, 'vlan' => $match[2][$k]);
- }
- }
- return $pairs_data;
- }
- /**
- * 2 - epon0/1:1 - port
- * 3 - -27.1 - optical param
- */
- public function get_all_optical_params()
- {
- $preg_get_optical_params = '/((epon0\/[\d]{1,2}:[\d]{1,2})\s[\w\W]*(-[\d]{1,2}.[\d]))+/iU';
- preg_match_all($preg_get_optical_params, $this->telnet->exec($this->commands_olt['GET_ALL_OPT_PARAMS']), $match);
- return $match;
- }
- /**
- * 1 - -18 - signal level
- */
- public function get_optical_params($interface)
- {
- $preg_get_optical_params = '/received\spower\(DBm\):\s(-\d*.\d)/i';
- preg_match($preg_get_optical_params, $this->telnet->exec('sh epon interface ' . $interface . ' onu ctc optical-transceiver-diagnosis'), $match);
- return $match;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement