api.ponzte.php 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318
  1. <?php
  2. /**
  3. * ZTE-like PON devices management
  4. */
  5. class PonZte {
  6. CONST DESC_PONTYPE = 1;
  7. CONST DESC_SHELF = 2;
  8. CONST DESC_SLOT = 3;
  9. CONST DESC_OLT = 4;
  10. CONST DESC_ONU = 5;
  11. /**
  12. * Contains current HAL instance OLT parameters
  13. *
  14. * @var array
  15. */
  16. protected $oltParameters = array();
  17. /**
  18. * Array for checking ports count for EPON cards
  19. *
  20. * @var array
  21. */
  22. protected $eponCards = array();
  23. /**
  24. * Array for checking ports count for GPON cards
  25. *
  26. * @var array
  27. */
  28. protected $gponCards = array();
  29. /**
  30. * Contains snmp helper object
  31. *
  32. * @var object
  33. */
  34. protected $snmp;
  35. /**
  36. * Contains OLTData
  37. *
  38. * @var object
  39. */
  40. protected $olt = '';
  41. /**
  42. * Contains all OLTs snmp tmplates
  43. *
  44. * @var array
  45. */
  46. protected $snmpTemplates = array();
  47. /**
  48. * Contains all OLTs devices with proper snmp config
  49. *
  50. * @var array
  51. */
  52. protected $allOltSnmp = array();
  53. /**
  54. * Contains all olt models
  55. *
  56. * @var array
  57. */
  58. protected $allOltModels = array();
  59. /**
  60. * Contains all OLTs devices
  61. *
  62. * @var array
  63. */
  64. protected $allOltDevices = array();
  65. /**
  66. * Current OLT switch id
  67. *
  68. * @var int
  69. */
  70. protected $oltid = 0;
  71. /**
  72. * Current OLT IP with SNMP port
  73. *
  74. * @var string
  75. */
  76. protected $oltIp = '';
  77. /**
  78. * Current OLT IP with SNMP port
  79. *
  80. * @var string
  81. */
  82. protected $oltFullAddress = '';
  83. /**
  84. * Current OLT snmp community
  85. *
  86. * @var string
  87. */
  88. protected $oltCommunity = '';
  89. /**
  90. * Take only needed SNMP template for current OLT.
  91. *
  92. * @var array
  93. */
  94. protected $currentSnmpTemplate;
  95. /**
  96. * Contains all ONUs MAC addresses.
  97. *
  98. * @var array
  99. */
  100. protected $macIndex = array();
  101. /**
  102. * Contains all signals
  103. *
  104. * @var array
  105. */
  106. protected $sigIndex = array();
  107. /**
  108. * Contains all interface names => ONU ID
  109. *
  110. * @var array
  111. */
  112. protected $intIndex = array();
  113. /**
  114. * Contains FDB
  115. *
  116. * @var array
  117. */
  118. protected $fdbIndex = array();
  119. /**
  120. * Contains type EPON or GPON.
  121. *
  122. * @var string
  123. */
  124. public $ponType = '';
  125. /**
  126. * Contains all serial numbers => index
  127. *
  128. * @var array
  129. */
  130. protected $snIndex = array();
  131. /**
  132. * Contains distances for ONTs
  133. *
  134. * @var array
  135. */
  136. protected $distanceIndex = array();
  137. /**
  138. * Creates new PON poller/parser proto
  139. *
  140. * @param array $oltParameters
  141. * @param array $snmpTemplates
  142. */
  143. public function __construct($oltParameters, $snmpTemplates) {
  144. $this->oltParameters = $oltParameters;
  145. //unpacking OLT settings
  146. $oltModelId = $this->oltParameters['MODELID'];
  147. $oltid = $this->oltParameters['ID'];
  148. $oltIp = $this->oltParameters['IP'];
  149. $oltCommunity = $this->oltParameters['COMMUNITY'];
  150. $oltNoFDBQ = $this->oltParameters['NOFDB'];
  151. $ponType = $this->oltParameters['TYPE'];
  152. //setting some object properties
  153. $this->oltid = $oltid;
  154. $this->oltCommunity = $oltCommunity;
  155. $this->oltIp = $oltIp;
  156. $this->oltFullAddress = $oltIp . ':' . PONizer::SNMPPORT;
  157. $this->ponType = $ponType;
  158. $this->initSNMP();
  159. $this->initOltAttractor();
  160. $this->loadOltDevices();
  161. $this->loadOltModels();
  162. $this->snmpTemplates = $snmpTemplates;
  163. $this->currentSnmpTemplate = $this->snmpTemplates[$oltModelId];
  164. $this->eponCards = OnuRegister::allEponCards();
  165. $this->gponCards = OnuRegister::allGponCards();
  166. if (!isset($this->currentSnmpTemplate['signal']['POLLTYPE'])) {
  167. $this->currentSnmpTemplate['signal']['POLLTYPE'] = 'default';
  168. }
  169. if (!isset($this->currentSnmpTemplate['signal']['SIGNALTYPE'])) {
  170. $this->currentSnmpTemplate['signal']['SIGNALTYPE'] = 'OLTRX';
  171. }
  172. }
  173. /**
  174. * Creates single instance of SNMPHelper object
  175. *
  176. * @return void
  177. */
  178. protected function initSNMP() {
  179. $this->snmp = new SNMPHelper();
  180. }
  181. /**
  182. * Inits current OLT data abstraction layer for further usage
  183. */
  184. protected function initOltAttractor() {
  185. $this->olt = new OLTAttractor($this->oltParameters['ID']);
  186. }
  187. /**
  188. * Loads all available snmp models data into private data property
  189. *
  190. * @return void
  191. */
  192. protected function loadOltModels() {
  193. $rawModels = zb_SwitchModelsGetAll();
  194. if (!empty($rawModels)) {
  195. foreach ($rawModels as $io => $each) {
  196. $this->allOltModels[$each['id']]['modelname'] = $each['modelname'];
  197. $this->allOltModels[$each['id']]['snmptemplate'] = $each['snmptemplate'];
  198. $this->allOltModels[$each['id']]['ports'] = $each['ports'];
  199. }
  200. }
  201. }
  202. /**
  203. * Loads all available devices set as OLT
  204. *
  205. * @return void
  206. */
  207. protected function loadOltDevices() {
  208. $query = "SELECT `id`,`ip`,`location`,`snmp`,`modelid` from `switches` WHERE `desc` LIKE '%OLT%';";
  209. $raw = simple_queryall($query);
  210. if (!empty($raw)) {
  211. foreach ($raw as $io => $each) {
  212. $this->allOltDevices[$each['id']] = $each['ip'] . ' - ' . $each['location'];
  213. if (!empty($each['snmp'])) {
  214. $this->allOltSnmp[$each['id']]['community'] = $each['snmp'];
  215. $this->allOltSnmp[$each['id']]['modelid'] = $each['modelid'];
  216. $this->allOltSnmp[$each['id']]['ip'] = $each['ip'];
  217. }
  218. }
  219. }
  220. }
  221. //wrappers
  222. /**
  223. * Wrapper around $this->snmp->walk method and explodeRows function to get less string length.
  224. *
  225. * @param string $oid
  226. *
  227. * @return array
  228. */
  229. protected function snmpwalk($oid) {
  230. $data = $this->snmp->walk($this->oltFullAddress, $this->oltCommunity, $oid, PONizer::SNMPCACHE);
  231. return(explodeRows(trim($data)));
  232. }
  233. /**
  234. * Converts hex to string value
  235. *
  236. * @param string $hex
  237. * @return string
  238. */
  239. protected function hexToString($hex) {
  240. return pack('H*', $hex);
  241. }
  242. /**
  243. * Remove oid + dot from string
  244. *
  245. * @param string $oid
  246. * @param string $str
  247. *
  248. * @return string
  249. */
  250. protected function strRemoveOidWithDot($oid, $str) {
  251. return(trim(str_replace($oid . ".", '', $str)));
  252. }
  253. /**
  254. * Wrapper around str_replace to make code more pretty
  255. *
  256. * @param string $search
  257. * @param string $str
  258. *
  259. * @return string
  260. */
  261. protected function strRemove($search, $str) {
  262. return(trim(str_replace($search, '', $str)));
  263. }
  264. //processing functions
  265. /**
  266. * Epon signals preprocessing
  267. *
  268. * @return array
  269. */
  270. protected function signalIndexProcessing() {
  271. foreach ($this->sigIndex as $devIndex => &$eachsig) {
  272. if ($eachsig == $this->currentSnmpTemplate['signal']['DOWNVALUE']) {
  273. $eachsig = 'Offline';
  274. }
  275. if (isset($this->currentSnmpTemplate['signal']['DOWNVALUE2'])) {
  276. if ($eachsig == $this->currentSnmpTemplate['signal']['DOWNVALUE2']) {
  277. $eachsig = 'Offline';
  278. }
  279. }
  280. if (isset($this->currentSnmpTemplate['signal']['DOWNVALUE3'])) {
  281. if ($eachsig == $this->currentSnmpTemplate['signal']['DOWNVALUE3']) {
  282. $eachsig = 'Offline';
  283. }
  284. }
  285. if ($eachsig != 'Offline') {
  286. $eachsig = str_replace('"', '', $eachsig);
  287. if ($this->currentSnmpTemplate['signal']['OFFSETMODE'] == 'div') {
  288. if ($this->currentSnmpTemplate['signal']['OFFSET']) {
  289. $div = $this->currentSnmpTemplate['signal']['OFFSET'];
  290. if ($this->currentSnmpTemplate['signal']['SIGNALTYPE'] == 'ONURX') {
  291. $div = $this->currentSnmpTemplate['signal']['ONURXOFFSET'];
  292. $exploDevIndex = explode('.', $devIndex);
  293. $devIndex = $exploDevIndex[0] . "." . $exploDevIndex[1];
  294. $this->sigIndex[$devIndex] = $eachsig / $div;
  295. }
  296. $eachsig = $eachsig / $div;
  297. }
  298. }
  299. }
  300. }
  301. }
  302. /**
  303. * Epon mac indexes preprocessing
  304. *
  305. * @return array
  306. */
  307. protected function macIndexEponProcessing() {
  308. foreach ($this->macIndex as $devIndex => &$eachmac) {
  309. $eachmac = str_replace(' ', ':', $eachmac);
  310. $eachmac = strtolower($eachmac);
  311. }
  312. }
  313. /**
  314. * Serial number indexes preprocessing.
  315. *
  316. * @return void
  317. */
  318. protected function serialIndexGponProcessing() {
  319. foreach ($this->snIndex as $devIndex => &$eachSn) {
  320. $eachSn = str_replace(' ', ':', $eachSn);
  321. $eachSn = strtoupper($eachSn);
  322. }
  323. }
  324. /**
  325. * Coverts dec value to binary with byte offset.
  326. *
  327. * @param int $binary
  328. *
  329. * @return array()
  330. */
  331. protected function getDecodeType($binary) {
  332. $match = array();
  333. $match2 = array();
  334. switch (strlen($binary)) {
  335. case 30:
  336. preg_match("/(\d{4})(\d{3})(\d{4})(\d{3})(\d{8})(\d{8})/", $binary, $match);
  337. break;
  338. case 31:
  339. preg_match("/(\d{4})(\d{4})(\d{4})(\d{3})(\d{8})(\d{8})/", $binary, $match);
  340. break;
  341. case 32:
  342. preg_match("/(\d{4})(\d{4})(\d{5})(\d{3})(\d{8})(\d{8})/", $binary, $match);
  343. break;
  344. }
  345. foreach ($match as &$each) {
  346. $each = bindec($each);
  347. }
  348. if (!empty($match)) {
  349. $match[self::DESC_OLT] += 1;
  350. switch ($match[self::DESC_PONTYPE]) {
  351. case 9:
  352. preg_match("/(\d{4})(\d{4})(\d{4})(\d{4})(\d{8})(\d{8})/", $binary, $match2);
  353. break;
  354. case 10:
  355. preg_match("/(\d{4})(\d{4})(\d{4})(\d{4})(\d{8})(\d{8})/", $binary, $match2);
  356. break;
  357. }
  358. if (isset($match2[self::DESC_PONTYPE])) {
  359. foreach ($match2 as &$each) {
  360. $each = bindec($each);
  361. }
  362. $match2[self::DESC_OLT] += 1;
  363. $match = $match2;
  364. }
  365. }
  366. return($match);
  367. }
  368. /**
  369. * Coverts dec value to binary with byte offset. For ZTE C6XX/
  370. *
  371. * @param int $binary
  372. *
  373. * @return array()
  374. */
  375. protected function getDecodeTypeC6XX($binary) {
  376. $match = array();
  377. switch (strlen($binary)) {
  378. case 29:
  379. preg_match("/(\d{4})(\d{9})(\d{8})(\d{8})/", $binary, $match);
  380. break;
  381. }
  382. foreach ($match as &$each) {
  383. $each = bindec($each);
  384. }
  385. return($match);
  386. }
  387. /**
  388. * Converts binary string to human readable format like epon-olt_1/1/10:16
  389. *
  390. * @param array $match
  391. * @param boolg $default
  392. *
  393. * @return string
  394. */
  395. protected function stdDecodeOutput($match, $default = true) {
  396. $typeName = array(
  397. 1 => 'type_olt_virtualIfBER',
  398. 3 => 'type-onu',
  399. 8 => 'type-onu',
  400. 9 => 'type-onu',
  401. 10 => 'type-onu',
  402. 12 => 'type-onu'
  403. );
  404. //rename interface to epon (or gpon if needed)
  405. foreach ($typeName as &$name) {
  406. if ($this->ponType == 'EPON') {
  407. $name = str_replace('type', 'epon', $name);
  408. } else {
  409. $name = str_replace('type', 'gpon', $name);
  410. }
  411. }
  412. if ($default) {
  413. return($typeName[$match[self::DESC_PONTYPE]]
  414. . '_'
  415. . $match[self::DESC_SHELF]
  416. . '/'
  417. . $match[self::DESC_SLOT]
  418. . '/'
  419. . $match[self::DESC_OLT]
  420. . ':'
  421. . $match[self::DESC_ONU]
  422. );
  423. } else {
  424. return($typeName[$match[self::DESC_PONTYPE]]
  425. . '_'
  426. . $match[self::DESC_SHELF]
  427. . '/'
  428. . $match[self::DESC_SLOT]
  429. . '/'
  430. . $match[self::DESC_OLT]
  431. );
  432. }
  433. }
  434. /**
  435. * Converts dec number to gpon interface name. Looks dirty but seems working.
  436. *
  437. * @param int $dec
  438. *
  439. * @return string
  440. */
  441. protected function gponOltInterfaceDecode($dec) {
  442. $result = '';
  443. $match = array();
  444. $binary = decbin((int) $dec);
  445. if (strlen($binary) == 29) {
  446. preg_match("/(\d{4})(\d{6})(\d{3})(\d{8})(\d{8})/", $binary, $match);
  447. foreach ($match as &$each) {
  448. $each = bindec($each);
  449. }
  450. if ($match[self::DESC_ONU] == 0) {
  451. $result = 'gpon-onu_' . $match[self::DESC_SHELF] . '/' . $match[self::DESC_SLOT] . '/' . $match[self::DESC_OLT] . ':';
  452. } else {
  453. $result = 'gpon-onu_' . $match[self::DESC_SHELF + 1] . '/' . $match[self::DESC_SLOT + 1] . '/' . $match[self::DESC_OLT + 1] . ':';
  454. }
  455. }
  456. return($result);
  457. }
  458. /**
  459. * Calculation ZTE epon interfaces indexes.
  460. *
  461. * @return void
  462. */
  463. protected function intIndexCalcEpon() {
  464. $cards = $this->cardsEponCalc();
  465. $onu_id_start = 805830912;
  466. foreach ($cards as $card) {
  467. $onu_id = $onu_id_start + (524288 * ($card - 1));
  468. for ($port = 1; $port <= 16; $port++) {
  469. $tmp_id = $onu_id;
  470. for ($onu_num = 1; $onu_num <= 64; $onu_num++) {
  471. $this->intIndex[$tmp_id] = 'epon-onu_' . $card . "/" . $port . ':' . $onu_num;
  472. $tmp_id += 256;
  473. }
  474. $onu_id += 65536;
  475. }
  476. }
  477. }
  478. /**
  479. * Check out which cards are installed
  480. *
  481. * @return array
  482. */
  483. protected function cardsEponCalc() {
  484. $cards = array();
  485. if (isset($this->currentSnmpTemplate['misc']['ALLCARDS'])) {
  486. $allCards = $this->snmpwalk($this->currentSnmpTemplate['misc']['ALLCARDS']);
  487. foreach ($allCards as $io => $value) {
  488. $split = explode("=", $value);
  489. if (isset($split[1])) {
  490. $oid = $this->strRemoveOidWithDot($this->currentSnmpTemplate['misc']['ALLCARDS'], $split[0]);
  491. $oidParts = explode(".", $oid);
  492. $cardNumber = end($oidParts);
  493. $card = trim(str_replace("STRING:", '', $split[1]));
  494. $card = str_replace('"', '', $card);
  495. if (isset($this->eponCards[$card])) {
  496. $cards[] = $cardNumber;
  497. }
  498. }
  499. }
  500. }
  501. if (empty($cards)) {
  502. if (isset($this->currentSnmpTemplate['misc']['CARDOFFSET'])) {
  503. $start = $this->currentSnmpTemplate['misc']['CARDOFFSET'];
  504. } else {
  505. $start = 1;
  506. }
  507. for ($card = $start; $card <= 20; $card++) {
  508. $cards[] = $card;
  509. }
  510. }
  511. return($cards);
  512. }
  513. /**
  514. * Getting raw snmp interface index => mac onu
  515. *
  516. * @return array
  517. */
  518. protected function macIndexRawCalc() {
  519. $macIndex = array();
  520. $macIndexTmp = $this->snmpwalk($this->currentSnmpTemplate['signal']['MACINDEX']);
  521. foreach ($macIndexTmp as $io => $value) {
  522. $value = $this->strRemoveOidWithDot($this->currentSnmpTemplate['signal']['MACINDEX'], $value);
  523. $value = $this->strRemove($this->currentSnmpTemplate['signal']['MACVALUE'], $value);
  524. $macIndex[$io] = $value;
  525. }
  526. return($macIndex);
  527. }
  528. /**
  529. * Prettyfying result of macIndexRawCalc
  530. *
  531. * @return void
  532. */
  533. protected function macIndexCalc() {
  534. $macIndexRaw = $this->macIndexRawCalc();
  535. if (!empty($macIndexRaw)) {
  536. foreach ($macIndexRaw as $rawIo => $rawEach) {
  537. $explodeIndex = explode('=', $rawEach);
  538. if (isset($explodeIndex[1])) {
  539. $naturalIndex = trim($explodeIndex[0]);
  540. $naturalMac = trim($explodeIndex[1]);
  541. $this->macIndex[$naturalIndex] = $naturalMac;
  542. }
  543. }
  544. }
  545. }
  546. /**
  547. * Getting signals => snmp interface id.
  548. *
  549. * @return array
  550. */
  551. protected function sigIndexCalc($data) {
  552. $sigIndexTmp = array();
  553. if ($this->currentSnmpTemplate['signal']['SIGNALTYPE'] == 'ONURX') {
  554. $oid = $this->currentSnmpTemplate['signal']['ONURXINDEX'];
  555. } else {
  556. $oid = $this->currentSnmpTemplate['signal']['SIGINDEX'];
  557. }
  558. if (!empty($data)) {
  559. if ($this->currentSnmpTemplate['signal']['POLLTYPE'] == 'default') {
  560. foreach ($data as $ioIndex => $eachVal) {
  561. $tmpSig = $this->snmpwalk($oid . $ioIndex);
  562. $sigIndex = $this->strRemove($this->currentSnmpTemplate['signal']['SIGVALUE'], $tmpSig[0]);
  563. $sigIndex = $this->strRemove($oid, $sigIndex);
  564. $explodeSig = explode('=', $sigIndex);
  565. $naturalIndex = trim($explodeSig[0]);
  566. if (isset($explodeSig[1])) {
  567. $naturalSig = trim($explodeSig[1]);
  568. $trueIndex = $naturalIndex;
  569. if ($this->currentSnmpTemplate['signal']['SIGNALTYPE'] == 'ONURX') {
  570. $splitIndex = explode(".", $naturalIndex);
  571. $trueIndex = $splitIndex[0] . "." . $splitIndex[1];
  572. if ($naturalSig <= 30000) {
  573. $naturalSig = $naturalSig * 0.002 - 30;
  574. }
  575. if ($naturalSig > 30000) {
  576. $naturalSig = ($naturalSig - 65535) * 0.002 - 30;
  577. }
  578. }
  579. $sigIndexTmp[$trueIndex] = $naturalSig;
  580. }
  581. }
  582. }
  583. if ($this->currentSnmpTemplate['signal']['POLLTYPE'] == 'fast') {
  584. $oid = substr($oid, 0, -1);
  585. $tmpSig = $this->snmpwalk($oid);
  586. foreach ($tmpSig as $eachSig) {
  587. $sigIndex = $this->strRemove($this->currentSnmpTemplate['signal']['SIGVALUE'], $eachSig);
  588. $sigIndex = $this->strRemoveOidWithDot($oid, $sigIndex);
  589. $explodeSig = explode('=', $sigIndex);
  590. $naturalIndex = trim($explodeSig[0]);
  591. if (isset($explodeSig[1])) {
  592. $naturalSig = trim($explodeSig[1]);
  593. $trueIndex = $naturalIndex;
  594. if ($this->currentSnmpTemplate['signal']['SIGNALTYPE'] == 'ONURX') {
  595. $splitIndex = explode(".", $naturalIndex);
  596. $trueIndex = $splitIndex[0] . "." . $splitIndex[1];
  597. if ($naturalSig <= 30000) {
  598. $naturalSig = $naturalSig * 0.002 - 30;
  599. }
  600. if ($naturalSig > 30000) {
  601. $naturalSig = ($naturalSig - 65535) * 0.002 - 30;
  602. }
  603. }
  604. $sigIndexTmp[$trueIndex] = $naturalSig;
  605. }
  606. }
  607. }
  608. }
  609. unset($this->sigIndex);
  610. $this->sigIndex = $sigIndexTmp;
  611. }
  612. /**
  613. * Getting FDB
  614. *
  615. * @return void
  616. */
  617. protected function fdbCalc() {
  618. $this->fdbIndex = $this->snmpwalk($this->currentSnmpTemplate['misc']['FDBINDEX']);
  619. foreach ($this->fdbIndex as $id => &$value) {
  620. $value = $this->strRemoveOidWithDot($this->currentSnmpTemplate['misc']['FDBINDEX'], $value);
  621. }
  622. }
  623. /**
  624. *
  625. * Function for fixing fucking zte interfaces snmp id.
  626. *
  627. * @param int $uuid
  628. *
  629. * @return string
  630. */
  631. protected function interfaceDecode($uuid) {
  632. $binary = decbin((int) $uuid);
  633. $match = $this->getDecodeType($binary);
  634. if (!empty($match) and isset($match[self::DESC_PONTYPE])) {
  635. switch ($match[self::DESC_PONTYPE]) {
  636. case 1:
  637. return($this->stdDecodeOutput($match, false));
  638. case 3:
  639. return($this->stdDecodeOutput($match));
  640. case 6:
  641. return($match[self::DESC_SHELF] . '/' . $match[self::DESC_SLOT] . '/');
  642. case 8:
  643. $match[self::DESC_SLOT] += $this->currentSnmpTemplate['misc']['CARDOFFSET'];
  644. $match[self::DESC_ONU] += 1;
  645. return($this->stdDecodeOutput($match));
  646. case 9:
  647. return($this->stdDecodeOutput($match));
  648. case 10:
  649. $match[self::DESC_SLOT] += 1;
  650. $match[self::DESC_ONU] += 1;
  651. return($this->stdDecodeOutput($match));
  652. case 12:
  653. return($this->stdDecodeOutput($match));
  654. }
  655. }
  656. return FALSE;
  657. }
  658. /**
  659. * Preprocessing serial index array with removing unneded substrings.
  660. *
  661. * @return void
  662. */
  663. protected function snIndexProcess() {
  664. $this->snIndex = $this->snmpwalk($this->currentSnmpTemplate['signal']['SNINDEX']);
  665. foreach ($this->snIndex as $io => &$value) {
  666. $value = $this->strRemove($this->currentSnmpTemplate['signal']['SNVALUE'], $value);
  667. $value = $this->strRemoveOidWithDot($this->currentSnmpTemplate['signal']['SNINDEX'], $value);
  668. $value = trim($value);
  669. }
  670. }
  671. /**
  672. * Preproccess distances indexes.
  673. *
  674. * @return void
  675. */
  676. protected function distanceIndexProcess() {
  677. if ($this->currentSnmpTemplate['signal']['POLLTYPE'] == 'default') {
  678. foreach ($this->snIndex as $ioIndex => $eachSn) {
  679. $tmpDist = $this->snmpwalk($this->currentSnmpTemplate['signal']['DISTANCE'] . '.' . $ioIndex);
  680. $distIndex = $this->strRemoveOidWithDot($this->currentSnmpTemplate['signal']['DISTANCE'], $tmpDist[0]);
  681. $distIndex = $this->strRemove($this->currentSnmpTemplate['signal']['DISTVALUE'], $distIndex);
  682. $explodeDist = explode('=', $distIndex);
  683. $naturalIndex = trim($explodeDist[0]);
  684. if (isset($explodeDist[1])) {
  685. $naturalDist = trim($explodeDist[1]);
  686. $this->distanceIndex[$naturalIndex] = $naturalDist;
  687. }
  688. }
  689. }
  690. if ($this->currentSnmpTemplate['signal']['POLLTYPE'] == 'fast') {
  691. $tmpDist = $this->snmpwalk($this->currentSnmpTemplate['signal']['DISTANCE']);
  692. foreach ($tmpDist as $eachDist) {
  693. $distIndex = $this->strRemoveOidWithDot($this->currentSnmpTemplate['signal']['DISTANCE'], $eachDist);
  694. $distIndex = $this->strRemove($this->currentSnmpTemplate['signal']['DISTVALUE'], $distIndex);
  695. $explodeDist = explode('=', $distIndex);
  696. $naturalIndex = trim($explodeDist[0]);
  697. if (isset($explodeDist[1])) {
  698. $naturalDist = trim($explodeDist[1]);
  699. $this->distanceIndex[$naturalIndex] = $naturalDist;
  700. }
  701. }
  702. }
  703. }
  704. //parser functions
  705. /**
  706. * Parses & stores in cache ZTE OLT ONU ID
  707. *
  708. * @return void
  709. */
  710. protected function onuidParseEpon() {
  711. $macTmp = array();
  712. foreach ($this->macIndex as $ioIndex => $eachMac) {
  713. $eachMac = strtolower($eachMac);
  714. $eachMac = str_replace(" ", ":", $eachMac);
  715. $macTmp[$ioIndex] = $eachMac;
  716. }
  717. $this->olt->writeOnuCache($macTmp);
  718. }
  719. /**
  720. * Parsing and validating input array. Getting hex from dec values.
  721. *
  722. * @param array $decParts
  723. *
  724. * @return array
  725. */
  726. protected function macPartParse($decParts) {
  727. $macPart = array();
  728. if (isset($decParts[1])) {
  729. for ($i = 2; $i <= 7; $i++) {
  730. $macPart[] = dechex($decParts[$i]);
  731. }
  732. foreach ($macPart as &$eachPart) {
  733. if (strlen($eachPart) < 2) {
  734. $eachPart = '0' . $eachPart;
  735. }
  736. }
  737. }
  738. return($macPart);
  739. }
  740. /**
  741. * Parses & stores in cache OLT ONU interfaces
  742. *
  743. * @return void
  744. */
  745. protected function fdbParseEpon() {
  746. $counter = 1;
  747. $fdbTmp = array();
  748. $macTmp = array();
  749. $result = array();
  750. //fdb index preprocessing
  751. if ((!empty($this->fdbIndex)) AND (!empty($this->macIndex))) {
  752. foreach ($this->fdbIndex as $io => $eachfdb) {
  753. $line = explode('=', $eachfdb);
  754. $devOid = trim($line[0]);
  755. $decParts = explode('.', $devOid);
  756. $devIndex = trim($decParts[0]);
  757. $interfaceName = $this->interfaceDecode($devIndex);
  758. if ($interfaceName) {
  759. if (isset($decParts[1])) {
  760. $fdbVlan = trim($decParts[1]);
  761. $fdbMac = implode(':', $this->macPartParse($decParts));
  762. $fdbTmp[$interfaceName][$counter]['mac'] = $fdbMac;
  763. $fdbTmp[$interfaceName][$counter]['vlan'] = $fdbVlan;
  764. $counter++;
  765. }
  766. }
  767. }
  768. //mac index preprocessing
  769. foreach ($this->macIndex as $devIndex => $eachMac) {
  770. if ($this->interfaceDecode($devIndex)) {
  771. $macTmp[$this->interfaceDecode($devIndex)] = $eachMac;
  772. }
  773. }
  774. $realData = array_intersect_key($macTmp, $fdbTmp);
  775. //storing results
  776. foreach ($realData as $devId => $eachMac) {
  777. $result[$macTmp[$devId]] = $fdbTmp[$devId];
  778. }
  779. }
  780. $this->olt->writeFdb($result);
  781. }
  782. /**
  783. * Parses & stores in cache ZTE OLT ONU interfaces
  784. *
  785. * @return void
  786. */
  787. protected function interfaceParseEpon() {
  788. $result = array();
  789. foreach ($this->macIndex as $ioIndex => $eachMac) {
  790. if (isset($this->intIndex[$ioIndex])) {
  791. $eachMac = strtolower($eachMac);
  792. $eachMac = str_replace(" ", ":", $eachMac);
  793. $interface = $this->intIndex[$ioIndex];
  794. $result[$eachMac] = $interface;
  795. } elseif ($this->interfaceDecode($ioIndex)) {
  796. $eachMac = strtolower($eachMac);
  797. $eachMac = str_replace(" ", ":", $eachMac);
  798. $result[$eachMac] = $this->interfaceDecode($ioIndex);
  799. }
  800. }
  801. $this->olt->writeInterfaces($result);
  802. }
  803. /**
  804. * Performs signal preprocessing for sig/mac index arrays and stores it into cache for ZTE OLT
  805. *
  806. * @return void
  807. */
  808. protected function signalParseEpon() {
  809. $result = array();
  810. if ((!empty($this->sigIndex)) AND (!empty($this->macIndex))) {
  811. $this->signalIndexProcessing();
  812. $this->macIndexEponProcessing();
  813. $realData = array_intersect_key($this->macIndex, $this->sigIndex);
  814. foreach ($realData as $devId => $io) {
  815. $result[$this->macIndex[$devId]] = $this->sigIndex[$devId];
  816. $tmpSig = $this->sigIndex[$devId];
  817. if ($this->sigIndex[$devId] == 'Offline') {
  818. $tmpSig = -9000;
  819. }
  820. $this->olt->writeSignalHistory($this->macIndex[$devId], $tmpSig);
  821. }
  822. }
  823. $this->olt->writeSignals($result);
  824. }
  825. /**
  826. * Performs signal preprocessing for sig/sn index arrays and stores it into cache for ZTE OLT
  827. *
  828. * @return void
  829. */
  830. protected function signalParseGpon() {
  831. $result = array();
  832. $curDate = curdatetime();
  833. //signal index preprocessing
  834. if ((!empty($this->sigIndex)) AND (!empty($this->snIndex))) {
  835. $this->signalIndexProcessing();
  836. $this->serialIndexGponProcessing();
  837. $realData = array_intersect_key($this->snIndex, $this->sigIndex);
  838. //storing results
  839. foreach ($realData as $devId => $eachSn) {
  840. $result[$this->snIndex[$devId]] = $this->sigIndex[$devId];
  841. $tmpSig = $this->sigIndex[$devId];
  842. if ($tmpSig == 'Offline') {
  843. $tmpSig = -9000;
  844. }
  845. //signal history filling
  846. $this->olt->writeSignalHistory($this->snIndex[$devId], $tmpSig);
  847. }
  848. }
  849. $this->olt->writeSignals($result);
  850. }
  851. /**
  852. * Parsing distance for ZTE/Huawei GPON
  853. *
  854. * @param array $distIndex
  855. *
  856. * @return void
  857. */
  858. protected function distanceParseGpon() {
  859. $result = array();
  860. //distance index preprocessing
  861. if (!empty($this->distanceIndex) AND !empty($this->snIndex)) {
  862. $realData = array_intersect_key($this->snIndex, $this->distanceIndex);
  863. foreach ($realData as $io => $eachsn) {
  864. $result[$this->snIndex[$io]] = $this->distanceIndex[$io];
  865. }
  866. }
  867. $this->olt->writeDistances($result);
  868. }
  869. /**
  870. * Parses & stores in cache OLT ONU interfaces
  871. *
  872. * @return void
  873. */
  874. protected function fdbParseGpon() {
  875. $counter = 1;
  876. $fdbTmp = array();
  877. $snTmp = array();
  878. $result = array();
  879. //fdb index preprocessing
  880. if ((!empty($this->fdbIndex)) AND (!empty($this->snIndex))) {
  881. foreach ($this->fdbIndex as $io => $eachfdb) {
  882. $line = explode('=', $eachfdb);
  883. $devOid = trim($line[0]);
  884. $decParts = explode('.', $devOid);
  885. if ($this->currentSnmpTemplate['onu_reg']['VERSION'] == 'C6XX') {
  886. if (trim($decParts[2]) != 0) {
  887. $vportIndex = trim($decParts[1]);
  888. $devIndex = trim($decParts[2]);
  889. $interfaceVport = $this->gponOltInterfaceDecode($vportIndex);
  890. /*
  891. // It's real data from OLT
  892. // c025.2fac.ff3c 3701 Dynamic vport-1/3/1.5:1
  893. $interfaceVport = str_replace('gpon-onu_', 'vport-', $this->gponOltInterfaceDecode($vportIndex));
  894. $interfaceVport = str_replace(':', '.', $interfaceVport);
  895. $interfaceVportDecode = $this->getDecodeTypeC6XX(decbin((int) $devIndex));
  896. $interfaceName = $interfaceVport . $interfaceVportDecode[3] . ':' . $interfaceVportDecode[4];
  897. $interfaceVportDecode = $this->getDecodeTypeC6XX(decbin((int) $devIndex));
  898. $interfaceName = $interfaceVport . $interfaceVportDecode[3] . ':' . $interfaceVportDecode[4];
  899. */
  900. $interfaceVportDecode = $this->getDecodeTypeC6XX(decbin((int) $devIndex));
  901. $interfaceName = $interfaceVport . $interfaceVportDecode[2];
  902. if ($interfaceName) {
  903. if (isset($decParts[0])) {
  904. $fdbVlan = trim($decParts[0]);
  905. $fdbMac = trim(str_replace('Hex-STRING:', '', $line[1]));
  906. $fdbMac = strtolower(str_replace(' ', ':', $fdbMac));
  907. $fdbTmp[$interfaceName][$counter]['mac'] = $fdbMac;
  908. $fdbTmp[$interfaceName][$counter]['vlan'] = $fdbVlan;
  909. $counter++;
  910. }
  911. }
  912. }
  913. } else {
  914. $devIndex = trim($decParts[0]);
  915. $interfaceName = $this->interfaceDecode($devIndex);
  916. if ($interfaceName) {
  917. if (isset($decParts[1])) {
  918. $fdbVlan = trim($decParts[1]);
  919. $fdbMac = implode(':', $this->macPartParse($decParts));
  920. $fdbTmp[$interfaceName][$counter]['mac'] = $fdbMac;
  921. $fdbTmp[$interfaceName][$counter]['vlan'] = $fdbVlan;
  922. $counter++;
  923. }
  924. }
  925. }
  926. }
  927. //mac index preprocessing
  928. foreach ($this->snIndex as $devIndex => $eachSn) {
  929. $devIndexParts = explode(".", $devIndex);
  930. $onuNumber = $devIndexParts[1];
  931. $interfaceName = $this->gponOltInterfaceDecode($devIndexParts[0]) . $onuNumber;
  932. if ($interfaceName) {
  933. $snTmp[$interfaceName] = $eachSn;
  934. }
  935. }
  936. $realData = array_intersect_key($snTmp, $fdbTmp);
  937. //storing results
  938. foreach ($realData as $devId => $eachSn) {
  939. $result[$snTmp[$devId]] = $fdbTmp[$devId];
  940. }
  941. }
  942. $this->olt->writeFdb($result);
  943. }
  944. /**
  945. * Parses & stores in cache ZTE OLT ONU interfaces
  946. *
  947. * @return void
  948. */
  949. protected function interfaceParseGpon() {
  950. $result = array();
  951. //storing results
  952. foreach ($this->snIndex as $ioIndex => $eachSn) {
  953. $ioIndexSplit = explode(".", $ioIndex);
  954. $result[$eachSn] = $this->gponOltInterfaceDecode($ioIndexSplit[0]) . $ioIndexSplit[1];
  955. }
  956. $this->olt->writeInterfaces($result);
  957. }
  958. /**
  959. * Parses & stores in cache ZTE OLT ONU interfaces
  960. *
  961. * @return void
  962. */
  963. protected function interfaceParseHuaweiGpon() {
  964. $result = array();
  965. $interfaces = array();
  966. $data = $this->snmpwalk($this->currentSnmpTemplate['misc']['INTERFACENAME']);
  967. if (!empty($data)) {
  968. foreach ($data as $io => $value) {
  969. $split = explode("=", $value);
  970. $eachOid = trim($this->strRemoveOidWithDot($this->currentSnmpTemplate['misc']['INTERFACENAME'], $split[0]));
  971. $interfaces[$eachOid] = trim(str_replace('STRING:','',$split[1]));
  972. }
  973. }
  974. //storing results
  975. foreach ($this->snIndex as $ioIndex => $eachSn) {
  976. $ioIndexSplit = explode(".", $ioIndex);
  977. if (isset($interfaces[$ioIndexSplit[0]])) {
  978. $result[$eachSn] = $interfaces[$ioIndexSplit[0]] . ':' . $ioIndexSplit[1];
  979. }
  980. }
  981. $this->olt->writeInterfaces($result);
  982. }
  983. /**
  984. * Parses & stores in cache ZTE OLT ONU ID
  985. *
  986. * @return void
  987. */
  988. protected function onuidParseGpon() {
  989. $snTmp = array();
  990. if ($this->currentSnmpTemplate['onu_reg']['VERSION'] == 'C6XX') {
  991. $snTmp = $this->snIndex;
  992. } else {
  993. foreach ($this->snIndex as $ioIndex => $eachSn) {
  994. $snTmp[$this->interfaceDecode($ioIndex)] = $eachSn;
  995. }
  996. }
  997. $this->olt->writeOnuCache($snTmp);
  998. }
  999. /**
  1000. * Parses & stores in cache ZTE OLT ONU ID
  1001. *
  1002. * @return void
  1003. */
  1004. protected function onuidParseHuaweiGpon() {
  1005. $snTmp = array();
  1006. foreach ($this->snIndex as $ioIndex => $eachSn) {
  1007. $snTmp[$this->interfaceDecode($ioIndex)] = $eachSn;
  1008. }
  1009. $this->olt->writeOnuCache($snTmp);
  1010. }
  1011. /**
  1012. * Parsing serial numbers;
  1013. *
  1014. * @return void
  1015. */
  1016. protected function serialNumberParse() {
  1017. $result = array();
  1018. foreach ($this->snIndex as $rawIo => $rawEach) {
  1019. $split = explode("=", $rawEach);
  1020. if (isset($split[1])) {
  1021. $naturalIndex = trim($split[0]);
  1022. $rawSn = trim($split[1]);
  1023. $tmpSn = explode(" ", $rawSn);
  1024. $check = trim($tmpSn[0]);
  1025. if ($check == 'STRING:') {
  1026. $naturalSn = $this->serialNumberBinaryParse($tmpSn[1]);
  1027. } else {
  1028. $naturalSn = $this->serialNumberHexParse($tmpSn);
  1029. }
  1030. $result[$naturalIndex] = $naturalSn;
  1031. }
  1032. }
  1033. unset($this->snIndex);
  1034. $this->snIndex = $result;
  1035. }
  1036. /**
  1037. * Parsing serial number in binary format and coverting it to needed format.
  1038. *
  1039. * @param array $rawSn
  1040. *
  1041. * @return string
  1042. */
  1043. protected function serialNumberBinaryParse($rawSn) {
  1044. $parts = array();
  1045. $hexSn = bin2hex($rawSn);
  1046. if (strlen($hexSn) == 20) {
  1047. $parts[0] = $this->serialNumberPartsTranslate($hexSn[2] . $hexSn[3]);
  1048. $parts[1] = $this->serialNumberPartsTranslate($hexSn[4] . $hexSn[5]);
  1049. $parts[2] = $this->serialNumberPartsTranslate($hexSn[6] . $hexSn[7]);
  1050. $parts[3] = $this->serialNumberPartsTranslate($hexSn[8] . $hexSn[9]);
  1051. $parts[4] = '';
  1052. for ($i = 10; $i <= 17; $i++) {
  1053. $parts[4] .= $hexSn[$i];
  1054. }
  1055. } else {
  1056. $parts[0] = $this->serialNumberPartsTranslate($hexSn[0] . $hexSn[1]);
  1057. $parts[1] = $this->serialNumberPartsTranslate($hexSn[2] . $hexSn[3]);
  1058. $parts[2] = $this->serialNumberPartsTranslate($hexSn[4] . $hexSn[5]);
  1059. $parts[3] = $this->serialNumberPartsTranslate($hexSn[6] . $hexSn[7]);
  1060. $parts[4] = '';
  1061. for ($i = 8; $i <= 15; $i++) {
  1062. $parts[4] .= $hexSn[$i];
  1063. }
  1064. }
  1065. $result = implode("", $parts);
  1066. return($result);
  1067. }
  1068. /**
  1069. * Parsing serial number in hex format and coverting it to needed format.
  1070. *
  1071. * @param array $rawSn
  1072. *
  1073. * @return string
  1074. */
  1075. protected function serialNumberHexParse($rawSn) {
  1076. $parts[0] = $this->serialNumberPartsTranslate($rawSn[0]);
  1077. $parts[1] = $this->serialNumberPartsTranslate($rawSn[1]);
  1078. $parts[2] = $this->serialNumberPartsTranslate($rawSn[2]);
  1079. $parts[3] = $this->serialNumberPartsTranslate($rawSn[3]);
  1080. $parts[4] = $rawSn[4] . $rawSn[5] . $rawSn[6] . $rawSn[7];
  1081. $result = implode("", $parts);
  1082. return($result);
  1083. }
  1084. /**
  1085. * Check mode to convert serial number string vs raw.
  1086. *
  1087. * @param string $part
  1088. *
  1089. * @return string
  1090. */
  1091. protected function serialNumberPartsTranslate($part) {
  1092. if ($this->currentSnmpTemplate['signal']['SNMODE'] == 'STRING') {
  1093. return($this->hexToString($part));
  1094. }
  1095. if ($this->currentSnmpTemplate['signal']['SNMODE'] == 'PURE') {
  1096. return($part);
  1097. }
  1098. }
  1099. /**
  1100. * Parses uptime data and saves it into uptime cache
  1101. *
  1102. * @param int $oltid
  1103. * @param string $uptimeRaw
  1104. *
  1105. * @return void
  1106. */
  1107. protected function uptimeParse() {
  1108. $uptimeIndexOid = $this->currentSnmpTemplate['system']['UPTIME'];
  1109. $uptimeRaw = $this->snmp->walk($this->oltFullAddress, $this->oltCommunity, $uptimeIndexOid, PONizer::SNMPCACHE);
  1110. if (!empty($this->oltid) and !empty($uptimeRaw)) {
  1111. $uptimeRaw = explode(')', $uptimeRaw);
  1112. $uptimeRaw = $uptimeRaw[1];
  1113. $uptimeRaw = trim($uptimeRaw);
  1114. $this->olt->writeUptime($uptimeRaw);
  1115. }
  1116. }
  1117. /**
  1118. * Parses temperature data and saves it into uptime cache
  1119. *
  1120. * @param int $oltid
  1121. * @param string $uptimeRaw
  1122. *
  1123. * @return void
  1124. */
  1125. protected function temperatureParse() {
  1126. $temperatureIndexOid = $this->currentSnmpTemplate['system']['TEMPERATURE'];
  1127. $tempRaw = $this->snmp->walk($this->oltFullAddress, $this->oltCommunity, $temperatureIndexOid, PONizer::SNMPCACHE);
  1128. if (!empty($this->oltid) and !empty($tempRaw)) {
  1129. $tempRaw = explode(':', $tempRaw);
  1130. $tempRaw = $tempRaw[1];
  1131. $tempRaw = trim($tempRaw);
  1132. $this->olt->writeTemperature($tempRaw);
  1133. }
  1134. }
  1135. //Main section
  1136. /**
  1137. * Polling EPON device
  1138. *
  1139. * @return void
  1140. */
  1141. public function pollEpon() {
  1142. $this->macIndexCalc();
  1143. $this->sigIndexCalc($this->macIndex);
  1144. $this->signalParseEpon();
  1145. if (isset($this->currentSnmpTemplate['misc'])) {
  1146. if (isset($this->currentSnmpTemplate['misc']['CARDOFFSET'])) {
  1147. $this->intIndexCalcEpon();
  1148. $this->fdbCalc();
  1149. $this->fdbParseEpon();
  1150. $this->interfaceParseEpon();
  1151. $this->onuidParseEpon();
  1152. }
  1153. }
  1154. }
  1155. /**
  1156. * Polling GPON device
  1157. *
  1158. * @return void
  1159. */
  1160. public function pollGpon() {
  1161. $this->snIndexProcess();
  1162. $this->serialNumberParse();
  1163. $this->sigIndexCalc($this->snIndex);
  1164. $this->signalParseGpon();
  1165. if (isset($this->currentSnmpTemplate['signal']['DISTANCE'])) {
  1166. $this->distanceIndexProcess();
  1167. $this->distanceParseGpon();
  1168. }
  1169. if (isset($this->currentSnmpTemplate['misc'])) {
  1170. if (isset($this->currentSnmpTemplate['misc']['CARDOFFSET'])) {
  1171. $this->fdbCalc();
  1172. $this->fdbParseGpon();
  1173. $this->interfaceParseGpon();
  1174. $this->onuidParseGpon();
  1175. }
  1176. }
  1177. //getting others system data from OLT
  1178. if (isset($this->currentSnmpTemplate['system'])) {
  1179. //OLT uptime
  1180. if (isset($this->currentSnmpTemplate['system']['UPTIME'])) {
  1181. $this->uptimeParse();
  1182. }
  1183. //OLT temperature
  1184. if (isset($this->currentSnmpTemplate['system']['TEMPERATURE'])) {
  1185. $this->temperatureParse();
  1186. }
  1187. }
  1188. }
  1189. /**
  1190. * Polling Huawei GPON device
  1191. *
  1192. * @return void
  1193. */
  1194. public function huaweiPollGpon() {
  1195. $this->snIndexProcess();
  1196. $this->serialNumberParse();
  1197. $this->sigIndexCalc($this->snIndex);
  1198. $this->signalParseGpon();
  1199. if (isset($this->currentSnmpTemplate['signal']['DISTANCE'])) {
  1200. $this->distanceIndexProcess();
  1201. $this->distanceParseGpon();
  1202. }
  1203. if (isset($this->currentSnmpTemplate['misc']['INTERFACENAME'])) {
  1204. $this->interfaceParseHuaweiGpon();
  1205. //$this->onuidParseHuaweiGpon();
  1206. }
  1207. }
  1208. }