'; echo "

Свич ".$host_name." (".$sw_type."), порт ".$port_num."

"; echo "

Абонент: $abon_dogov $no_money

$agg
"; } else { echo ''; echo "".$host_name." ".$sw_type." ".$port_num.""; echo "$abon_dogov $no_money $agg"; } //echo "

Абонент: $abon_dogov $no_money

"; $admin_status = "Down"; $oper_status = "Down"; $admin_state = ""; $oper_state = ""; //echo $snmp_allow." ".$sw_model_id; if ($host_reachable){//($snmp_allow == "1"){ error_log($host." ,community=". $community." ,oid=". $admin_oid.$port_oid, 3, self::USER_ERROR_DIR); $admin_state = snmp2_get($host, $community, $admin_oid.$port_oid); $oper_state = snmp2_get($host, $community, $oper_oid.$port_oid); //echo $host.','. $community.','. $oper_oid.$port_oid.'
'; $admin_state = str_replace("INTEGER:", " ", $admin_state); if(preg_match("/(\d+)/", $admin_state, $m)) $admin_state = $m[1]; $oper_state = str_replace("INTEGER:", " ", $oper_state); if(preg_match("/(\d+)/", $oper_state, $m)) $oper_state = $m[1]; //echo $oper_state if ($oper_state == "1"){ switch ($sw_model_id){ case 8: case 26: $mac = mac_huaweiS3026();break; case 11: $mac = mac_hp(); break; // HP Procurve case 6: $mac = mac_cisco(); break;//Cisco default: $mac = mac_dlink(); // D-Link, Alcatel, EdgeCore, Huawei }; }; //echo $oper_state.' - '.$sw_model_id.' - '.$mac; $isepmp = false; if ($sw_model_id == 12){//($isepmp == "1"){ // ePMP $isepmp = true; $mac = mac_epmp($host, $community, $vlan); $oper_state = $mac == '' ? '2' : '1'; if ($vlan != 0) $vlan=$vlan." (".strtoupper(dechex($vlan)).")"; }; $isgpon = false; if ($sw_model_id == 16 or $sw_model_id == 19 or $sw_model_id == 31) {//Gpon BDCOM P3310B or P3310C or P3310D $mac = mac_gpon($host, $community, $vlan); //$oper_state = $mac == '' ? '2' : '1'; $isgpon = true; }; if ($sw_model_id == 24 ){ //Gpon Stels $mac = mac_gpon_stels($host, $community, $vlan); //$oper_state = $mac == '' ? '2' : '1'; $isgpon = true; }; if ($sw_model_id == 32 or $sw_model_id == 33){ //Gpon BDCOM3608 $mac = mac_gpon_bdcom3608($host, $community, $vlan); //$oper_state = $mac == '' ? '2' : '1'; $isgpon = true; }; }; //$snmp_allow == "1" $isepmp != "1" //$visible = $_SESSION['login_role'] == "admin" & $protect == "0" & $host_reachable & !$isepmp & !$isgpon ? "visible" : "hidden"; $visible = "visible"; if ($admin_state == "1"){$admin_status = "Up";}; //if ($oper_state == "2") {$oper_status = "DOWN";}; if ($oper_state == "1") {$oper_status = "Up";}; if (!$host_reachable){$sw_nr ='свич не доступен';}; // Agg interface status //$sshconnection = ssh2_connect('172.25.5.4', 22); //ssh2_auth_password($sshconnection, 'aggint', 'v4n#yKMS1AcmuHbHzXrern3H'); $sshconnection = ssh2_connect('172.25.5.20', 22); ssh2_auth_password($sshconnection, 'aggint', '127001'); $stream = ssh2_exec($sshconnection, '/usr/local/sbin/check-user-int '.$abon_dogov); stream_set_blocking($stream,true); $stream_out = ssh2_fetch_stream($stream, SSH2_STREAM_STDIO); $agg_status = stream_get_contents($stream_out); //$agg_status = agg_int_status(); if($type != "xml") { echo "
$sw_nr$status0
Admin status: ".$admin_status." $status1
Oper status: ".$oper_status." $status2
Mac address: $mac $status3
Vlan: $vlan $status4
Agg int status: $agg_status $status5

"; //echo "snmp2_get(".$host.",". $community.",". $oper_oid.$port_oid.")
"; //echo "aaa = ". $admin_state ."
" if ($oper_state != "1") echo "Нет линка на свиче ".$host_name." порт ".$port_num; //echo "
"; echo "
$res"; echo ' '; } else { echo " ".$status0." ".$admin_status." ".$oper_status." ".$mac." $vlan $status3 $agg_status "; //echo "oper_state = ".$oper_state."
"; if ($oper_state != "1") echo "Нет линка на свиче ".$host_name." порт ".$port_num.""; //echo "
"; $time_e = date("Y-m-d H:i:s"); echo "$res
"; } function mac_dlink() { $mac_oid = ".1.3.6.1.2.1.17.7.1.2.2.1.2"; $a = snmprealwalk($GLOBALS['host'], $GLOBALS['community'], $mac_oid); $a_val = array_values($a); $a_key = array_keys($a); $port_count = 0; for ($i=0; $i < count($a_val); $i++) { if ($a_val[$i] == "INTEGER: ".$GLOBALS['port_num']) { $port_count++; $port_id = $i; } //echo $i." = ".$b[$i]."
"; }; //echo "Port count = ".$port_count."
"; if ($port_count == "0"){ return ""; exit; }; if ($port_count == "1"){ $res_oid = $a_key[$port_id]; $x = str_replace(".1.3", "iso.3", $mac_oid); //echo "x = ".$x."
"; $y = str_replace($x, "", $res_oid); //echo "y = ".$y."
"; $nums = explode(".", $y); //for ($k=0; $k < count($nums); $k++){ // echo $k." = [".$nums[$k]."]
"; //}; $GLOBALS['vlan'] = $nums[1]; $mac_addr = sprintf('%02X-%02X-%02X-%02X-%02X-%02X', $nums[2], $nums[3], $nums[4], $nums[5], $nums[6], $nums[7]); //echo "Vlan = ".$vlan."
"; //echo "Mac = ".$mac_addr."
"; //exit; } else { $mac_addr = "Много маков ($port_count)"; }; return $mac_addr; }; function mac_hp(){ $mac_oid = ".1.3.6.1.2.1.17.4.3.1.2"; $a = snmprealwalk($GLOBALS['host'], $GLOBALS['community'], $mac_oid); $a_val = array_values($a); $a_key = array_keys($a); $port_count = 0; for ($i=0; $i < count($a_val); $i++) { if ($a_val[$i] == "INTEGER: ".$GLOBALS['port_num']) { $port_count++; $port_id = $i; } //echo $i." = ".$b[$i]."
"; }; //echo "Port count = ".$port_count."
"; if ($port_count == "0"){ return ""; exit; }; if ($port_count == "1"){ $res_oid = $a_key[$port_id]; $x = str_replace(".1.3", "iso.3", $mac_oid); //echo "x = ".$x."
"; $y = str_replace($x, "", $res_oid); //echo "y = ".$y."
"; $nums = explode(".", $y); //for ($k=0; $k < count($nums); $k++){ // echo $k." = [".$nums[$k]."]
"; //}; //$GLOBALS['vlan'] = $nums[1]; $mac_addr = sprintf('%02X-%02X-%02X-%02X-%02X-%02X', $nums[1], $nums[2], $nums[3], $nums[4], $nums[5], $nums[6]); //echo "Vlan = ".$vlan."
"; //echo "Mac = ".$mac_addr."
"; //exit; } else { $mac_addr = "Много маков"; }; return $mac_addr; }; function mac_cisco(){ $vlan_all_oid = ".1.3.6.1.4.1.9.9.46.1.3.1.1.2"; $vlan_oid = ".1.3.6.1.2.1.17.1.4.1.2"; $mac_oid = ".1.3.6.1.2.1.17.4.3.1.2"; $a = snmprealwalk($GLOBALS['host'], $GLOBALS['community'], $vlan_all_oid); //$a_val_vlan = array_values($a); $a_key_vlan = array_keys($a); //$vlan_count = 0; // находим список vlan for ($i=0; $i < count($a_key_vlan); $i++) { $a_key_oid = $a_key_vlan[$i]; $a_key_vlan[$i] = str_replace("iso", ".1", $a_key_oid); $a_key_vlan[$i] = str_replace($vlan_all_oid.".1.", " ", $a_key_vlan[$i]); // $vlan_count++; //echo $a_key_vlan[$i]."
"; }; $vlan_true = 0; $myvlan=""; //находим по кадому vlan порты и вычисляем в каком вилане живет наш порт for ($j=0; $j < count($a_key_vlan); $j++){ //$comm = $GLOBALS['community']."@".trim($a_key_vlan[$j]); //echo $comm."
"; //$b = snmprealwalk($GLOBALS['host'], $GLOBALS['community']."@".trim($a_key_vlan[$j]), $vlan_oid); $b = snmp2_real_walk($GLOBALS['host'], $GLOBALS['community']."@".trim($a_key_vlan[$j]), $vlan_oid); if(!$b ) continue; $a_ports = array_values($b); //echo $a_key_vlan[$j]."
"; for ($k=0; $k < count($a_ports); $k++){ $a_ports[$k] = trim(str_replace("INTEGER:", " ", $a_ports[$k])); if ($a_ports[$k] == $GLOBALS['port_oid']){ $myvlan = trim($a_key_vlan[$j]); break; }; //if ($vlan_true == 1) // break; }; }; //echo $myvlan; $count_mac=0; // находим маки в нашем вилане if ($myvlan != ""){ $GLOBALS['vlan'] = $myvlan; //echo $mac_oid."
"; //echo $comm = $GLOBALS['community']."@".$myvlan; $c = snmprealwalk($GLOBALS['host'], $GLOBALS['community']."@".$myvlan, $mac_oid); $a_ports = array_values($c); $a_macs = array_keys($c); for ($i=0; $i < count($a_macs); $i++){ $z = trim(str_replace("INTEGER: ", "", $a_ports[$i])); //echo $z."
"; if ($z == $GLOBALS['port_num']){ //echo $a_macs[$i]."
"; $snmp_mac = $a_macs[$i]; $count_mac++; }; if ($count_mac > 1){ $mac_addr = "Много маков"; break; }; $snmp_mac = str_replace("iso", ".1", $snmp_mac); $snmp_mac = str_replace($mac_oid.".", "", $snmp_mac); //echo $a_macs[$i]."
"; //echo $snmp_mac."
"; $nums = explode(".", $snmp_mac); //for ($k=0; $k < count($nums); $k++){ // echo $k." = [".$nums[$k]."]
";}; $mac_addr = sprintf('%02X-%02X-%02X-%02X-%02X-%02X', $nums[0], $nums[1], $nums[2], $nums[3], $nums[4], $nums[5]); }; }; return $mac_addr; }; function mac_epmp($host, $community, $vlan){ $mac_all_oid = ".1.3.6.1.4.1.17713.21.1.2.30.1.1"; $ul_rssi_oid = ".1.3.6.1.4.1.17713.21.1.2.30.1.4."; $dl_rssi_oid = ".1.3.6.1.4.1.17713.21.1.2.30.1.5."; $epmp_ver = snmp2_get($host, $community, ".1.3.6.1.4.1.17713.21.1.1.1.0"); // current version $epmp_ver = str_replace("STRING: ", "", $epmp_ver); $epmp_ver = str_replace("\"", "", $epmp_ver); switch ($epmp_ver){ case "2.5" : $ip_oid = ".1.3.6.1.4.1.17713.21.1.2.30.1.11."; break; default : $ip_oid = ".1.3.6.1.4.1.17713.21.1.2.30.1.10."; }; $GLOBALS['res'] = "Sector SW version: ".$epmp_ver; $epmp_num = 0; $epmp_mac =""; $epmp_vlan = "000456".dechex($vlan); $a = snmprealwalk($host, $community, $mac_all_oid); $a_nums = array_keys($a); $a_macs = array_values($a); for ($i = 0; $i < count($a_macs); $i++) { $snmp_mac = str_replace("STRING: ", "", $a_macs[$i]); $snmp_mac = str_replace("\"", "", $snmp_mac); $snmp_mac = str_replace(":", "", $snmp_mac); if ($snmp_mac == $epmp_vlan){ $epmp_num = str_replace("iso.3.6.1.4.1.17713.21.1.2.30.1.1.", "", $a_nums[$i]); break; }; }; //return "epmp_num=".$epmp_num." a_mac=".$a_macs[$epmp_num]." snmp_mac=".$snmp_mac." epmp_vlan=".$epmp_vlan." - a_num=".$a_nums[$epmp_num]; //exit; if ($epmp_num != 0){ $epmp_mac = str_replace("STRING: ", "", $a_macs[$epmp_num-1]); $epmp_mac = str_replace("\"", "", $epmp_mac); $GLOBALS['admin_state'] = "1"; $GLOBALS['oper_state'] = "1"; $ul_rssi_dbm = snmp2_get($host, $community, $ul_rssi_oid.$epmp_num); $ul_rssi_dbm = str_replace("INTEGER: ", "", $ul_rssi_dbm); $dl_rssi_dbm = snmp2_get($host, $community, $dl_rssi_oid.$epmp_num); $dl_rssi_dbm = str_replace("INTEGER: ", "", $dl_rssi_dbm); $ip = snmp2_get($host, $community, $ip_oid.$epmp_num); $ip = str_replace("IpAddress: ", "", $ip); if ($ip) { $epmp_ver = snmp2_get($ip, $community, ".1.3.6.1.4.1.17713.21.1.1.1.0"); // current version $epmp_ver = str_replace("STRING: ", "", $epmp_ver); $epmp_ver = str_replace("\"", "", $epmp_ver); }; $GLOBALS['status0'] = 'RSSI, dBm'; $GLOBALS['status1'] = "DL: ".$dl_rssi_dbm; $GLOBALS['status2'] = "UL: ".$ul_rssi_dbm; $GLOBALS['status3'] = "IP: ".$ip.""; $GLOBALS['status4'] = "SW: ".$epmp_ver; }; return $epmp_mac; }; function mac_gpon($host, $community, $vlan){ $vlans_oid = ".1.3.6.1.4.1.3320.101.12.1.1.3"; $oper_state_oid = ".1.3.6.1.2.1.2.2.1.8."; $rx_power_oid_b = ".1.3.6.1.4.1.3320.9.183.1.1.5."; $rx_power_oid_c = ".1.3.6.1.4.1.3320.101.108.1.3."; // не на вcех онушках получает уровни, но значения которые получет реальны $onu_rx_power_oid = ".1.3.6.1.4.1.3320.101.10.5.1.5."; //$rx_power_oid_c = ".1.3.6.1.4.1.3320.101.10.5.1.5."; // показывает иногда неправильные уровни, но иногда есть и реальные $onu_name_oid = ".1.3.6.1.2.1.2.2.1.2."; $ver_oid = ".1.3.6.1.2.1.1.1.0"; $mac_oid = ".1.3.6.1.4.1.3320.101.10.1.1.3."; $a = snmprealwalk($host, $community, $vlans_oid); $a_ports = array_keys($a); $a_vlans = array_values($a); $mac = ""; $GLOBALS['admin_state'] = "1"; $GLOBALS['oper_state'] = "0"; for ($i = 0; $i < count($a_vlans); $i++){ $gpon_vlan = $a_vlans[$i]; $gpon_vlan = str_replace("INTEGER: ", "", $gpon_vlan); if ($gpon_vlan == $vlan) { $arr_port_id = $i; break; }; }; if (isset($arr_port_id)) { $gpon_port_id = $a_ports[$arr_port_id]; //$gpon_port_id = str_replace("iso.3.6.1.4.1.3320.101.12.1.1.3.", "", $gpon_port_id); //$gpon_port_id = str_replace(".1", "", $gpon_port_id); preg_match("/(\d+).1$/", $gpon_port_id, $m); $gpon_port_id = $m[1]; $port_oper_state = snmp2_get($host, $community, $oper_state_oid.$gpon_port_id); $port_oper_state = str_replace("INTEGER: ", "", $port_oper_state); if(preg_match("/(\d+)/", $port_oper_state, $m)) $port_oper_state = $m[1]; $ver = snmp2_get($host, $community, $ver_oid); $pos = stristr($ver, "3310"); if (substr($pos, 0, 5) == "3310B") { $rx_power = snmp2_get($host, $community, $rx_power_oid_b.$gpon_port_id); $rx_power = str_replace("INTEGER: ", "", $rx_power); $rx_power = $rx_power * 0.1; $onu_rx_power = snmp2_get($host, $community, $onu_rx_power_oid.$gpon_port_id); $onu_rx_power = str_replace("INTEGER: ", "", $onu_rx_power); $onu_rx_power = $onu_rx_power * 0.1; $GLOBALS['status2'] = "RxPower, dBm"; $GLOBALS['status3'] = $rx_power.'/'.$onu_rx_power; }; if ((substr($pos, 0, 5) == "3310C") or (substr($pos, 0, 5) == "3310D")) { $rx_power = snmp2_get($host, $community, $rx_power_oid_c.$gpon_port_id); $rx_power = str_replace("INTEGER: ", "", $rx_power); $onu_rx_power = snmp2_get($host, $community, $onu_rx_power_oid.$gpon_port_id); $onu_rx_power = str_replace("INTEGER: ", "", $onu_rx_power); $onu_rx_power = $onu_rx_power * 0.1; if ($rx_power != -65535){ $rx_power = $rx_power * 0.1; $GLOBALS['status2'] = "RxPower, dBm"; $GLOBALS['status3'] = $rx_power.'/'.$onu_rx_power; }; }; /*if (substr($pos, 0, 5) == "3310D") { $rx_power = snmp2_get($host, $community, $rx_power_oid_d.$gpon_port_id); $rx_power = str_replace("INTEGER: ", "", $rx_power); $rx_power = $rx_power * 0.1; $onu_rx_power = snmp2_get($host, $community, $onu_rx_power_oid.$gpon_port_id); $onu_rx_power = str_replace("INTEGER: ", "", $onu_rx_power); $onu_rx_power = $onu_rx_power * 0.1; $GLOBALS['status2'] = "RxPower, dBm"; $GLOBALS['status3'] = $rx_power.'/'.$onu_rx_power; };*/ $onu_name = snmp2_get($host, $community, $onu_name_oid.$gpon_port_id); $onu_name = str_replace("STRING: ", "", $onu_name); $onu_name = str_replace("\"", "", $onu_name); $mac = snmp2_get($host, $community, $mac_oid.$gpon_port_id); $mac = str_replace("Hex-STRING: ", "", $mac); $GLOBALS['oper_state'] = $port_oper_state; $GLOBALS['status0'] = $onu_name; }; return $mac; /*$mac_oid = ".1.3.6.1.4.1.3320.101.10.1.1.3."; $macs_oid_next = $macs_oid.".252.250.247.198.31.139"; $snmp_res = snmprealwalk($host, $community, ".1.3.6.1.2.1.17.4.3.1.2.252.250.247.198.31.139"); $snmp_res_key = array_keys($snmp_res); $snmp_res_val = array_values($snmp_res); return count($snmp_res_key)." ".$snmp_res_key[0].$snmp_res_val[0]; */ /* exit; while (true) { }; */ //return "FF-FF-FF-FF-FF-FF"; }; function mac_gpon_stels($host, $community, $vlan){ $vlans_oid = "iso.3.6.1.4.1.34592.1.3.4.6.1.2.1";//"iso.3.6.1.4.1.34592.1.3.3.16.1.5.1";// $oper_state_oid = "iso.3.6.1.4.1.34592.1.3.4.1.1.11.1."; // online (3), offline (2) $rx_power_oid = "iso.3.6.1.4.1.34592.1.3.4.1.1.36.1."; //$range_value_oid = ".1.3.6.1.4.1.34592.1.3.4.1.1.13.1.1."; $mac_oid = "iso.3.6.1.4.1.34592.1.3.4.1.1.7.1."; //$onu_id_oid = "iso.3.6.1.4.1.34592.1.3.4.1.1.7.1.";//"iso.3.6.1.4.1.34592.1.3.3.16.1.4.1."; // $mac = ""; $a = snmprealwalk($host, $community, $vlans_oid, 5000000, 2); $a_ports = array_keys($a); $a_vlans = array_values($a); for ($i = 0; $i < count($a_vlans); $i++){ $gpon_vlan = $a_vlans[$i]; //$gpon_vlan = str_replace("INTEGER: ", "", $gpon_vlan); $gpon_vlan = str_replace("Hex-STRING: 09 81 00 01 ", "", $gpon_vlan); $gpon_vlan = str_replace(" 00 00 00 00", "", $gpon_vlan); $gpon_vlan = str_replace(" ", "", $gpon_vlan); //$gpon_vlan = substr($gpon_vlan, 0, 4); $gpon_vlan = hexdec($gpon_vlan); if ($gpon_vlan == $vlan) { $arr_port_id = $i; break; }; }; //$mac = $arr_port_id.' - '.$gpon_vlan.' = '.$a_ports[$arr_port_id];return $mac;exit; if (isset($arr_port_id)) { $gpon_port_id = $a_ports[$arr_port_id]; $gpon_port_id = str_replace($vlans_oid.".", "", $gpon_port_id); $gpon_port_id = substr($gpon_port_id, 0, strlen($gpon_port_id)-2); preg_match("/(\d+\.\d+$)/", $gpon_port_id, $m); $gpon_port_id = $m[1]; //$gpon_port_id = str_replace(".1", "", $gpon_port_id); //$onu_id = snmp2_get($host, $community, $mac_oid.$gpon_port_id, 5000000, 2); //$onu_id = str_replace("INTEGER: ", "", $gpon_port_id); //$pon_id = substr($gpon_port_id, 0, 1); $GLOBALS['status0'] = 'onu ID: '.$gpon_port_id;//$pon_id.':'.$onu_id; $port_oper_state = snmp2_get($host, $community, $oper_state_oid.$gpon_port_id, 5000000, 2); $port_oper_state = str_replace("INTEGER: ", "", $port_oper_state); if ($port_oper_state == 3){ $port_oper_state = 1; }; $rx_power = snmp2_get($host, $community, $rx_power_oid.$gpon_port_id, 5000000, 2); $rx_power = str_replace("INTEGER: ", "", $rx_power); if ($rx_power != 0) { $rx_power = $rx_power * 0.0001; $rx_power = round(log10($rx_power) * 10, 2); } else { $rx_power = ''; }; $GLOBALS['status2'] = "RxPower, dBm"; $GLOBALS['status3'] = $rx_power; //$onu_range_value = snmp2_get($host, $community, $range_value_oid.$gpon_port_id); //$onu_range_value = str_replace("INTEGER: ", "", $onu_range_value); //$GLOBALS['status4'] = $onu_range_value.' м'; $mac = snmp2_get($host, $community, $mac_oid.$gpon_port_id, 5000000, 2); $mac = str_replace("Hex-STRING: ", "", $mac); $GLOBALS['oper_state'] = $port_oper_state; }; $GLOBALS['admin_state'] = "1"; //$GLOBALS['status4'] = $port_oper_state; return $mac; }; function mac_huaweiS3026(){ $host = $GLOBALS['host']; $community = $GLOBALS['community']; $ports_oid = '.1.3.6.1.2.1.17.4.3.1.1';//".1.3.6.1.2.1.17.4.3.1.1"; $mac = ''; $i=0; $end_mac = false; //while (!$end_mac){ $end_mac = true; //$a_mac[$i] = snmp2_getnext($host, $community, $ports_oid.$mac, 2000); /*if (strlen($a_mac[$i]) > 2 ) { $mac = '.244.242.109.178.77.205'; $end_mac = false; $i++; }*/ //}; //$mac = $a_mac[$i]; //$a_mac[0] = snmp2_getnext($host, $community, $ports_oid); //$a_mac = $a; //$a_port = array_values($a); //$mac = $a; //$port = $a_port[0]; return $mac; }; function mac_gpon_bdcom3608($host, $community, $vlan){ $vlans_oid = ".1.3.6.1.4.1.3320.101.12.1.1.3"; $oper_state_oid = ".1.3.6.1.2.1.2.2.1.8."; $olt_rx_power_oid = ".1.3.6.1.4.1.3320.101.108.1.3."; $onu_rx_power_oid = ".1.3.6.1.4.1.3320.101.10.5.1.5."; $onu_name_oid = ".1.3.6.1.2.1.2.2.1.2."; //$ver_oid = ".1.3.6.1.2.1.1.1.0"; $mac_oid = ".1.3.6.1.4.1.3320.101.10.1.1.3."; $a = snmprealwalk($host, $community, $vlans_oid); $a_ports = array_keys($a); $a_vlans = array_values($a); $mac = ""; $GLOBALS['admin_state'] = "1"; $GLOBALS['oper_state'] = "0"; //$GLOBALS['status2'] = "rxpower, dbm"; //exit; for ($i = 0; $i < count($a_vlans); $i++){ $gpon_vlan = $a_vlans[$i]; $gpon_vlan = str_replace("INTEGER: ", "", $gpon_vlan); if ($gpon_vlan == $vlan) { $arr_port_id = $i; break; }; }; if (isset($arr_port_id)) { $gpon_port_id = $a_ports[$arr_port_id]; //$gpon_port_id = str_replace("iso.3.6.1.4.1.3320.101.12.1.1.3.", "", $gpon_port_id); //$gpon_port_id = str_replace(".1", "", $gpon_port_id); preg_match("/(\d+).1$/", $gpon_port_id, $m); $gpon_port_id = $m[1]; $port_oper_state = snmp2_get($host, $community, $oper_state_oid.$gpon_port_id); $port_oper_state = str_replace("INTEGER: ", "", $port_oper_state); preg_match("/(\d+)/", $port_oper_state, $m); $port_oper_state = $m[1]; $onu_name = snmp2_get($host, $community, $onu_name_oid.$gpon_port_id); $olt_rx_power = snmp2_get($host, $community, $olt_rx_power_oid.$gpon_port_id); $olt_rx_power = str_replace("INTEGER: ", "", $olt_rx_power); $onu_rx_power = snmp2_get($host, $community, $onu_rx_power_oid.$gpon_port_id); $onu_rx_power = str_replace("INTEGER: ", "", $onu_rx_power); $onu_rx_power = $onu_rx_power * 0.1; if ($olt_rx_power != -65535){ $olt_rx_power = $olt_rx_power * 0.1; $GLOBALS['status2'] = "rx, dbm (OLT/ONU)"; $GLOBALS['status3'] = $olt_rx_power.'/'.$onu_rx_power; }; $onu_name = str_replace("STRING: ", "", $onu_name); $onu_name = str_replace("\"", "", $onu_name); $mac = snmp2_get($host, $community, $mac_oid.$gpon_port_id); $mac = str_replace("Hex-STRING: ", "", $mac); $GLOBALS['oper_state'] = $port_oper_state; $GLOBALS['status0'] = $onu_name; }; return $mac; }; function agg_int_status(){ $host = $GLOBALS['host']; $community = $GLOBALS['community']; $vlan = $GLOBALS['vlan']; $agg_vlan_name_oid = '.1.3.6.1.2.1.2.2.1.2'; $agg_vlan_status_oid = '.1.3.6.1.2.1.2.2.1.7'; //$i=0; $status = "Down"; $a_vlans = snmprealwalk($host, $community, $agg_vlan_name_oid); $a_vlan_oid = array_keys($a_vlans); $a_vlan_name = array_values($a_vlans); for ($i = 0; $i < count($a_vlans); $i++){ $agg_vlan = $a_vlan_name[$i]; $agg_vlan = str_replace("STRING: ", "", $agg_vlan); $agg_vlan = str_replace("Vlan", "", $agg_vlan); if ($agg_vlan == $vlan) { $arr_vlan_id = $i; break; }; }; $a_vlan = snmprealwalk($host, $community, $agg_vlan_status_oid); $a_vlan_status = array_values($a_vlans); $vlan_status = str_replace("INTEGER: ", "", $a_vlan_status[0]); if ($vlan_status == 1){ $status = "Up"; }; return $status; }; ?>