当前位置: 首页>>代码示例>>PHP>>正文


PHP short_ifname函数代码示例

本文整理汇总了PHP中short_ifname函数的典型用法代码示例。如果您正苦于以下问题:PHP short_ifname函数的具体用法?PHP short_ifname怎么用?PHP short_ifname使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了short_ifname函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: process_port_label


//.........这里部分代码省略.........
    } else {
        if (preg_match('/\\d+(?:(?:[\\/:](?:[a-z])?[\\d\\.:]+)+[a-z\\d\\.\\:]*(?:[\\-\\_][\\w\\.\\:]+)*|\\/\\w+$)/i', $this_port['port_label'], $matches)) {
            // Multipart numeric
            /*
            1/1/1
            e1-0/0/1.0
            e1-0/2/0:13.0
            dwdm0/1/0/6
            DTI1/1/0
            Cable8/1/4-upstream2
            Cable8/1/4
            16GigabitEthernet1/2/1
            cau4-0/2/0
            dot11radio0/0
            Dialer0/0.1
            Downstream 0/2/0
            1000BaseTX Port 8/48 Name
            Backplane-GigabitEthernet0/3
            Ethernet1/10
            FC port 0/19
            GigabitEthernet0/0/0/1
            GigabitEthernet0/1.ServiceInstance.206
            Integrated-Cable7/0/0:0
            Logical Upstream Channel 1/0.0/0
            Slot0/1
            sonet_12/1
            GigaVUE-212 Port  8/48 (Network Port)
            Stacking Port 1/StackA
            1:38
            1/4/x24, mx480-xe-0-0-0
            1/4/x24
            */
            $this_port['port_label_num'] = $matches[0];
            list($this_port['port_label_base']) = explode($matches[0], $this_port['port_label'], 2);
            $this_port['port_label'] = $this_port['port_label_base'] . $this_port['port_label_num'];
            // Remove additional part (after port number)
        } else {
            if (preg_match('/(?<port_label_num>(?:\\d+[a-z])?\\d[\\d\\.\\:]*(?:[\\-\\_]\\w+)?)(?: [a-z()\\[\\] ]+)?$/i', $this_port['port_label'], $matches)) {
                // Simple numeric
                /*
                GigaVUE-212 Port  1 (Network Port)
                MMC-A s3 SW Port
                Atm0_Physical_Interface
                wan1_phys
                fwbr101i0
                Nortel Ethernet Switch 325-24G Module - Port 1
                lo0.32768
                vlan.818
                jsrv.1
                Bundle-Ether1.1701
                Ethernet1
                ethernet_13
                eth0
                eth0.101
                BVI900
                A/1
                e1
                CATV-MAC 1
                16
                */
                $this_port['port_label_num'] = $matches['port_label_num'];
                $this_port['port_label_base'] = substr($this_port['port_label'], 0, 0 - strlen($matches[0]));
                $this_port['port_label'] = $this_port['port_label_base'] . $this_port['port_label_num'];
                // Remove additional part (after port number)
            } else {
                // All other (non-numeric)
                /*
                UniPing Server Solution v3/SMS Enet Port
                MMC-A s2 SW Port
                Control Plane
                */
                $this_port['port_label_base'] = $this_port['port_label'];
            }
        }
    }
    // When not empty label brackets and empty numeric part, re-add brackets to label
    if (!empty($label_bracket) && $this_port['port_label_num'] == '') {
        // rtif(172.20.30.46/28)
        $this_port['port_label'] .= $label_bracket;
    }
    $this_port['port_label_short'] = short_ifname($this_port['port_label']);
    // Set entity variables for use by code which uses entities
    // Base label part: TenGigabitEthernet3/3 -> TenGigabitEthernet, GigabitEthernet4/8.722 -> GigabitEthernet, Vlan2603 -> Vlan
    //$port['port_label_base'] = preg_replace('/^([A-Za-z ]*).*/', '$1', $port['port_label']);
    //$port['port_label_num']  = substr($port['port_label'], strlen($port['port_label_base'])); // Second label part
    //
    //  // Index example for TenGigabitEthernet3/10.324:
    //  //  $ports_links['Ethernet'][] = array('label_base' => 'TenGigabitEthernet', 'label_num0' => '3', 'label_num1' => '10', 'label_num2' => '324')
    //  $label_num  = preg_replace('![^\d\.\/]!', '', substr($data['port_label'], strlen($data['port_label_base']))); // Remove base part and all not-numeric chars
    //  preg_match('!^(\d+)(?:\/(\d+)(?:\.(\d+))*)*!', $label_num, $label_nums); // Split by slash and point (1/1.324)
    //  $ports_links[$data['human_type']][$data['ifIndex']] = array(
    //    'label'      => $data['port_label'],
    //    'label_base' => $data['port_label_base'],
    //    'label_num0' => $label_nums[0],
    //    'label_num1' => $label_nums[1],
    //    'label_num2' => $label_nums[2],
    //    'link'       => generate_port_link($data, $data['port_label_short'])
    //  );
    return TRUE;
}
开发者ID:Natolumin,项目名称:observium,代码行数:101,代码来源:rewrites.inc.php

示例2: foreach

<?php

$i = 0;
foreach (explode(",", $vars['id']) as $ifid) {
    $port = dbFetchRow("SELECT * FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id", array($ifid));
    $rrdfile = get_port_rrdfilename($port, $port);
    if (is_file($rrdfile)) {
        humanize_port($port);
        $rrd_list[$i]['filename'] = $rrdfile;
        $rrd_list[$i]['descr'] = $port['hostname'] . " " . $port['ifDescr'];
        $rrd_list[$i]['descr_in'] = $port['hostname'];
        $rrd_list[$i]['descr_out'] = short_ifname($port['label']);
        $i++;
    }
}
$units = 'b';
$total_units = 'B';
$colours_in = 'greens';
$multiplier = "8";
$colours_out = 'blues';
$ds_in = "INOCTETS";
$ds_out = "OUTOCTETS";
include "includes/graphs/generic_multi_bits_separated.inc.php";
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:23,代码来源:bits_separate.inc.php

示例3: array

         echo "\n  [VRF {$vrf_name}] OID   - " . $vrf_oid;
         echo "\n  [VRF {$vrf_name}] RD    - " . $vrf_rd;
         echo "\n  [VRF {$vrf_name}] DESC  - " . $descr_table[$vrf_oid];
         if (dbFetchCell('SELECT COUNT(*) FROM `vrfs` WHERE `device_id` = ? AND `vrf_oid` = ?', array($device['device_id'], $vrf_oid))) {
             $update_array = array('mplsVpnVrfDescription' => $descr_table[$vrf_oid], 'mplsVpnVrfRouteDistinguisher' => $vrf_rd);
             dbUpdate($update_array, 'vrfs', '`device_id` = ? AND `vrf_oid` = ?', array($device['device_id'], $vrf_oid));
         } else {
             $insert_array = array('device_id' => $device['device_id'], 'vrf_oid' => $vrf_oid, 'vrf_name' => $vrf_name, 'mplsVpnVrfDescription' => $descr_table[$vrf_oid], 'mplsVpnVrfRouteDistinguisher' => $vrf_rd);
             dbInsert($insert_array, 'vrfs');
         }
         $vrf_id = dbFetchCell('SELECT vrf_id FROM `vrfs` WHERE `device_id` = ? AND `vrf_oid` = ?', array($device['device_id'], $vrf_oid));
         $valid_vrf[$vrf_id] = 1;
         echo "\n  [VRF {$vrf_name}] PORTS - ";
         foreach ($port_table[$vrf_oid] as $if_id) {
             $interface = dbFetchRow('SELECT ifDescr, port_id FROM ports WHERE ifIndex = ? AND device_id = ?', array($if_id, $device['device_id']));
             echo short_ifname($interface['ifDescr']) . " ";
             dbUpdate(array('ifVrf' => $vrf_id), 'ports', '`port_id` = ?', array($interface['port_id']));
             $if = $interface['port_id'];
             $valid_vrf_if[$vrf_id][$if] = 1;
         }
     }
 }
 echo "\n";
 foreach (dbFetchRows('SELECT * FROM ports WHERE device_id = ?', array($device['device_id'])) as $row) {
     $if = $row['port_id'];
     $vrf_id = $row['ifVrf'];
     if ($row['ifVrf']) {
         if (!$valid_vrf_if[$vrf_id][$if]) {
             echo "-";
             dbUpdate(array('ifVrf' => NULL), 'ports', '`port_id` = ?', array($if));
         } else {
开发者ID:skive,项目名称:observium,代码行数:31,代码来源:cisco-vrf.inc.php

示例4: foreach

 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage graphs
 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
// Generate a list of ports and then call the multi_bits grapher to generate from the list
$i = 0;
foreach (dbFetchRows("SELECT * FROM `ports` AS I, `devices` AS D WHERE `port_descr_type` = 'cust' AND `port_descr_descr` = ? AND D.device_id = I.device_id", array($vars['id'])) as $port) {
    $rrd_filename = get_port_rrdfilename($port, NULL, TRUE);
    if (is_file($rrd_filename)) {
        $rrd_list[$i]['filename'] = $rrd_filename;
        $rrd_list[$i]['descr'] = $port['hostname'] . "-" . $port['ifDescr'];
        $rrd_list[$i]['descr_in'] = short_hostname($port['hostname']);
        $rrd_list[$i]['descr_out'] = short_ifname($port['ifDescr'], NULL, FALSE);
        // Options sets for skip htmlentities
        $i++;
    }
}
$units = 'b';
$total_units = 'B';
$colours_in = 'greens';
$multiplier = "8";
$colours_out = 'blues';
$nototal = 1;
$ds_in = "INOCTETS";
$ds_out = "OUTOCTETS";
include "includes/graphs/generic_multi_bits_separated.inc.php";
开发者ID:skive,项目名称:observium,代码行数:31,代码来源:bits.inc.php

示例5: foreach

<?php

// FIXME new url format
if (is_integer($i / 2)) {
    $bg_colour = $list_colour_a;
} else {
    $bg_colour = $list_colour_b;
}
echo "<tr bgcolor='{$bg_colour}'>";
echo "<td width=200 class=entity-title><a href='routing/vrf/" . $vrf['mplsVpnVrfRouteDistinguisher'] . "/'>" . $vrf['vrf_name'] . "</a></td>";
echo "<td width=150 class=small>" . $vrf['mplsVpnVrfDescription'] . "</td>";
echo "<td width=100 class=small>" . $vrf['mplsVpnVrfRouteDistinguisher'] . "</td>";
echo '<td class="entity">';
foreach (dbFetchRows("SELECT * FROM ports WHERE `device_id` = ? AND `ifVrf` = ?", array($device['device_id'], $vrf['vrf_id'])) as $port) {
    if ($vars['view'] == "graphs") {
        $graph_type = "port_" . $vars['graph'];
        echo "<div style='display: block; padding: 2px; margin: 2px; min-width: 139px; max-width:139px; min-height:85px; max-height:85px; text-align: center; float: left; background-color: #e9e9e9;'>\n    <div style='font-weight: bold;'>" . short_ifname($port['ifDescr']) . "</div>\n    <a href='device/" . $device['device_id'] . "/port/" . $port['port_id'] . "/' onmouseover=\"return overlib('\\\n    <div style=\\'font-size: 16px; padding:5px; font-weight: bold; color: #e5e5e5;\\'>" . $device['hostname'] . " - " . $port['ifDescr'] . "</div>\\\n    " . $port['ifAlias'] . " \\\n    <img src=\\'graph.php?type={$graph_type}&amp;id=" . $port['port_id'] . "&amp;from=" . $config['time']['twoday'] . "&amp;to=" . $config['time']['now'] . "&amp;width=450&amp;height=150\\'>\\\n    ', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\"  >" . "<img src='graph.php?type={$graph_type}&amp;id=" . $port['port_id'] . "&amp;from=" . $config['time']['twoday'] . "&amp;to=" . $config['time']['now'] . "&amp;width=132&amp;height=40&amp;legend=no'>\n    </a>\n    <div style='font-size: 9px;'>" . short_port_descr($port['ifAlias']) . "</div>\n   </div>";
    } else {
        echo $vrf['port_sep'] . generate_port_link($port, short_ifname($port['ifDescr']));
        $vrf['port_sep'] = ", ";
    }
}
echo "</td>";
echo "</tr>";
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:24,代码来源:print-vrf.inc.php

示例6: elseif

            if ($port_id) {
                $vars['id'] = $port_id;
            }
        } elseif (!empty($vars['ifalias'])) {
            // Get port by ifAlias
            $port_id = get_port_id_by_ifAlias($device['device_id'], $vars['ifalias']);
            if ($port_id) {
                $vars['id'] = $port_id;
            }
        }
    } elseif (!empty($vars['circuit'])) {
        // Get port by circuit id
        $port_id = get_port_id_by_customer(array('circuit' => $vars['circuit']));
        if ($port_id) {
            $vars['id'] = $port_id;
        }
    }
}
if (is_numeric($vars['id']) && ($auth || port_permitted($vars['id']))) {
    $port = get_port_by_id($vars['id']);
    $device = device_by_id_cache($port['device_id']);
    $title = generate_device_link($device);
    $title .= " :: Port  <b>" . generate_port_link($port) . "</b>";
    $title_array = array();
    $title_array[] = array('text' => $device['hostname'], 'url' => generate_url(array('page' => 'device', 'device' => $device['device_id'])));
    $title_array[] = array('text' => 'Ports', 'url' => generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'ports')));
    $title_array[] = array('text' => rewrite_ifname($port['label']), 'url' => generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'port', 'port' => $port['port_id'])));
    $graph_title = short_hostname($device['hostname']) . " :: " . strtolower(short_ifname($port['ifDescr'], NULL, FALSE));
    $auth = TRUE;
    $rrd_filename = get_port_rrdfilename($port, NULL, TRUE);
}
开发者ID:skive,项目名称:observium,代码行数:31,代码来源:auth.inc.php

示例7: print_mac_addresses

/**
 * Display Interface MACs addresses.
 *
 * Display pages with MAC addresses from device Interfaces.
 *
 * @param array $vars
 * @return none
 *
 */
function print_mac_addresses($vars)
{
    // With pagination? (display page numbers in header)
    $pagination = isset($vars['pagination']) && $vars['pagination'];
    pagination($vars, 0, TRUE);
    // Get default pagesize/pageno
    $pageno = $vars['pageno'];
    $pagesize = $vars['pagesize'];
    $start = $pagesize * $pageno - $pagesize;
    $param = array();
    $where = ' WHERE 1 ';
    foreach ($vars as $var => $value) {
        if ($value != '') {
            switch ($var) {
                case 'device':
                case 'device_id':
                    $where .= generate_query_values($value, 'device_id');
                    break;
                case 'interface':
                    $where .= ' AND `ifDescr` LIKE ?';
                    $param[] = $value;
                    break;
                case 'address':
                    $where .= ' AND `ifPhysAddress` LIKE ?';
                    # FIXME hm? mres in a dbFacile parameter?
                    $param[] = '%' . str_replace(array(':', ' ', '-', '.', '0x'), '', mres($value)) . '%';
                    break;
            }
        }
    }
    $where .= ' AND `ifPhysAddress` IS NOT NULL';
    //Exclude empty MACs
    // Show MACs only for permitted ports
    $query_permitted = generate_query_permitted(array('port'));
    $query = 'FROM `ports` ';
    $query .= $where . $query_permitted;
    $query_count = 'SELECT COUNT(*) ' . $query;
    $query = 'SELECT * ' . $query;
    $query .= ' ORDER BY `ifPhysAddress`';
    $query .= " LIMIT {$start},{$pagesize}";
    // Query addresses
    $entries = dbFetchRows($query, $param);
    // Query address count
    if ($pagination) {
        $count = dbFetchCell($query_count, $param);
    }
    $list = array('device' => FALSE);
    if (!isset($vars['device']) || empty($vars['device']) || $vars['page'] == 'search') {
        $list['device'] = TRUE;
    }
    $string = '<table class="table table-bordered table-striped table-hover table-condensed">' . PHP_EOL;
    if (!$short) {
        $string .= '  <thead>' . PHP_EOL;
        $string .= '    <tr>' . PHP_EOL;
        if ($list['device']) {
            $string .= '      <th>Device</th>' . PHP_EOL;
        }
        $string .= '      <th>Interface</th>' . PHP_EOL;
        $string .= '      <th>MAC Address</th>' . PHP_EOL;
        $string .= '      <th>Description</th>' . PHP_EOL;
        $string .= '    </tr>' . PHP_EOL;
        $string .= '  </thead>' . PHP_EOL;
    }
    $string .= '  <tbody>' . PHP_EOL;
    foreach ($entries as $entry) {
        if (port_permitted($entry['port_id'])) {
            humanize_port($entry);
            $string .= '  <tr>' . PHP_EOL;
            if ($list['device']) {
                $dev = device_by_id_cache($entry['device_id']);
                $string .= '    <td class="entity" style="white-space: nowrap;">' . generate_device_link($dev) . '</td>' . PHP_EOL;
            }
            if ($entry['ifInErrors_delta'] > 0 || $entry['ifOutErrors_delta'] > 0) {
                $port_error = generate_port_link($entry, '<span class="label label-important">Errors</span>', 'port_errors');
            }
            $string .= '    <td class="entity">' . generate_port_link($entry, short_ifname($entry['label'])) . ' ' . $port_error . '</td>' . PHP_EOL;
            $string .= '    <td style="width: 160px;">' . $entry['human_mac'] . '</td>' . PHP_EOL;
            $string .= '    <td>' . $entry['ifAlias'] . '</td>' . PHP_EOL;
            $string .= '  </tr>' . PHP_EOL;
        }
    }
    $string .= '  </tbody>' . PHP_EOL;
    $string .= '</table>';
    // Print pagination header
    if ($pagination) {
        $string = pagination($vars, $count) . $string . pagination($vars, $count);
    }
    // Print MAC addresses
    echo $string;
}
开发者ID:skive,项目名称:observium,代码行数:99,代码来源:mac_addresses.inc.php

示例8: print_events


//.........这里部分代码省略.........
            if ($list['device']) {
                $string .= '      <th>设备</th>' . PHP_EOL;
            }
            if ($list['entity']) {
                $string .= '      <th>单位</th>' . PHP_EOL;
            }
            $string .= '      <th>信息</th>' . PHP_EOL;
            $string .= '    </tr>' . PHP_EOL;
            $string .= '  </thead>' . PHP_EOL;
        }
        $string .= '  <tbody>' . PHP_EOL;
        foreach ($events['entries'] as $entry) {
            #$icon = geteventicon($entry['message']);
            #if ($icon) { $icon = '<img src="images/16/' . $icon . '" />'; }
            switch ($entry['severity']) {
                case "0":
                    // Emergency
                // Emergency
                case "1":
                    // Alert
                // Alert
                case "2":
                    // Critical
                // Critical
                case "3":
                    // Error
                    $entry['html_row_class'] = "error";
                    break;
                case "4":
                    // Warning
                    $entry['html_row_class'] = "warning";
                    break;
                case "5":
                    // Notification
                    $entry['html_row_class'] = "recovery";
                    break;
                case "6":
                    // Informational
                    $entry['html_row_class'] = "up";
                    break;
                case "7":
                    // Debugging
                    $entry['html_row_class'] = "suppressed";
                    break;
                default:
            }
            $string .= '  <tr class="' . $entry['html_row_class'] . '">' . PHP_EOL;
            $string .= '<td class="state-marker"></td>' . PHP_EOL;
            if ($events['short']) {
                $string .= '    <td class="syslog" style="white-space: nowrap">';
                $timediff = $GLOBALS['config']['time']['now'] - strtotime($entry['timestamp']);
                $string .= overlib_link('', formatUptime($timediff, "short-3"), format_timestamp($entry['timestamp']), NULL) . '</td>' . PHP_EOL;
            } else {
                $string .= '    <td style="width: 160px">';
                $string .= format_timestamp($entry['timestamp']) . '</td>' . PHP_EOL;
            }
            if ($list['device']) {
                $dev = device_by_id_cache($entry['device_id']);
                $device_vars = array('page' => 'device', 'device' => $entry['device_id'], 'tab' => 'logs', 'section' => 'eventlog');
                $string .= '    <td class="entity">' . generate_device_link($dev, short_hostname($dev['hostname']), $device_vars) . '</td>' . PHP_EOL;
            }
            if ($list['entity']) {
                if ($entry['entity_type'] == 'device' && !$entry['entity_id']) {
                    $entry['entity_id'] = $entry['device_id'];
                }
                if ($entry['entity_type'] == 'port') {
                    $this_if = get_port_by_id_cache($entry['entity_id']);
                    $entry['link'] = '<span class="entity"><i class="' . $config['entities']['port']['icon'] . '"></i> ' . generate_port_link($this_if, short_ifname($this_if['label'])) . '</span>';
                } else {
                    if (!empty($config['entities'][$entry['entity_type']]['icon'])) {
                        $entry['link'] = '<i class="' . $config['entities'][$entry['entity_type']]['icon'] . '"></i> ' . generate_entity_link($entry['entity_type'], $entry['entity_id']);
                    } else {
                        $entry['link'] = nicecase($entry['entity_type']);
                    }
                }
                if (!$events['short']) {
                    $string .= '    <td>' . $entry['link'] . '</td>' . PHP_EOL;
                }
            }
            if ($events['short']) {
                $string .= '    <td class="syslog">';
                if (strpos($entry['message'], $entry['link']) !== 0) {
                    $string .= $entry['link'] . ' ';
                }
            } else {
                $string .= '    <td>';
            }
            $string .= escape_html($entry['message']) . '</td>' . PHP_EOL;
            $string .= '  </tr>' . PHP_EOL;
        }
        $string .= '  </tbody>' . PHP_EOL;
        $string .= '</table>';
        // Print pagination header
        if ($events['pagination_html']) {
            $string = $events['pagination_html'] . $string . $events['pagination_html'];
        }
        // Print events
        echo $string;
    }
}
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:101,代码来源:events.inc.php

示例9: array

 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
echo '<tr>';
echo '<td style="width: 100px;" class="entity-title"> Vlan ' . $vlan['vlan_vlan'] . '</td>';
echo '<td style="width: 200px;" class="small">' . $vlan['vlan_name'] . '</td>';
echo '<td class="strong">';
$vlan_ports = array();
$otherports = dbFetchRows("SELECT * FROM `ports_vlans` AS V, `ports` as P WHERE V.`device_id` = ? AND V.`vlan` = ? AND P.port_id = V.port_id", array($device['device_id'], $vlan['vlan_vlan']));
foreach ($otherports as $otherport) {
    $vlan_ports[$otherport['ifIndex']] = $otherport;
}
$otherports = dbFetchRows("SELECT * FROM ports WHERE `device_id` = ? AND `ifVlan` = ?", array($device['device_id'], $vlan['vlan_vlan']));
foreach ($otherports as $otherport) {
    $vlan_ports[$otherport['ifIndex']] = array_merge($otherport, array('untagged' => '1'));
}
ksort($vlan_ports);
foreach ($vlan_ports as $port) {
    humanize_port($port);
    if ($vars['view'] == "graphs") {
        echo "<div style='display: block; padding: 2px; margin: 2px; min-width: 139px; max-width:139px; min-height:85px; max-height:85px; text-align: center; float: left; background-color: " . $list_colour_b_b . ";'>\n    <div style='font-weight: bold;'>" . short_ifname($port['ifDescr']) . "</div>\n    <a href='device/device=" . $device['device_id'] . "/tab=port/port=" . $port['port_id'] . "/' onmouseover=\"return overlib('\\\n    <div style=\\'font-size: 16px; padding:5px; font-weight: bold; color: #e5e5e5;\\'>" . $device['hostname'] . " - " . $port['ifDescr'] . "</div>\\\n    " . $port['ifAlias'] . " \\\n    <img src=\\'graph.php?type={$graph_type}&amp;id=" . $port['port_id'] . "&amp;from=" . $config['time']['twoday'] . "&amp;to=" . $config['time']['now'] . "&amp;width=450&amp;height=150\\'>\\\n    ', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\"  >" . "<img src='graph.php?type={$graph_type}&amp;id=" . $port['port_id'] . "&amp;from=" . $config['time']['twoday'] . "&amp;to=" . $config['time']['now'] . "&amp;width=132&amp;height=40&amp;legend=no'>\n    </a>\n    <div style='font-size: 9px;'>" . short_port_descr($port['ifAlias']) . "</div>\n   </div>";
    } else {
        echo $vlan['port_sep'] . generate_port_link($port, short_ifname($port['label']));
        $vlan['port_sep'] = ", ";
        if ($port['untagged']) {
            echo "(U)";
        }
    }
}
echo '</td></tr>';
// EOF
开发者ID:skive,项目名称:observium,代码行数:31,代码来源:print-vlan.inc.php

示例10: short_ifname

                     case 'bits':
                     case 'upkts':
                     case 'nupkts':
                     case 'errors':
                         $port['width'] = "130";
                         $port['height'] = "30";
                         $port['from'] = $config['time']['day'];
                         $port['to'] = $config['time']['now'];
                         $port['bg'] = "#" . $bg;
                         $port['graph_type'] = "port_" . $_GET['optc'];
                         echo "<div style='display: block; padding: 3px; margin: 3px; min-width: 135px; max-width:135px; min-height:75px; max-height:75px;\n               text-align: center; float: left; background-color: " . $list_colour_b_b . ";'>\n               <div style='font-weight: bold;'>" . short_ifname($port['ifDescr']) . "</div>";
                         generate_port_thumbnail($port);
                         echo "<div style='font-size: 9px;'>" . short_port_descr($port['ifAlias']) . "</div>\n              </div>";
                         break;
                     default:
                         echo $seperator . generate_port_link($port, short_ifname($port['ifDescr']));
                         $seperator = ", ";
                         break;
                 }
             }
             echo "</td></tr>";
             $x++;
         }
         // End While
         echo "</table></td>";
         $i++;
     }
     echo "</table></div>";
 } else {
     echo "<div style='background: {$list_colour_a}; padding: 10px;'><table border=0 cellspacing=0 cellpadding=5 width=100%>";
     $vrf = dbFetchRow("SELECT * FROM `vrfs` WHERE mplsVpnVrfRouteDistinguisher = ?", array($_GET['optb']));
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:31,代码来源:vrf.inc.php

示例11: unset

    unset($sub);
    $hostname = $ip['hostname'];
    $real_hostname = $hostname;
    $hostname = str_replace(".jerseytelecom.net", "", $hostname);
    list($cc, $loc, $host) = explode(".", $hostname);
    if ($host) {
        $hostname = "{$host}.{$loc}.{$cc}.v4.data.net.uk";
    } else {
        $host = $cc;
        unset($cc);
        $hostname = "{$host}.v4.data.net.uk";
    }
    $interface = $ip['ifDescr'];
    $address = $ip['ipv4_address'];
    $cidr = $ip['ipv4_prefixlen'];
    $interface = short_ifname($interface);
    $interface = str_replace("/", "-", $interface);
    $interface = str_replace(":", "_", $interface);
    list($interface, $sub) = explode(".", $interface);
    if ($sub) {
        $sub = str_replace(" ", "", $sub);
        $sub = str_replace("aal5", "", $sub);
        $interface = "{$sub}.{$interface}";
    }
    $hostip = trim(gethostbyname($real_hostname));
    list($first, $second, $third, $fourth) = explode(".", $address);
    $revzone = "{$third}.{$second}.{$first}.in-addr.arpa";
    $reverse = "{$fourth}.{$revzone}";
    $dnsname = "{$interface}.{$hostname}";
    $dns_list[] = str_pad($revzone, 24) . "|" . str_pad($reverse, 30) . "IN ADDR  " . str_pad($dnsname, 30);
}
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:31,代码来源:generate-dnstext.php

示例12: print_addresses


//.........这里部分代码省略.........
    if ($address_type == 'ipv6') {
        $query_netscaler = str_replace(array('vsvr_ip', '0.0.0.0'), array('vsvr_ipv6', '0:0:0:0:0:0:0:0'), $query_netscaler);
        //$query_netscaler_count = str_replace(array('vsvr_ip', '0.0.0.0'), array('vsvr_ipv6', '0:0:0:0:0:0:0:0'), $query_netscaler_count);
    }
    $entries = dbFetchRows($query_netscaler, $param_netscaler);
    // Rewrite netscaler addresses
    foreach ($entries as $entry) {
        $ip_address = $address_type == 'ipv4' ? $entry['vsvr_ip'] : $entry['vsvr_' . $address_type];
        $ip_network = $address_type == 'ipv4' ? $entry['vsvr_ip'] . '/32' : $entry['vsvr_' . $address_type] . '/128';
        $ip_array[] = array('type' => 'netscaler_vsvr', 'device_id' => $entry['device_id'], 'hostname' => $entry['hostname'], 'vsvr_id' => $entry['vsvr_id'], 'vsvr_label' => $entry['vsvr_label'], 'ifAlias' => 'Netscaler: ' . $entry['vsvr_type'] . '/' . $entry['vsvr_entitytype'], $address_type . '_address' => $ip_address, $address_type . '_network' => $ip_network);
    }
    //print_message($query_netscaler_count);
    $query = 'FROM `ip_addresses` AS A ';
    $query .= 'LEFT JOIN `ports`   AS I ON I.`port_id`   = A.`port_id` ';
    $query .= 'LEFT JOIN `devices` AS D ON I.`device_id` = D.`device_id` ';
    $query .= 'LEFT JOIN `ip_networks` AS N ON N.`ip_network_id` = A.`ip_network_id` ';
    $query .= $where . $query_port_permitted;
    //$query_count = 'SELECT COUNT(`ip_address_id`) ' . $query;
    $query = 'SELECT * ' . $query;
    $query .= ' ORDER BY A.`ip_address`';
    if ($ip_valid) {
        $pagination = FALSE;
    }
    // Override by address type
    $query = str_replace(array('ip_address', 'ip_network'), array($address_type . '_address', $address_type . '_network'), $query);
    //$query_count = str_replace(array('ip_address', 'ip_network'), array($address_type.'_address', $address_type.'_network'), $query_count);
    // Query addresses
    $entries = dbFetchRows($query, $param);
    $ip_array = array_merge($ip_array, $entries);
    $ip_array = array_sort($ip_array, $address_type . '_address');
    // Query address count
    //if ($pagination) { $count = dbFetchCell($query_count, $param); }
    if ($pagination) {
        $count = count($ip_array);
        $ip_array = array_slice($ip_array, $start, $pagesize);
    }
    $list = array('device' => FALSE);
    if (!isset($vars['device']) || empty($vars['device']) || $vars['page'] == 'search') {
        $list['device'] = TRUE;
    }
    $string = '<table class="table table-bordered table-striped table-hover table-condensed">' . PHP_EOL;
    if (!$short) {
        $string .= '  <thead>' . PHP_EOL;
        $string .= '    <tr>' . PHP_EOL;
        if ($list['device']) {
            $string .= '      <th>Device</th>' . PHP_EOL;
        }
        $string .= '      <th>Interface</th>' . PHP_EOL;
        $string .= '      <th>Address</th>' . PHP_EOL;
        $string .= '      <th>Description</th>' . PHP_EOL;
        $string .= '    </tr>' . PHP_EOL;
        $string .= '  </thead>' . PHP_EOL;
    }
    $string .= '  <tbody>' . PHP_EOL;
    foreach ($ip_array as $entry) {
        $address_show = TRUE;
        if ($ip_valid) {
            // If address not in specified network, don't show entry.
            if ($address_type === 'ipv4') {
                $address_show = Net_IPv4::ipInNetwork($entry[$address_type . '_address'], $addr . '/' . $mask);
            } else {
                $address_show = Net_IPv6::isInNetmask($entry[$address_type . '_address'], $addr, $mask);
            }
        }
        if ($address_show) {
            list($prefix, $length) = explode('/', $entry[$address_type . '_network']);
            if (port_permitted($entry['port_id']) || $entry['type'] == 'netscaler_vsvr') {
                if ($entry['type'] == 'netscaler_vsvr') {
                    $entity_link = generate_entity_link($entry['type'], $entry);
                } else {
                    humanize_port($entry);
                    if ($entry['ifInErrors_delta'] > 0 || $entry['ifOutErrors_delta'] > 0) {
                        $port_error = generate_port_link($entry, '<span class="label label-important">Errors</span>', 'port_errors');
                    }
                    $entity_link = generate_port_link($entry, short_ifname($entry['label'])) . ' ' . $port_error;
                }
                $device_link = generate_device_link($entry);
                $string .= '  <tr>' . PHP_EOL;
                if ($list['device']) {
                    $string .= '    <td class="entity" style="white-space: nowrap">' . $device_link . '</td>' . PHP_EOL;
                }
                $string .= '    <td class="entity">' . $entity_link . '</td>' . PHP_EOL;
                if ($address_type === 'ipv6') {
                    $entry[$address_type . '_address'] = Net_IPv6::compress($entry[$address_type . '_address']);
                }
                $string .= '    <td>' . $entry[$address_type . '_address'] . '/' . $length . '</td>' . PHP_EOL;
                $string .= '    <td>' . $entry['ifAlias'] . '</td>' . PHP_EOL;
                $string .= '  </tr>' . PHP_EOL;
            }
        }
    }
    $string .= '  </tbody>' . PHP_EOL;
    $string .= '</table>';
    // Print pagination header
    if ($pagination) {
        $string = pagination($vars, $count) . $string . pagination($vars, $count);
    }
    // Print addresses
    echo $string;
}
开发者ID:skive,项目名称:observium,代码行数:101,代码来源:addresses.inc.php

示例13: generate_port_row


//.........这里部分代码省略.........
                            $int_links[$new['port_id']] = $new['port_id'];
                            $int_links_v6[$new['port_id']][] = $new['ipv6_network'];
                        }
                    }
                }
                // Output contents of links array
                foreach ($int_links as $int_link) {
                    $link_if = get_port_by_id_cache($int_link);
                    if (!device_permitted($link_if['device_id'])) {
                        continue;
                    }
                    // Skip not permitted links
                    $link_dev = device_by_id_cache($link_if['device_id']);
                    $string .= $br;
                    if ($int_links_phys[$int_link]) {
                        $string .= '<a data-alt="Directly connected" class="oicon-connect"></a> ';
                    } else {
                        $string .= '<a data-alt="Same subnet" class="oicon-network-hub"></a> ';
                    }
                    $string .= '<b>' . generate_port_link($link_if, $link_if['port_label_short']) . ' on ' . generate_device_link($link_dev, short_hostname($link_dev['hostname'])) . '</b>';
                    ## FIXME -- do something fancy here.
                    if ($int_links_v6[$int_link]) {
                        $string .= '&nbsp;' . overlib_link('', '<span class="label label-success">IPv6</span>', implode("<br />", $int_links_v6[$int_link]), NULL);
                    }
                    if ($int_links_v4[$int_link]) {
                        $string .= '&nbsp;' . overlib_link('', '<span class="label label-info">IPv4</span>', implode("<br />", $int_links_v4[$int_link]), NULL);
                    }
                    $br = "<br />";
                }
                // Output content of unknown links array (where ports don't exist in our database, or they weren't matched)
                foreach ($int_links_unknown as $int_link) {
                    // FIXME -- Expose platform and version here.
                    $string .= '<a data-alt="Directly connected" class="oicon-plug-connect"></a> ';
                    $string .= '<b><i>' . short_ifname($int_link['remote_port']) . '</i></b> on ';
                    $string .= '<i><b>' . generate_tooltip_link(NULL, $int_link['remote_hostname'], '<div class="small" style="max-width: 500px;"><b>' . $int_link['remote_platform'] . '</b><br />' . $int_link['remote_version'] . '</div>') . '</b></i>';
                    $string .= '<br />';
                }
            }
            if (!isset($cache['ports_option']['pseudowires']) || in_array($port['port_id'], $cache['ports_option']['pseudowires'])) {
                foreach (dbFetchRows("SELECT * FROM `pseudowires` WHERE `port_id` = ?", array($port['port_id'])) as $pseudowire) {
                    //`port_id`,`peer_device_id`,`peer_ldp_id`,`pwID`,`pwIndex`
                    #    $pw_peer_dev = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($pseudowire['peer_device_id']));
                    $pw_peer_int = dbFetchRow("SELECT * FROM `ports` AS I, `pseudowires` AS P WHERE I.`device_id` = ? AND P.`pwID` = ? AND P.`port_id` = I.`port_id`", array($pseudowire['peer_device_id'], $pseudowire['pwID']));
                    #    $pw_peer_int = get_port_by_id_cache($pseudowire['peer_device_id']);
                    $pw_peer_dev = device_by_id_cache($pseudowire['peer_device_id']);
                    if (is_array($pw_peer_int)) {
                        humanize_port($pw_peer_int);
                        $string .= $br . '<i class="oicon-arrow-switch"></i> <strong>' . generate_port_link($pw_peer_int, $pw_peer_int['port_label_short']) . ' on ' . generate_device_link($pw_peer_dev, short_hostname($pw_peer_dev['hostname'])) . '</strong>';
                    } else {
                        $string .= $br . '<i class="oicon-arrow-switch"></i> <strong> VC ' . $pseudowire['pwID'] . ' on ' . $pseudowire['peer_addr'] . '</strong>';
                    }
                    $string .= ' <span class="label">' . $pseudowire['pwPsnType'] . '</span>';
                    $string .= ' <span class="label">' . $pseudowire['pwType'] . '</span>';
                    $br = "<br />";
                }
            }
            if (!isset($cache['ports_option']['ports_pagp']) || in_array($port['ifIndex'], $cache['ports_option']['ports_pagp'])) {
                foreach (dbFetchRows("SELECT * FROM `ports` WHERE `pagpGroupIfIndex` = ? AND `device_id` = ?", array($port['ifIndex'], $device['device_id'])) as $member) {
                    humanize_port($member);
                    $pagp[$device['device_id']][$port['ifIndex']][$member['ifIndex']] = TRUE;
                    $string .= $br . '<i class="oicon-arrow-join"></i> <strong>' . generate_port_link($member) . ' [PAgP]</strong>';
                    $br = "<br />";
                }
            }
            if ($port['pagpGroupIfIndex'] && $port['pagpGroupIfIndex'] != $port['ifIndex']) {
                $pagp[$device['device_id']][$port['pagpGroupIfIndex']][$port['ifIndex']] = TRUE;
开发者ID:Natolumin,项目名称:observium,代码行数:67,代码来源:port.inc.php

示例14: foreach

$pagetitle[] = "客户";
foreach (dbFetchRows("SELECT * FROM `ports` WHERE `port_descr_type` = 'cust' GROUP BY `port_descr_descr` ORDER BY `port_descr_descr`") as $customer) {
    $customer_name = $customer['port_descr_descr'];
    foreach (dbFetchRows("SELECT * FROM `ports` WHERE `port_descr_type` = 'cust' AND `port_descr_descr` = ?", array($customer['port_descr_descr'])) as $port) {
        $device = device_by_id_cache($port['device_id']);
        unset($class);
        $ifname = rewrite_ifname($device['ifDescr']);
        $ifclass = ifclass($port['ifOperStatus'], $port['ifAdminStatus']);
        if ($device['os'] == "ios") {
            if ($port['ifTrunk']) {
                $vlan = "<span class=small><span class=red>" . $port['ifTrunk'] . "</span></span>";
            } elseif ($port['ifVlan']) {
                $vlan = "<span class=small><span class=blue>VLAN " . $port['ifVlan'] . "</span></span>";
            } else {
                $vlan = "";
            }
        }
        echo "\n           <tr>\n             <td width='250'><span style='font-weight: bold;' class=interface>" . $customer_name . "</span></td>\n             <td width='150'>" . generate_device_link($device) . "</td>\n             <td width='100'>" . generate_port_link($port, short_ifname($port['ifDescr'])) . "</td>\n             <td width='100'>" . $port['port_descr_speed'] . "</td>\n             <td width='100'>" . $port['port_descr_circuit'] . "</td>\n             <td>" . $port['port_descr_notes'] . "</td>\n           </tr>\n         ";
        unset($customer_name);
    }
    if ($config['int_customers_graphs']) {
        echo "<tr><td colspan=7>";
        $graph_array['type'] = "customer_bits";
        $graph_array['to'] = $config['time']['now'];
        $graph_array['id'] = $customer['port_descr_descr'];
        print_graph_row($graph_array);
        echo "</tr>";
    }
}
echo "</table>";
// EOF
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:31,代码来源:customers.inc.php

示例15: get_port_by_id

$port = get_port_by_id($port);
$device = device_by_id_cache($port['device_id']);
$pluses = "";
$iter = '0';
$rrd_options .= " COMMENT:'                                     In\\: Current     Maximum      Total      Out\\: Current     Maximum     Total\\\\n'";
foreach ($mas as $ma) {
    $this_rrd = get_rrd_path($device, "mac_acc-" . $port['ifIndex'] . "-" . $ma['vlan_id'] . "-" . $ma['mac'] . ".rrd");
    if (is_file($this_rrd)) {
        $mac = format_mac($ma['mac']);
        $name = $mac;
        $addy = dbFetchRow("SELECT * FROM ipv4_mac where mac_address = ? AND port_id = ?", array($ma['mac'], $ma['port_id']));
        if ($addy) {
            $name = $addy['ipv4_address'] . " (" . $mac . ")";
            $peer = dbFetchRow("SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D\n              WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND D.device_id = I.device_id", array($addy['ipv4_address']));
            if ($peer) {
                $name = $peer['hostname'] . " " . short_ifname($port['ifDescr'], NULL, FALSE) . " (" . $mac . ")";
            }
            if (dbFetchCell("SELECT COUNT(*) FROM bgpPeers WHERE device_id = ? AND bgpPeerIdentifier = ?", array($ma['device_id'], $addy['ipv4_address']))) {
                $peer_info = dbFetchRow("SELECT * FROM bgpPeers WHERE device_id = ? AND bgpPeerIdentifier = ?", array($ma['device_id'], $addy['ipv4_address']));
                $name .= " - AS" . $peer_info['bgpPeerRemoteAs'];
            }
            if ($peer_info) {
                $asn = "AS" . $peer_info['bgpPeerRemoteAs'];
                $astext = $peer_info['astext'];
            } else {
                unset($as);
                unset($astext);
                unset($asn);
            }
        }
        $this_id = str_replace(".", "", $ma['mac']);
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:31,代码来源:mac_acc_total.inc.php


注:本文中的short_ifname函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。