Guest User

Untitled

a guest
May 4th, 2017
877
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $oltip = "10.10.10.10";
  2. $oltrocommunity = "public";
  3. $oidgetcardtype = ".1.3.6.1.4.1.3902.1015.2.1.1.3.1.4.1.1";
  4. $oidcardcpuload = ".1.3.6.1.4.1.3902.1015.2.1.1.3.1.9.1.1";
  5. $oidcardmemutil = ".1.3.6.1.4.1.3902.1015.2.1.1.3.1.11.1.1";
  6. $oidonuifnumber = ".1.3.6.1.4.1.3902.1012.3.28.3.1.8";
  7. $oidonusn = ".1.3.6.1.4.1.3902.1012.3.28.1.1.5";
  8. $oidonusignal = ".1.3.6.1.4.1.3902.1015.1010.11.2.1.2";
  9. $oidonudescr = ".1.3.6.1.4.1.3902.1012.3.28.1.1.2";
  10. $oidsysname = ".1.3.6.1.2.1.1.5.0";
  11. $oidonumodel = ".1.3.6.1.4.1.3902.1012.3.50.11.2.1.9";
  12. $oidonulanifstatus = "1.3.6.1.4.1.3902.1012.3.50.14.1.1.7";
  13. $oidonulanifoperstatus = "1.3.6.1.4.1.3902.1012.3.50.14.1.1.6";
  14. $oidonuuptime = "1.3.6.1.4.1.3902.1012.3.50.11.2.1.20";
  15. $oidonudistance = ".1.3.6.1.4.1.3902.1012.3.11.4.1.2";
  16.  
  17.  
  18. $gpon_id['gpon-olt_1/1/1'] = 268501248;
  19. $gpon_id['gpon-olt_1/1/2'] = 268501504;
  20. $gpon_id['gpon-olt_1/1/3'] = 268501760;
  21. $gpon_id['gpon-olt_1/1/4'] = 268502016;
  22. $gpon_id['gpon-olt_1/1/5'] = 268502272;
  23. $gpon_id['gpon-olt_1/1/6'] = 268502528;
  24. $gpon_id['gpon-olt_1/1/7'] = 268502784;
  25. $gpon_id['gpon-olt_1/1/8'] = 268503040;
  26. $gpon_id['gpon-olt_1/1/9'] = 268503296;
  27. $gpon_id['gpon-olt_1/1/10'] = 268503552;
  28. $gpon_id['gpon-olt_1/1/11'] = 268503808;
  29. $gpon_id['gpon-olt_1/1/12'] = 268504064;
  30. $gpon_id['gpon-olt_1/1/13'] = 268504320;
  31. $gpon_id['gpon-olt_1/1/14'] = 268504576;
  32. $gpon_id['gpon-olt_1/1/15'] = 268504832;
  33. $gpon_id['gpon-olt_1/1/16'] = 268505088;
  34. $gpon_id['gpon-olt_1/2/1'] = 268566784;
  35. $gpon_id['gpon-olt_1/2/2'] = 268567040;
  36. $gpon_id['gpon-olt_1/2/3'] = 268567296;
  37. $gpon_id['gpon-olt_1/2/4'] = 268567552;
  38. $gpon_id['gpon-olt_1/2/5'] = 268567808;
  39. $gpon_id['gpon-olt_1/2/6'] = 268568064;
  40. $gpon_id['gpon-olt_1/2/7'] = 268568320;
  41. $gpon_id['gpon-olt_1/2/8'] = 268568576;
  42. $gpon_id['gpon-olt_1/2/9'] = 268568832;
  43. $gpon_id['gpon-olt_1/2/10'] = 268569088;
  44. $gpon_id['gpon-olt_1/2/11'] = 268569344;
  45. $gpon_id['gpon-olt_1/2/12'] = 268569600;
  46. $gpon_id['gpon-olt_1/2/13'] = 268569856;
  47. $gpon_id['gpon-olt_1/2/14'] = 268570112;
  48. $gpon_id['gpon-olt_1/2/15'] = 268570368;
  49. $gpon_id['gpon-olt_1/2/16'] = 268570624;
  50.  
  51.  
  52. function port_oid_to_if_convert($portdec) {
  53. // Конвертирует OID интерфейса в название порта
  54. $dec = decbin($portdec);
  55. $mactypenum = substr("$dec", 0, -28); // type 4 bit
  56. $macshelfnum = substr("$dec", 4, -24); // shelf 4 bit
  57. $macslotnum = substr("$dec", 8, -20); // slot 4 bit
  58. $macoltportnum = substr("$dec", 12, -16); // olt port 4 bit
  59. $maconuportnum = substr("$dec", 16, -8); // onu port 8 bit
  60. $port = (bindec($macshelfnum) + 1) . "/" . (bindec($macslotnum) + 1) . "/" . (bindec($macoltportnum) + 1) . ":" . (bindec($maconuportnum) + 1);
  61. return $port;
  62. }
  63.  
  64. function mac_dec_to_hex_convert($macdec) {
  65. // Конвертирует MAC адрес с DEC в HEX формат
  66. $macdec = explode(".", $macdec);
  67. foreach ($macdec as $key => $value) {
  68. if ($value < 16) {
  69. $machex = "0" . dechex($value);
  70. } else {
  71. $machex = dechex($value);
  72. }
  73. $machexarr[$key] = $machex;
  74. }
  75. return strtoupper($machexarr[0] . ":" . $machexarr[1] . ":" . $machexarr[2] . ":" . $machexarr[3] . ":" . $machexarr[4] . ":" . $machexarr[5]);
  76. }
  77.  
  78. function PortMacVlanConvert($oid) {
  79. // Разбирает OID на название интерфейса, VLAN, MAC
  80. $oidtmp = explode(".", $oid);
  81. $oidiface = $oidtmp[0];
  82. $oidvlan = $oidtmp[1];
  83. $oidmac = $oidtmp[2] . "." . $oidtmp[3] . "." . $oidtmp[4] . "." . $oidtmp[5] . "." . $oidtmp[6] . "." . $oidtmp[7];
  84. $array['interface'] = port_oid_to_if_convert($oidiface);
  85. $array['vlan'] = $oidvlan;
  86. $array['mac'] = mac_dec_to_hex_convert($oidmac);
  87. return $array;
  88. }
  89.  
  90. function port_if_to_oid_convert($port) {
  91. // Конвертирует название интерфейса в OID
  92. $port = str_replace("/", " ", $port);
  93. $port = str_replace(":", " ", $port);
  94. $port = explode(" ", $port);
  95. $shelf = str_pad(decbin($port[0] - 1), 4, "0", STR_PAD_LEFT);
  96. $slot = str_pad(decbin($port[1] - 1), 4, "0", STR_PAD_LEFT);
  97. $oltport = str_pad(decbin($port[2] - 1), 4, "0", STR_PAD_LEFT);
  98. $onuport = str_pad(decbin($port[3] - 1), 8, "0", STR_PAD_LEFT);
  99. $result = "1010" . $shelf . $slot . $oltport . $onuport . "00000000";
  100. $result = bindec($result);
  101. return $result;
  102. }
RAW Paste Data