api.ponzte.php 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321
  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 != 65535) {
  573. if ($naturalSig <= 30000) {
  574. $naturalSig = $naturalSig * 0.002 - 30;
  575. }
  576. if ($naturalSig > 30000) {
  577. $naturalSig = ($naturalSig - 65535) * 0.002 - 30;
  578. }
  579. }
  580. }
  581. $sigIndexTmp[$trueIndex] = $naturalSig;
  582. }
  583. }
  584. }
  585. if ($this->currentSnmpTemplate['signal']['POLLTYPE'] == 'fast') {
  586. $oid = substr($oid, 0, -1);
  587. $tmpSig = $this->snmpwalk($oid);
  588. foreach ($tmpSig as $eachSig) {
  589. $sigIndex = $this->strRemove($this->currentSnmpTemplate['signal']['SIGVALUE'], $eachSig);
  590. $sigIndex = $this->strRemoveOidWithDot($oid, $sigIndex);
  591. $explodeSig = explode('=', $sigIndex);
  592. $naturalIndex = trim($explodeSig[0]);
  593. if (isset($explodeSig[1])) {
  594. $naturalSig = trim($explodeSig[1]);
  595. $trueIndex = $naturalIndex;
  596. if ($this->currentSnmpTemplate['signal']['SIGNALTYPE'] == 'ONURX') {
  597. $splitIndex = explode(".", $naturalIndex);
  598. $trueIndex = $splitIndex[0] . "." . $splitIndex[1];
  599. if ($naturalSig != 65535) {
  600. if ($naturalSig <= 30000) {
  601. $naturalSig = $naturalSig * 0.002 - 30;
  602. }
  603. if ($naturalSig > 30000) {
  604. $naturalSig = ($naturalSig - 65535) * 0.002 - 30;
  605. }
  606. }
  607. }
  608. $sigIndexTmp[$trueIndex] = $naturalSig;
  609. }
  610. }
  611. }
  612. }
  613. unset($this->sigIndex);
  614. $this->sigIndex = $sigIndexTmp;
  615. }
  616. /**
  617. * Getting FDB
  618. *
  619. * @return void
  620. */
  621. protected function fdbCalc() {
  622. $this->fdbIndex = $this->snmpwalk($this->currentSnmpTemplate['misc']['FDBINDEX']);
  623. foreach ($this->fdbIndex as $id => &$value) {
  624. $value = $this->strRemoveOidWithDot($this->currentSnmpTemplate['misc']['FDBINDEX'], $value);
  625. }
  626. }
  627. /**
  628. *
  629. * Function for fixing fucking zte interfaces snmp id.
  630. *
  631. * @param int $uuid
  632. *
  633. * @return string
  634. */
  635. protected function interfaceDecode($uuid) {
  636. $binary = decbin((int) $uuid);
  637. $match = $this->getDecodeType($binary);
  638. if (!empty($match) and isset($match[self::DESC_PONTYPE])) {
  639. switch ($match[self::DESC_PONTYPE]) {
  640. case 1:
  641. return ($this->stdDecodeOutput($match, false));
  642. case 3:
  643. return ($this->stdDecodeOutput($match));
  644. case 6:
  645. return ($match[self::DESC_SHELF] . '/' . $match[self::DESC_SLOT] . '/');
  646. case 8:
  647. $match[self::DESC_SLOT] += $this->currentSnmpTemplate['misc']['CARDOFFSET'];
  648. $match[self::DESC_ONU] += 1;
  649. return ($this->stdDecodeOutput($match));
  650. case 9:
  651. return ($this->stdDecodeOutput($match));
  652. case 10:
  653. $match[self::DESC_SLOT] += 1;
  654. $match[self::DESC_ONU] += 1;
  655. return ($this->stdDecodeOutput($match));
  656. case 12:
  657. return ($this->stdDecodeOutput($match));
  658. }
  659. }
  660. return FALSE;
  661. }
  662. /**
  663. * Preprocessing serial index array with removing unneded substrings.
  664. *
  665. * @return void
  666. */
  667. protected function snIndexProcess() {
  668. $this->snIndex = $this->snmpwalk($this->currentSnmpTemplate['signal']['SNINDEX']);
  669. foreach ($this->snIndex as $io => &$value) {
  670. $value = $this->strRemove($this->currentSnmpTemplate['signal']['SNVALUE'], $value);
  671. $value = $this->strRemoveOidWithDot($this->currentSnmpTemplate['signal']['SNINDEX'], $value);
  672. $value = trim($value);
  673. }
  674. }
  675. /**
  676. * Preproccess distances indexes.
  677. *
  678. * @return void
  679. */
  680. protected function distanceIndexProcess() {
  681. if ($this->currentSnmpTemplate['signal']['POLLTYPE'] == 'default') {
  682. foreach ($this->snIndex as $ioIndex => $eachSn) {
  683. $tmpDist = $this->snmpwalk($this->currentSnmpTemplate['signal']['DISTANCE'] . '.' . $ioIndex);
  684. $distIndex = $this->strRemoveOidWithDot($this->currentSnmpTemplate['signal']['DISTANCE'], $tmpDist[0]);
  685. $distIndex = $this->strRemove($this->currentSnmpTemplate['signal']['DISTVALUE'], $distIndex);
  686. $explodeDist = explode('=', $distIndex);
  687. $naturalIndex = trim($explodeDist[0]);
  688. if (isset($explodeDist[1])) {
  689. $naturalDist = trim($explodeDist[1]);
  690. $this->distanceIndex[$naturalIndex] = $naturalDist;
  691. }
  692. }
  693. }
  694. if ($this->currentSnmpTemplate['signal']['POLLTYPE'] == 'fast') {
  695. $tmpDist = $this->snmpwalk($this->currentSnmpTemplate['signal']['DISTANCE']);
  696. foreach ($tmpDist as $eachDist) {
  697. $distIndex = $this->strRemoveOidWithDot($this->currentSnmpTemplate['signal']['DISTANCE'], $eachDist);
  698. $distIndex = $this->strRemove($this->currentSnmpTemplate['signal']['DISTVALUE'], $distIndex);
  699. $explodeDist = explode('=', $distIndex);
  700. $naturalIndex = trim($explodeDist[0]);
  701. if (isset($explodeDist[1])) {
  702. $naturalDist = trim($explodeDist[1]);
  703. $this->distanceIndex[$naturalIndex] = $naturalDist;
  704. }
  705. }
  706. }
  707. }
  708. //parser functions
  709. /**
  710. * Parses & stores in cache ZTE OLT ONU ID
  711. *
  712. * @return void
  713. */
  714. protected function onuidParseEpon() {
  715. $macTmp = array();
  716. foreach ($this->macIndex as $ioIndex => $eachMac) {
  717. $eachMac = strtolower($eachMac);
  718. $eachMac = str_replace(" ", ":", $eachMac);
  719. $macTmp[$ioIndex] = $eachMac;
  720. }
  721. $this->olt->writeOnuCache($macTmp);
  722. }
  723. /**
  724. * Parsing and validating input array. Getting hex from dec values.
  725. *
  726. * @param array $decParts
  727. *
  728. * @return array
  729. */
  730. protected function macPartParse($decParts) {
  731. $macPart = array();
  732. if (isset($decParts[1])) {
  733. for ($i = 2; $i <= 7; $i++) {
  734. $macPart[] = dechex($decParts[$i]);
  735. }
  736. foreach ($macPart as &$eachPart) {
  737. if (strlen($eachPart) < 2) {
  738. $eachPart = '0' . $eachPart;
  739. }
  740. }
  741. }
  742. return ($macPart);
  743. }
  744. /**
  745. * Parses & stores in cache OLT ONU interfaces
  746. *
  747. * @return void
  748. */
  749. protected function fdbParseEpon() {
  750. $counter = 1;
  751. $fdbTmp = array();
  752. $macTmp = array();
  753. $result = array();
  754. //fdb index preprocessing
  755. if ((!empty($this->fdbIndex)) and (!empty($this->macIndex))) {
  756. foreach ($this->fdbIndex as $io => $eachfdb) {
  757. $line = explode('=', $eachfdb);
  758. $devOid = trim($line[0]);
  759. $decParts = explode('.', $devOid);
  760. $devIndex = trim($decParts[0]);
  761. $interfaceName = $this->interfaceDecode($devIndex);
  762. if ($interfaceName) {
  763. if (isset($decParts[1])) {
  764. $fdbVlan = trim($decParts[1]);
  765. $fdbMac = implode(':', $this->macPartParse($decParts));
  766. $fdbTmp[$interfaceName][$counter]['mac'] = $fdbMac;
  767. $fdbTmp[$interfaceName][$counter]['vlan'] = $fdbVlan;
  768. $counter++;
  769. }
  770. }
  771. }
  772. //mac index preprocessing
  773. foreach ($this->macIndex as $devIndex => $eachMac) {
  774. if ($this->interfaceDecode($devIndex)) {
  775. $macTmp[$this->interfaceDecode($devIndex)] = $eachMac;
  776. }
  777. }
  778. $realData = array_intersect_key($macTmp, $fdbTmp);
  779. //storing results
  780. foreach ($realData as $devId => $eachMac) {
  781. $result[$macTmp[$devId]] = $fdbTmp[$devId];
  782. }
  783. }
  784. $this->olt->writeFdb($result);
  785. }
  786. /**
  787. * Parses & stores in cache ZTE OLT ONU interfaces
  788. *
  789. * @return void
  790. */
  791. protected function interfaceParseEpon() {
  792. $result = array();
  793. foreach ($this->macIndex as $ioIndex => $eachMac) {
  794. if (isset($this->intIndex[$ioIndex])) {
  795. $eachMac = strtolower($eachMac);
  796. $eachMac = str_replace(" ", ":", $eachMac);
  797. $interface = $this->intIndex[$ioIndex];
  798. $result[$eachMac] = $interface;
  799. } elseif ($this->interfaceDecode($ioIndex)) {
  800. $eachMac = strtolower($eachMac);
  801. $eachMac = str_replace(" ", ":", $eachMac);
  802. $result[$eachMac] = $this->interfaceDecode($ioIndex);
  803. }
  804. }
  805. $this->olt->writeInterfaces($result);
  806. }
  807. /**
  808. * Performs signal preprocessing for sig/mac index arrays and stores it into cache for ZTE OLT
  809. *
  810. * @return void
  811. */
  812. protected function signalParseEpon() {
  813. $result = array();
  814. if ((!empty($this->sigIndex)) and (!empty($this->macIndex))) {
  815. $this->signalIndexProcessing();
  816. $this->macIndexEponProcessing();
  817. $realData = array_intersect_key($this->macIndex, $this->sigIndex);
  818. foreach ($realData as $devId => $io) {
  819. $result[$this->macIndex[$devId]] = $this->sigIndex[$devId];
  820. $tmpSig = $this->sigIndex[$devId];
  821. if ($this->sigIndex[$devId] == 'Offline') {
  822. $tmpSig = -9000;
  823. }
  824. $this->olt->writeSignalHistory($this->macIndex[$devId], $tmpSig);
  825. }
  826. }
  827. $this->olt->writeSignals($result);
  828. }
  829. /**
  830. * Performs signal preprocessing for sig/sn index arrays and stores it into cache for ZTE OLT
  831. *
  832. * @return void
  833. */
  834. protected function signalParseGpon() {
  835. $result = array();
  836. $curDate = curdatetime();
  837. //signal index preprocessing
  838. if ((!empty($this->sigIndex)) and (!empty($this->snIndex))) {
  839. $this->signalIndexProcessing();
  840. $this->serialIndexGponProcessing();
  841. $realData = array_intersect_key($this->snIndex, $this->sigIndex);
  842. //storing results
  843. foreach ($realData as $devId => $eachSn) {
  844. $result[$this->snIndex[$devId]] = $this->sigIndex[$devId];
  845. $tmpSig = $this->sigIndex[$devId];
  846. if ($tmpSig == 'Offline') {
  847. $tmpSig = -9000;
  848. }
  849. //signal history filling
  850. $this->olt->writeSignalHistory($this->snIndex[$devId], $tmpSig);
  851. }
  852. }
  853. $this->olt->writeSignals($result);
  854. }
  855. /**
  856. * Parsing distance for ZTE/Huawei GPON
  857. *
  858. * @param array $distIndex
  859. *
  860. * @return void
  861. */
  862. protected function distanceParseGpon() {
  863. $result = array();
  864. //distance index preprocessing
  865. if (!empty($this->distanceIndex) and !empty($this->snIndex)) {
  866. $realData = array_intersect_key($this->snIndex, $this->distanceIndex);
  867. foreach ($realData as $io => $eachsn) {
  868. $result[$this->snIndex[$io]] = $this->distanceIndex[$io];
  869. }
  870. }
  871. $this->olt->writeDistances($result);
  872. }
  873. /**
  874. * Parses & stores in cache OLT ONU interfaces
  875. *
  876. * @return void
  877. */
  878. protected function fdbParseGpon() {
  879. $counter = 1;
  880. $fdbTmp = array();
  881. $snTmp = array();
  882. $result = array();
  883. //fdb index preprocessing
  884. if ((!empty($this->fdbIndex)) and (!empty($this->snIndex))) {
  885. foreach ($this->fdbIndex as $io => $eachfdb) {
  886. $line = explode('=', $eachfdb);
  887. $devOid = trim($line[0]);
  888. $decParts = explode('.', $devOid);
  889. if ($this->currentSnmpTemplate['onu_reg']['VERSION'] == 'C6XX') {
  890. if (trim($decParts[2]) != 0) {
  891. $vportIndex = trim($decParts[1]);
  892. $devIndex = trim($decParts[2]);
  893. $interfaceVport = $this->gponOltInterfaceDecode($vportIndex);
  894. /*
  895. // It's real data from OLT
  896. // c025.2fac.ff3c 3701 Dynamic vport-1/3/1.5:1
  897. $interfaceVport = str_replace('gpon-onu_', 'vport-', $this->gponOltInterfaceDecode($vportIndex));
  898. $interfaceVport = str_replace(':', '.', $interfaceVport);
  899. $interfaceVportDecode = $this->getDecodeTypeC6XX(decbin((int) $devIndex));
  900. $interfaceName = $interfaceVport . $interfaceVportDecode[3] . ':' . $interfaceVportDecode[4];
  901. $interfaceVportDecode = $this->getDecodeTypeC6XX(decbin((int) $devIndex));
  902. $interfaceName = $interfaceVport . $interfaceVportDecode[3] . ':' . $interfaceVportDecode[4];
  903. */
  904. $interfaceVportDecode = $this->getDecodeTypeC6XX(decbin((int) $devIndex));
  905. $interfaceName = $interfaceVport . $interfaceVportDecode[2];
  906. if ($interfaceName) {
  907. if (isset($decParts[0])) {
  908. $fdbVlan = trim($decParts[0]);
  909. $fdbMac = trim(str_replace('Hex-STRING:', '', $line[1]));
  910. $fdbMac = strtolower(str_replace(' ', ':', $fdbMac));
  911. $fdbTmp[$interfaceName][$counter]['mac'] = $fdbMac;
  912. $fdbTmp[$interfaceName][$counter]['vlan'] = $fdbVlan;
  913. $counter++;
  914. }
  915. }
  916. }
  917. } else {
  918. $devIndex = trim($decParts[0]);
  919. $interfaceName = $this->interfaceDecode($devIndex);
  920. if ($interfaceName) {
  921. if (isset($decParts[1])) {
  922. $fdbVlan = trim($decParts[1]);
  923. $fdbMac = implode(':', $this->macPartParse($decParts));
  924. $fdbTmp[$interfaceName][$counter]['mac'] = $fdbMac;
  925. $fdbTmp[$interfaceName][$counter]['vlan'] = $fdbVlan;
  926. $counter++;
  927. }
  928. }
  929. }
  930. }
  931. //mac index preprocessing
  932. foreach ($this->snIndex as $devIndex => $eachSn) {
  933. $devIndexParts = explode(".", $devIndex);
  934. $onuNumber = $devIndexParts[1];
  935. $interfaceName = $this->gponOltInterfaceDecode($devIndexParts[0]) . $onuNumber;
  936. if ($interfaceName) {
  937. $snTmp[$interfaceName] = $eachSn;
  938. }
  939. }
  940. $realData = array_intersect_key($snTmp, $fdbTmp);
  941. //storing results
  942. foreach ($realData as $devId => $eachSn) {
  943. $result[$snTmp[$devId]] = $fdbTmp[$devId];
  944. }
  945. }
  946. $this->olt->writeFdb($result);
  947. }
  948. /**
  949. * Parses & stores in cache ZTE OLT ONU interfaces
  950. *
  951. * @return void
  952. */
  953. protected function interfaceParseGpon() {
  954. $result = array();
  955. //storing results
  956. foreach ($this->snIndex as $ioIndex => $eachSn) {
  957. $ioIndexSplit = explode(".", $ioIndex);
  958. $result[$eachSn] = $this->gponOltInterfaceDecode($ioIndexSplit[0]) . $ioIndexSplit[1];
  959. }
  960. $this->olt->writeInterfaces($result);
  961. }
  962. /**
  963. * Parses & stores in cache ZTE OLT ONU interfaces
  964. *
  965. * @return void
  966. */
  967. protected function interfaceParseHuaweiGpon() {
  968. $result = array();
  969. $interfaces = array();
  970. $data = $this->snmpwalk($this->currentSnmpTemplate['misc']['INTERFACENAME']);
  971. if (!empty($data)) {
  972. foreach ($data as $io => $value) {
  973. $split = explode("=", $value);
  974. $eachOid = trim($this->strRemoveOidWithDot($this->currentSnmpTemplate['misc']['INTERFACENAME'], $split[0]));
  975. $interfaces[$eachOid] = trim(str_replace('STRING:', '', $split[1]));
  976. }
  977. }
  978. //storing results
  979. foreach ($this->snIndex as $ioIndex => $eachSn) {
  980. $ioIndexSplit = explode(".", $ioIndex);
  981. if (isset($interfaces[$ioIndexSplit[0]])) {
  982. $result[$eachSn] = $interfaces[$ioIndexSplit[0]] . ':' . $ioIndexSplit[1];
  983. }
  984. }
  985. $this->olt->writeInterfaces($result);
  986. }
  987. /**
  988. * Parses & stores in cache ZTE OLT ONU ID
  989. *
  990. * @return void
  991. */
  992. protected function onuidParseGpon() {
  993. $snTmp = array();
  994. if ($this->currentSnmpTemplate['onu_reg']['VERSION'] == 'C6XX') {
  995. $snTmp = $this->snIndex;
  996. } else {
  997. foreach ($this->snIndex as $ioIndex => $eachSn) {
  998. $snTmp[$this->interfaceDecode($ioIndex)] = $eachSn;
  999. }
  1000. }
  1001. $this->olt->writeOnuCache($snTmp);
  1002. }
  1003. /**
  1004. * Parses & stores in cache ZTE OLT ONU ID
  1005. *
  1006. * @return void
  1007. */
  1008. protected function onuidParseHuaweiGpon() {
  1009. $snTmp = array();
  1010. foreach ($this->snIndex as $ioIndex => $eachSn) {
  1011. $snTmp[$this->interfaceDecode($ioIndex)] = $eachSn;
  1012. }
  1013. $this->olt->writeOnuCache($snTmp);
  1014. }
  1015. /**
  1016. * Parsing serial numbers;
  1017. *
  1018. * @return void
  1019. */
  1020. protected function serialNumberParse() {
  1021. $result = array();
  1022. foreach ($this->snIndex as $rawIo => $rawEach) {
  1023. $split = explode("=", $rawEach);
  1024. if (isset($split[1])) {
  1025. $naturalIndex = trim($split[0]);
  1026. $rawSn = trim($split[1]);
  1027. $tmpSn = explode(" ", $rawSn);
  1028. $check = trim($tmpSn[0]);
  1029. if ($check == 'STRING:') {
  1030. $naturalSn = $this->serialNumberBinaryParse($tmpSn[1]);
  1031. } else {
  1032. $naturalSn = $this->serialNumberHexParse($tmpSn);
  1033. }
  1034. $result[$naturalIndex] = $naturalSn;
  1035. }
  1036. }
  1037. unset($this->snIndex);
  1038. $this->snIndex = $result;
  1039. }
  1040. /**
  1041. * Parsing serial number in binary format and coverting it to needed format.
  1042. *
  1043. * @param array $rawSn
  1044. *
  1045. * @return string
  1046. */
  1047. protected function serialNumberBinaryParse($rawSn) {
  1048. $parts = array();
  1049. $hexSn = bin2hex($rawSn);
  1050. if (strlen($hexSn) == 20) {
  1051. $parts[0] = $this->serialNumberPartsTranslate($hexSn[2] . $hexSn[3]);
  1052. $parts[1] = $this->serialNumberPartsTranslate($hexSn[4] . $hexSn[5]);
  1053. $parts[2] = $this->serialNumberPartsTranslate($hexSn[6] . $hexSn[7]);
  1054. $parts[3] = $this->serialNumberPartsTranslate($hexSn[8] . $hexSn[9]);
  1055. $parts[4] = '';
  1056. for ($i = 10; $i <= 17; $i++) {
  1057. $parts[4] .= $hexSn[$i];
  1058. }
  1059. } else {
  1060. $parts[0] = $this->serialNumberPartsTranslate($hexSn[0] . $hexSn[1]);
  1061. $parts[1] = $this->serialNumberPartsTranslate($hexSn[2] . $hexSn[3]);
  1062. $parts[2] = $this->serialNumberPartsTranslate($hexSn[4] . $hexSn[5]);
  1063. $parts[3] = $this->serialNumberPartsTranslate($hexSn[6] . $hexSn[7]);
  1064. $parts[4] = '';
  1065. for ($i = 8; $i <= 15; $i++) {
  1066. $parts[4] .= $hexSn[$i];
  1067. }
  1068. }
  1069. $result = implode("", $parts);
  1070. return ($result);
  1071. }
  1072. /**
  1073. * Parsing serial number in hex format and coverting it to needed format.
  1074. *
  1075. * @param array $rawSn
  1076. *
  1077. * @return string
  1078. */
  1079. protected function serialNumberHexParse($rawSn) {
  1080. $parts[0] = $this->serialNumberPartsTranslate($rawSn[0]);
  1081. $parts[1] = $this->serialNumberPartsTranslate($rawSn[1]);
  1082. $parts[2] = $this->serialNumberPartsTranslate($rawSn[2]);
  1083. $parts[3] = $this->serialNumberPartsTranslate($rawSn[3]);
  1084. $parts[4] = $rawSn[4] . $rawSn[5] . $rawSn[6] . $rawSn[7];
  1085. $result = implode("", $parts);
  1086. return ($result);
  1087. }
  1088. /**
  1089. * Check mode to convert serial number string vs raw.
  1090. *
  1091. * @param string $part
  1092. *
  1093. * @return string
  1094. */
  1095. protected function serialNumberPartsTranslate($part) {
  1096. if ($this->currentSnmpTemplate['signal']['SNMODE'] == 'STRING') {
  1097. return ($this->hexToString($part));
  1098. }
  1099. if ($this->currentSnmpTemplate['signal']['SNMODE'] == 'PURE') {
  1100. return ($part);
  1101. }
  1102. }
  1103. /**
  1104. * Parses uptime data and saves it into uptime cache
  1105. *
  1106. * @param int $oltid
  1107. * @param string $uptimeRaw
  1108. *
  1109. * @return void
  1110. */
  1111. protected function uptimeParse() {
  1112. $uptimeIndexOid = $this->currentSnmpTemplate['system']['UPTIME'];
  1113. $uptimeRaw = $this->snmp->walk($this->oltFullAddress, $this->oltCommunity, $uptimeIndexOid, PONizer::SNMPCACHE);
  1114. if (!empty($this->oltid) and !empty($uptimeRaw)) {
  1115. $uptimeRaw = explode(')', $uptimeRaw);
  1116. $uptimeRaw = $uptimeRaw[1];
  1117. $uptimeRaw = trim($uptimeRaw);
  1118. $this->olt->writeUptime($uptimeRaw);
  1119. }
  1120. }
  1121. /**
  1122. * Parses temperature data and saves it into uptime cache
  1123. *
  1124. * @param int $oltid
  1125. * @param string $uptimeRaw
  1126. *
  1127. * @return void
  1128. */
  1129. protected function temperatureParse() {
  1130. $temperatureIndexOid = $this->currentSnmpTemplate['system']['TEMPERATURE'];
  1131. $tempRaw = $this->snmp->walk($this->oltFullAddress, $this->oltCommunity, $temperatureIndexOid, PONizer::SNMPCACHE);
  1132. if (!empty($this->oltid) and !empty($tempRaw)) {
  1133. $tempRaw = explode(':', $tempRaw);
  1134. $tempRaw = $tempRaw[1];
  1135. $tempRaw = trim($tempRaw);
  1136. $this->olt->writeTemperature($tempRaw);
  1137. }
  1138. }
  1139. //Main section
  1140. /**
  1141. * Polling EPON device
  1142. *
  1143. * @return void
  1144. */
  1145. public function pollEpon() {
  1146. $this->macIndexCalc();
  1147. $this->sigIndexCalc($this->macIndex);
  1148. $this->signalParseEpon();
  1149. if (isset($this->currentSnmpTemplate['misc'])) {
  1150. if (isset($this->currentSnmpTemplate['misc']['CARDOFFSET'])) {
  1151. $this->intIndexCalcEpon();
  1152. $this->fdbCalc();
  1153. $this->fdbParseEpon();
  1154. $this->interfaceParseEpon();
  1155. $this->onuidParseEpon();
  1156. }
  1157. }
  1158. }
  1159. /**
  1160. * Polling GPON device
  1161. *
  1162. * @return void
  1163. */
  1164. public function pollGpon() {
  1165. $this->snIndexProcess();
  1166. $this->serialNumberParse();
  1167. $this->sigIndexCalc($this->snIndex);
  1168. $this->signalParseGpon();
  1169. if (isset($this->currentSnmpTemplate['signal']['DISTANCE'])) {
  1170. $this->distanceIndexProcess();
  1171. $this->distanceParseGpon();
  1172. }
  1173. if (isset($this->currentSnmpTemplate['misc'])) {
  1174. if (isset($this->currentSnmpTemplate['misc']['CARDOFFSET'])) {
  1175. $this->fdbCalc();
  1176. $this->fdbParseGpon();
  1177. $this->interfaceParseGpon();
  1178. $this->onuidParseGpon();
  1179. }
  1180. }
  1181. //getting others system data from OLT
  1182. if (isset($this->currentSnmpTemplate['system'])) {
  1183. //OLT uptime
  1184. if (isset($this->currentSnmpTemplate['system']['UPTIME'])) {
  1185. $this->uptimeParse();
  1186. }
  1187. //OLT temperature
  1188. if (isset($this->currentSnmpTemplate['system']['TEMPERATURE'])) {
  1189. $this->temperatureParse();
  1190. }
  1191. }
  1192. }
  1193. /**
  1194. * Polling Huawei GPON device
  1195. *
  1196. * @return void
  1197. */
  1198. public function huaweiPollGpon() {
  1199. $this->snIndexProcess();
  1200. $this->serialNumberParse();
  1201. $this->sigIndexCalc($this->snIndex);
  1202. $this->signalParseGpon();
  1203. if (isset($this->currentSnmpTemplate['signal']['DISTANCE'])) {
  1204. $this->distanceIndexProcess();
  1205. $this->distanceParseGpon();
  1206. }
  1207. if (isset($this->currentSnmpTemplate['misc']['INTERFACENAME'])) {
  1208. $this->interfaceParseHuaweiGpon();
  1209. //$this->onuidParseHuaweiGpon();
  1210. }
  1211. }
  1212. }