本文整理匯總了PHP中Device::get_interface_id_by_name方法的典型用法代碼示例。如果您正苦於以下問題:PHP Device::get_interface_id_by_name方法的具體用法?PHP Device::get_interface_id_by_name怎麽用?PHP Device::get_interface_id_by_name使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Device
的用法示例。
在下文中一共展示了Device::get_interface_id_by_name方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: displayService
function displayService($services)
{
//global all variables
global $serviceKey, $serviceForm, $tool, $headings, $titles, $serviceTypes, $location, $status_array;
$serviceForm->setCols(2);
//make the tool bar for this page
if ($_SESSION['access'] >= 50) {
$toolNames = array("Edit Service", "Delete Service");
$toolIcons = array("edit", "delete");
$toolHandlers = array("handleEvent('services.php?action=edit&ID={$_GET['ID']}', 'devicePart');", "handleEvent('services.php?action=remove&ID={$_GET['ID']}')");
echo $tool->createNewTools($toolNames, $toolIcons, $toolHandlers);
}
//check the service layer and display according to the layer
//if the layer is 3
if ($services->get_service_layer() == 3) {
//store the values in the heading and title array
$headings = array("Service Information", "*<break>*", "Port Specific Information", "*<break>*", "Routing Specific Information", "*<break>*", "IPv4 Information", "*<break>*", "IPv6 Information");
$titles = array("Customer name", "Customer ID", "Service type", "Service ID", "Include statistics in portal?.tip.If YES is selected the user will be able to see the statistics for this particular service in the wiki portal. If this is not selected, traffic stats for this service will not be available in the wiki portal", "Service description (name).tip.A useful description for this service", "Notes.tip.Here you can add generic notes for this service, for example: This is a tempory backup connection.", "Status.tip.Specifies the production status of this Service", "In production date", "Out of production date", "*<break>*", "Device for Service", "Interface.tip.Name of the physical interface, for example ge-2/0/1<br>Do not use subinterface format no ge-2/0/1.10", "Interface MTU Size.tip.Default for ORAN and CU_ALL is 9000 bytes, the commodity and IX instance use 1500", "Interface tagged", "Vlan number.tip.Please enter a vlan number. If this is an untagged routed port and has no vlan, than please use 0. This means no vlan configuration", "*<break>*", "Logical router", "Routing type", "AS number", "Traffic Policing", "*<break>*", "IPv4 unicast", "IPv4 multicast", "BCNET router address.tip.IPv4 address of the BCNET side of this link. Please include masklenght. Format: x.x.x.x/30", "Customer router address.tip.IPv4 address of the Customer side of this link. Please include masklenght. Format: x.x.x.x/30", "IPv4 prefix", "*<break>*", "IPv6 unicast", "IPv6 multicast", "BCNET router address", "Customer router address", "IPv6 prefix");
$layer3Service = new Layer3_service($services->get_service_id());
//add all the prefixes for ipv4 and ipv6 together
foreach (array_keys($layer3Service->get_prefixes(4)) as $prefix) {
$address4Prefix .= $prefix . "<br />";
}
foreach (array_keys($layer3Service->get_prefixes(6)) as $prefix) {
$address6Prefix .= $prefix . "<br />";
}
//switch the values into strings
$layer3Service->get_portal_statistics() == 1 ? $stats = 'Yes' : ($stats = 'No');
$layer3Service->get_tagged() == 1 ? $tagged = 'Tagged' : ($tagged = 'Untagged');
$layer3Service->get_ipv4_unicast() == 1 ? $uni4 = 'True' : ($uni4 = 'False');
$layer3Service->get_ipv4_multicast() == 1 ? $multi4 = 'True' : ($multi4 = 'False');
$layer3Service->get_ipv6_unicast() == 1 ? $uni6 = 'True' : ($uni6 = 'False');
$layer3Service->get_ipv6_multicast() == 1 ? $multi6 = 'True' : ($multi6 = 'False');
//store the values in the info
$info = array($layer3Service->get_contact_name(), $layer3Service->get_contact_id(), $layer3Service->get_service_type_name(), $layer3Service->get_service_id(), $stats, $layer3Service->get_name(), $layer3Service->get_notes(), $layer3Service->get_status(), $layer3Service->get_in_production_date(), $layer3Service->get_out_production_date(), $layer3Service->get_pe_name(), $layer3Service->get_port_name(), $layer3Service->get_mtu(), $tagged, $layer3Service->get_vlan_id(), $layer3Service->get_logical_router(), $layer3Service->get_routing_type(), $layer3Service->get_bgp_as(), $layer3Service->get_traffic_policing(), $uni4, $multi4, $layer3Service->get_pe_address(4), $layer3Service->get_ce_address(4), $address4Prefix, $uni6, $multi6, $layer3Service->get_pe_address(6), $layer3Service->get_ce_address(6), $address6Prefix);
} elseif ($services->get_service_layer() == 2) {
//store the values in the heading and title array
$headings = array("Service Information", "*<break>*", "Layer 2 Specific Information");
$titles = array("Customer name", "Customer ID", "Service type", "Service ID", "Include statistics in portal?", "Service description (name)", "Notes", "Status.tip.Specify the production status of this Service", "In production date", "Out of production date", "*<break>*", "Vlan number");
$layer2Service = new Layer2_service($services->get_service_id());
//change the value into strings
$layer2Service->get_portal_statistics() == 1 ? $stats = 'Yes' : ($stats = 'No');
$info = array($layer2Service->get_contact_name(), $layer2Service->get_contact_id(), $layer2Service->get_service_type_name(), $layer2Service->get_service_id(), $stats, $layer2Service->get_name(), $layer2Service->get_notes(), $layer2Service->get_status(), $layer2Service->get_in_production_date(), $layer2Service->get_out_production_date(), $layer2Service->get_vlan_id());
$layer2Interfaces = $layer2Service->get_interfaces();
//store the interface port into the array
$titles2 = array();
$info2 = array();
$headings2 = array("Device Name", "Port name", "Tagged", "Vlan", "MTU", "Actions");
$handlers = array();
//~atoonk/test/rrd/graph.php?file=deviceid12_ge-0-0-3.653&titel=cr1.keltx1.bc.net -- ge-0/0/3.653
//add the ports information together
$key = array("interfaceID", "deviceName", "portName", "tagged", "vlan", "mtu");
$titlePort = array("Interface ID", "Device Name", "Port name.tip.Name of the physical interface, for example ge-2/0/1<br>Do not use subinterface format no ge-2/0/1.10", "Tagged", "Vlan.tip.Please enter a vlan number. If this is an untagged routed port and has no vlan, than please use 0. This means no vlan configuration", "MTU.tip.Default for ORAN and CU_ALL is 9000 bytes, the commodity and IX instance use 1500");
$infoPort = array();
$headingPort = array('Port Information');
$fieldType = array("static", "drop_down", "", "radio", "", "");
$types = array(Device::get_devices());
//push all the interface port information
foreach ($layer2Interfaces as $id => $value) {
$infoPort = array();
//Array ( [service_interface_id] => 184 [device_id] => 11 [device_name] => cr1.victx1.bc.net [port_name] => ge-0/1/2 [tagged] => 1 [vlan_id] => 0 [mtu] => 1500 )
$oriPortName = $value[port_name];
$portName = str_replace("/", "-", $value[port_name]);
$portName = str_replace(" ", "-", $portName);
// Determine port alias /descs
//print_r(Port::get_device_interfaces($value[device_id]));
if ($value[tagged] == 1) {
// Nortel hack
// Nortel BPS / baystack switches don't append the vlan id to the interface
// So if it's a Nortel switch don't append
// Nortel interfaces start with ifc24 (Slot: 1 Port: 24)
if (!preg_match("/ifc\\d+\\s\\(Slot:/", $oriPortName)) {
$oriPortName = $oriPortName . "." . $value[vlan];
$portName = $portName . "." . $value[vlan];
}
}
// Determine port alias /descs
$device = new Device($value[device_id]);
$port = new Port($device->get_interface_id_by_name($oriPortName));
$port_alias = $port->get_alias();
$port_alias = '';
if ($port->get_alias() != '') {
$port_alias = " <i> (" . $port->get_alias() . ")</i>";
}
// Done Determine port alias /descs
$link = 'rrdgraph.php?file=deviceid' . $value[device_id] . "_" . $portName . ".rrd&title=" . $value[device_name] . "%20--%20" . $oriPortName;
array_push($handlers, $link);
array_push($titles2, $value['device_name'] . "//" . $device->get_interface_id_by_name($oriPortName) . "//" . $value[device_id]);
array_push($infoPort, $value['service_interface_id']);
array_push($infoPort, $value['device_name']);
foreach ($value as $subID => $subValue) {
if ($subID == "tagged") {
if ($subValue == 1) {
array_push($info2, 'Tagged');
array_push($infoPort, 'Tagged');
} else {
array_push($info2, 'Untagged');
array_push($infoPort, 'Untagged');
}
} else {
//.........這裏部分代碼省略.........
示例2: get_files_for_device
private function get_files_for_device($device_id)
{
if (!is_numeric($device_id)) {
return;
}
$selectedDevice = new Device($device_id);
$output = "<h2>Displaying Counters for: <b>" . $selectedDevice->get_name() . "</b></h2><br>";
//print $selectedDevice->get_name() . "<br>";
$property = new Property();
if ($rrdtool = $property->get_property("path_rrdtool")) {
} else {
return;
}
if ($rrd_dir = $property->get_property("path_rrddir")) {
} else {
return;
}
$pattern = "{$rrd_dir}/fwcounters/fwcounter_deviceid" . $device_id . "_*.rrd";
$files = glob($pattern);
foreach ($files as $v) {
$path_parts = pathinfo($v);
$fullPath = "fwcounters/" . $path_parts['basename'];
$fileName = $path_parts['filename'];
//(\d+)_(.+)$
$searchPattern = '/fwcounter_deviceid(\\d+)_(.+)$/';
$replacement = $selectedDevice->get_name() . ' $2';
$counterName = preg_replace($searchPattern, $replacement, $fileName);
// If this is an interface-specific counter then show more info about the interface
$outputPortInfo = "";
// print strtolower($counterName);
//ge-0-2-5.0
$arrPortTypes = array();
$arrPortTypes[] = "fe";
$arrPortTypes[] = "ge";
$arrPortTypes[] = "xe";
$arrPortTypes[] = "et";
$interfaceName = false;
foreach ($arrPortTypes as $k => $v) {
$interfaceName = strstr($counterName, $v . "-");
if ($interfaceName != false) {
$interfaceName = strtr($interfaceName, array('-' => '/'));
$interfaceName = str_replace($v . "/", $v . "-", $interfaceName);
break;
}
}
if ($interfaceName != false) {
$thisDevice = new Device($device_id);
$interfaceID = $thisDevice->get_interface_id_by_name($interfaceName);
if ($interfaceID) {
$thisPort = new Port($interfaceID);
$outputPortInfo = "<br>Port description: " . $thisPort->get_alias();
}
}
$output .= "<table>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td colspan='2'><h3>RRD File: {$fileName} {$outputPortInfo} </h3></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>";
$height = 150;
$width = 550;
$from = "-1d";
if (isset($_GET['From'])) {
$from = $_GET['From'];
}
$graph = "Bits Per Second";
$graph = str_replace(" ", "%20", $graph);
$type = "traffic";
$type = str_replace(" ", "%20", $type);
$link = "rrdgraph.php?file={$fullPath}&title=" . $fileName . " --- " . $graph . "&height=" . $height . "&width=" . $width . "&type=" . $type;
$output .= "<a href='#'><img src='rrdgraph.php?file={$fullPath}&title=" . $counterName . " --- " . $graph . "&from={$from}&height={$height}&width={$width}&type={$type}'></a><br><br>";
$output .= "</td><td>";
$graph = "Unicast Packets Per Second";
$graph = str_replace(" ", "%20", $graph);
$type = "unicastpkts";
$type = str_replace(" ", "%20", $type);
$link = "rrdgraph.php?file={$fullPath}&title=" . $fileName . " --- " . $graph . "&height=" . $height . "&width=" . $width . "&type=" . $type;
$output .= "<a href='#'><img src='rrdgraph.php?file={$fullPath}&title=" . $counterName . " --- " . $graph . "&from={$from}&height={$height}&width={$width}&type={$type}'></a><br>";
$output .= "</td></tr><br><hr>";
}
return $output;
}
示例3: Device
<?php
if (isset($_GET['ID'])) {
echo "<div style='font-size:10px; font-weight:100px;'>";
$link = $_SERVER['PHP_SELF'];
echo "<a href='" . $link . "'>All Devices</a>";
$link = $_SERVER['PHP_SELF'] . "?action=showGraph&ID=" . $_GET['ID'] . "&pageNum=1&active=yes";
$device = new Device($_GET['ID']);
$deviceName = $device->get_name();
if (isset($_GET['interID'])) {
echo " >> <a href='" . $link . "'>" . $deviceName . "</a>";
$port = new Port($_GET['interID']);
$portName = $port->get_name();
if (preg_match("/\\.[0-9]/", $portName)) {
$physPort = array();
$physPort = explode(".", $portName, 2);
$interID = $device->get_interface_id_by_name($physPort[0]);
$link = $_SERVER['PHP_SELF'] . "?action=showGraphDetail&ID=" . $_GET['ID'] . "&interID=" . $interID . "&active=up&type=" . $_GET['type'];
echo " >> <a href='" . $link . "'>" . $physPort[0] . "</a>";
}
if ($_GET['action'] == "zoomGraphDetail") {
$link = $_SERVER['PHP_SELF'] . "?action=showGraphDetail&ID=" . $_GET['ID'] . "&interID=" . $_GET['interID'] . "&active=up&type=" . $_GET['type'];
echo " >> <a href='" . $link . "'>" . $portName . "</a>";
if ($_GET['action'] == 'zoomGraphDetail') {
echo " >> zoom";
}
} else {
$link = $_SERVER['PHP_SELF'] . "?action=showGraph&ID=" . $_GET['ID'] . "&interID=" . $_GET['interID'] . "&pageNum=1";
echo " >> <a href='" . $link . "'>" . $portName . "</a>";
}
} else {
echo " >> " . $deviceName;