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


PHP get_port_by_id函数代码示例

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


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

示例1: get_entity_by_id_cache

/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage functions
 * @author     Adam Armstrong <adama@memetic.org>
 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
function get_entity_by_id_cache($type, $id)
{
    global $cache;
    if ($type !== 'port') {
        list($entity_table, $entity_id_field, $entity_name_field) = entity_type_translate($type);
    }
    if (is_array($cache[$type][$id])) {
        return $cache[$type][$id];
    } else {
        switch ($type) {
            case "port":
                $entity = get_port_by_id($id);
                break;
            default:
                $entity = dbFetchRow("SELECT * FROM `" . $entity_table . "` WHERE `" . $entity_id_field . "` = ?", array($id));
                if (function_exists('humanize_' . $type)) {
                    $do = 'humanize_' . $type;
                    $do($entity);
                }
                break;
        }
        if (is_array($entity)) {
            entity_rewrite($type, $entity);
            $cache[$type][$id] = $entity;
            return $entity;
        }
    }
    return FALSE;
}
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:40,代码来源:entities.inc.php

示例2: get_entity_by_id_cache

function get_entity_by_id_cache($entity_type, $entity_id)
{
    global $cache;
    $translate = entity_type_translate_array($entity_type);
    if (is_array($cache[$entity_type][$entity_id])) {
        return $cache[$entity_type][$entity_id];
    } else {
        switch ($entity_type) {
            case "port":
                $entity = get_port_by_id($entity_id);
                break;
            default:
                $entity = dbFetchRow("SELECT * FROM `" . $translate['table'] . "` WHERE `" . $translate['id_field'] . "` = ?", array($entity_id));
                if (function_exists('humanize_' . $entity_type)) {
                    $do = 'humanize_' . $entity_type;
                    $do($entity);
                } elseif (isset($translate['humanize_function']) && function_exists('humanize_' . $translate['humanize_function'])) {
                    $do = 'humanize_' . $translate['humanize_function'];
                    $do($entity);
                }
                break;
        }
        if (is_array($entity)) {
            entity_rewrite($entity_type, $entity);
            $cache[$entity_type][$entity_id] = $entity;
            return $entity;
        }
    }
    return FALSE;
}
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:30,代码来源:entities.inc.php

示例3: foreach

<?php

echo '<table class="table table-striped table-condensed">';
$i = "1";
echo '<thead><th>Local Port</th>
          <th>Remote Port</th>
          <th>Remote Device</th>
          <th>Protocol</th>
      </thead>';
foreach (dbFetchRows("SELECT * FROM links AS L, ports AS I WHERE I.device_id = ? AND I.port_id = L.local_port_id", array($device['device_id'])) as $neighbour) {
    if ($bg_colour == $list_colour_b) {
        $bg_colour = $list_colour_a;
    } else {
        $bg_colour = $list_colour_b;
    }
    echo '<tr bgcolor="' . $bg_colour . '">';
    echo '<td><span style="font-weight: bold;">' . generate_port_link($neighbour) . '</span><br />' . $neighbour['ifAlias'] . '</td>';
    if (is_numeric($neighbour['remote_port_id']) && $neighbour['remote_port_id']) {
        $remote_port = get_port_by_id($neighbour['remote_port_id']);
        $remote_device = device_by_id_cache($remote_port['device_id']);
        echo "<td>" . generate_port_link($remote_port) . "<br />" . $remote_port['ifAlias'] . "</td>";
        echo "<td>" . generate_device_link($remote_device) . "<br />" . $remote_device['hardware'] . "</td>";
    } else {
        echo "<td>" . $neighbour['remote_port'] . "</td>";
        echo "<td>" . $neighbour['remote_hostname'] . "\n          <br />" . $neighbour['remote_platform'] . "</td>";
    }
    echo "<td>" . strtoupper($neighbour['protocol']) . "</td>";
    echo "</tr>";
    $i++;
}
echo "</table>";
开发者ID:RomanBogachev,项目名称:observium,代码行数:31,代码来源:neighbours.inc.php

示例4: print_debug

             // Hola, port really found
             $options['entPhysicalIndex_measured'] = $ifIndex;
             $options['measured_class'] = 'port';
             $options['measured_entity'] = $port['port_id'];
             print_debug("Port is found: ifIndex = {$ifIndex}, port_id = " . $port['port_id']);
         }
     }
     break;
     // Exit while
 } else {
     if ($device['os'] == 'arista_eos' && $sensor_port['entPhysicalClass'] == 'container' && strlen($sensor_port['entPhysicalAlias'])) {
         // Arista not have entAliasMappingIdentifier, but used entPhysicalAlias as ifDescr
         $port_id = get_port_id_by_ifDescr($device['device_id'], $sensor_port['entPhysicalAlias']);
         if (is_numeric($port_id)) {
             // Hola, port really found
             $port = get_port_by_id($port_id);
             $ifIndex = $port['ifIndex'];
             $options['entPhysicalIndex_measured'] = $ifIndex;
             $options['measured_class'] = 'port';
             $options['measured_entity'] = $port_id;
             print_debug("Port is found: ifIndex = {$ifIndex}, port_id = " . $port_id);
             break;
             // Exit while
         }
         $sensor_index = $sensor_port['entPhysicalContainedIn'];
         // Next ifIndex
     } else {
         if ($sensor_index == $sensor_port['entPhysicalContainedIn']) {
             break;
             // Break if current index same as next to avoid loop
         } else {
开发者ID:Natolumin,项目名称:observium,代码行数:31,代码来源:entity-sensor-mib.inc.php

示例5: foreach

            }
            ?>

          </select>
          <button class="btn pull-right" type="submit" name="提交" value="添加"><i class="oicon-plus-circle"></i> 添加</button>
        </form>
      </div>
    </div>
    <div class="col-md-4">
      <div class="well">
        <h2>端口权限</h2>

<?php 
            if (count($user_permissions['port'])) {
                foreach (array_keys($user_permissions['port']) as $entity_id) {
                    $port = get_port_by_id($entity_id);
                    $device = device_by_id_cache($port['device_id']);
                    $emptyCheck = true;
                    $count++;
                    $devicebtn = '<button class="btn"><i class="oicon-servers"></i> ' . generate_device_link($device) . '</button>';
                    if (empty($port['ifAlias'])) {
                        $portalias = "";
                    } else {
                        $portalias = " - " . $port['ifAlias'] . "";
                    }
                    $portbtn = '<button class="btn">' . generate_port_link($port, '<i class="oicon-network-ethernet"></i> ' . rewrite_ifname($port['label']) . $portalias) . '</button>';
                    $del_url = generate_url(array('page' => 'edituser', 'action' => 'perm_del', 'user_id' => $vars['user_id'], 'entity_type' => 'port', 'entity_id' => $entity_id));
                    echo '            <div class="btn-group" style="margin: 5px;">';
                    echo '              <button class="btn btn-danger" style="color: #fff;" onclick="location.href=\'' . $del_url . '\';"><i class="icon-minus-sign icon-white"></i> 删除</button>';
                    echo '              ' . $devicebtn;
                    echo '              ' . $portbtn;
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:31,代码来源:edituser.inc.php

示例6: get_vars

 *   This file is included with Observium. It was originally part of m0n0wall <http://www.m0n0.ch/wall/>
 *
 * @package    observium
 * @subpackage graphing
 * @author     T. Lechat <dev@lechat.org>, Manuel Kasper <mk@neon1.net>, Jonathan Watt <jwatt@jwatt.org>
 * @copyright  2004-2006 T. Lechat <dev@lechat.org>, Manuel Kasper <mk@neon1.net>, Jonathan Watt <jwatt@jwatt.org>
 * @license    BSD
 *
 */
include_once "../includes/sql-config.inc.php";
include $config['html_dir'] . "/includes/functions.inc.php";
include $config['html_dir'] . "/includes/authenticate.inc.php";
// Push $_GET into $vars to be compatible with web interface naming
$vars = get_vars('GET');
if (is_numeric($vars['id']) && ($config['allow_unauth_graphs'] || 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  " . generate_port_link($port);
    $auth = TRUE;
} else {
    echo "Unauthenticated";
    die;
}
header("Content-type: image/svg+xml");
/********** HTTP GET Based Conf ***********/
$ifnum = $port['ifIndex'];
// BSD / SNMP interface name / number
$ifname = escape_html($port['port_label']);
//Interface name that will be showed on top right of graph
$hostname = short_hostname($device['hostname']);
开发者ID:Natolumin,项目名称:observium,代码行数:31,代码来源:graph-realtime.php

示例7: dbFetchRows

<?php

$res = "";
$count = 0;
$speed = 0;
$port_ids = dbFetchRows("SELECT `port_id` FROM `bill_ports` WHERE bill_id = ?", array($bill_id));
foreach ($port_ids as $port_entry) {
    $port = get_port_by_id($port_entry['port_id']);
    $device = device_by_id_cache($port['device_id']);
    $emptyCheck = true;
    $count++;
    $speed += $port['ifSpeed'];
    /// FIXME - clean this up, it's horrible.
    $devicebtn = '<button class="btn"><i class="oicon-servers"></i> ' . generate_device_link($device) . '</button>';
    if (empty($port['ifAlias'])) {
        $portalias = "";
    } else {
        $portalias = " - " . $port['ifAlias'] . "";
    }
    $portbtn = '<button class="btn">' . generate_port_link($port, '<i class="oicon-network-ethernet"></i> ' . $port['label'] . $portalias) . '</button>';
    #  $portbtn = str_replace("interface-upup", "btn btn-mini", generate_port_link($port, "<i class='icon-random'></i> ".$port['label'].$portalias));
    #  $portbtn = str_replace("interface-updown", "btn btn-mini btn-danger", $portbtn);
    #  $portbtn = str_replace("interface-downdown", "btn btn-mini btn-danger", $portbtn);
    #  $portbtn = str_replace("interface-admindown", "btn btn-mini btn-warning disabled", $portbtn);
    #  $res    .= "          <div class=\"btn-toolbar\">\n";
    $res .= "            <div class=\"btn-group\">\n";
    $res .= "              " . $devicebtn . "\n";
    $res .= "              " . $portbtn . "\n";
    $res .= "            </div><br />\n";
    #  $res    .= "          </div>\n";
}
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:31,代码来源:ports.inc.php

示例8: print_vars

 if ($debug) {
     echo "<pre>";
     print_vars($ma);
     echo "</pre>";
 }
 if (is_array($ma)) {
     if ($auth || port_permitted($ma['port_id'])) {
         $rrd_filename = $config['rrd_dir'] . "/" . $ma['hostname'] . "/" . safename("mac_acc-" . $ma['ifIndex'] . "-" . $ma['vlan_id'] . "-" . $ma['mac'] . ".rrd");
         if ($debug) {
             echo $rrd_filename;
         }
         if (is_file($rrd_filename)) {
             if ($debug) {
                 echo "exists";
             }
             $port = get_port_by_id($ma['port_id']);
             $device = device_by_id_cache($port['device_id']);
             $title = generate_device_link($device);
             $title .= " :: Port  " . generate_port_link($port);
             $title .= " :: Mac Accounting";
             $title .= " :: " . formatMac($ma['mac']);
             $auth = TRUE;
         } else {
             #     graph_error("file not found");
         }
     } else {
         #    graph_error("unauthenticated");
     }
 } else {
     #   graph_error("entry not found");
 }
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:31,代码来源:auth.inc.php

示例9: print_error

 *
 */
$config['install_dir'] = "../..";
require_once $config['install_dir'] . "/includes/sql-config.inc.php";
include $config['html_dir'] . "/includes/functions.inc.php";
include $config['html_dir'] . "/includes/authenticate.inc.php";
if (!$_SESSION['authenticated']) {
    print_error('Session expired, please log in again!');
    exit;
}
$vars = get_vars();
$vars['page'] = "popup";
switch ($vars['entity_type']) {
    case "port":
        if (is_numeric($vars['entity_id']) && port_permitted($vars['entity_id'])) {
            $port = get_port_by_id($vars['entity_id']);
            echo generate_port_popup($port);
        } else {
            print_warning("You are not permitted to view this port.");
        }
        exit;
        break;
    case "device":
        if (is_numeric($vars['entity_id']) && device_permitted($vars['entity_id'])) {
            $device = device_by_id_cache($vars['entity_id']);
            echo generate_device_popup($device, $vars, $start, $end);
        } else {
            print_warning("You are not permitted to view this device.");
        }
        exit;
        break;
开发者ID:Natolumin,项目名称:observium,代码行数:31,代码来源:entity_popup.php

示例10: elseif

} elseif ($stat == "bits") {
    $units = 'bps';
    $unit = 'B';
    $multiplier = '8';
    $colours_in = 'greens';
    $colours_out = 'blues';
    if ($sort == "in") {
        $sort = "bytes_input_rate";
    } elseif ($sort == "out") {
        $sort = "bytes_output_rate";
    } else {
        $sort = "bps";
    }
}
$mas = dbFetchRows("SELECT *, (bytes_input_rate + bytes_output_rate) AS bps,\n        (pkts_input_rate + pkts_output_rate) AS pps\n        FROM `mac_accounting`\n        LEFT JOIN  `mac_accounting-state` ON  `mac_accounting`.ma_id =  `mac_accounting-state`.ma_id\n        WHERE `mac_accounting`.port_id = ?\n        ORDER BY {$sort} DESC LIMIT 0," . $topn, array($port));
$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 . ")";
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:31,代码来源:mac_acc_total.inc.php

示例11: foreach

 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage webui
 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
// Ports
// Print table of EIGRP interfaces from eigrp_ports.
echo '<table class="table table-hover table-striped-two table-bordered table-condensed table-rounded">';
echo '<thead>';
echo '<tr><th></th><th></th><th>Port</th><th>AS</th><th>Peers</th><th>Mean SRTT</th><th>Auth</th></tr>';
echo '</thead>';
echo '<tbody>';
foreach (dbFetchRows("SELECT * FROM `eigrp_ports` WHERE `device_id` = ?", array($device['device_id'])) as $eigrp_port) {
    $port = get_port_by_id($eigrp_port['port_id']);
    echo '<tr class="' . $port['row_class'] . '" onclick="location.href=\'' . generate_port_url($port) . '/\'" style="cursor: pointer;">

          <td style="width: 1px; background-color: ' . $port['table_tab_colour'] . '; margin: 0px; padding: 0px"></td>
          <td style="width: 1px;"></td>
          <td><span class="entity-title">' . generate_port_link($port) . '</span><br />
                                 ' . $port['ifAlias'] . '</td>
          <td>' . $eigrp_port['eigrp_as'] . '</td>
          <td>' . $eigrp_port['eigrp_peer_count'] . '</td>
          <td>' . $eigrp_port['eigrp_MeanSrtt'] . '</td>
          <td>' . $eigrp_port['eigrp_authmode'] . '</td>
        </tr>
        <tr>
          <td colspan=7>';
    $graph_array['to'] = $config['time']['now'];
    $graph_array['id'] = $eigrp_port['eigrp_port_id'];
开发者ID:skive,项目名称:observium,代码行数:31,代码来源:eigrp_ports.inc.php

示例12: array

 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
echo "Mac Accounting: ";
// FIXME -- we're walking, so we can discover here too.
#dbQuery("TRUNCATE TABLE `mac_accounting`");
#dbQuery("TRUNCATE TABLE `mac_accounting-state`");
// Cache DB entries
echo "Caching DB...";
$sql = "SELECT *, `mac_accounting`.`ma_id` as `ma_id`";
$sql .= " FROM  `mac_accounting`";
$sql .= " LEFT JOIN  `mac_accounting-state` ON  `mac_accounting`.ma_id =  `mac_accounting-state`.ma_id";
$sql .= " WHERE `device_id` = ?";
$arg = array($device['device_id']);
foreach (dbFetchRows($sql, $arg) as $acc) {
    $port = get_port_by_id($acc['port_id']);
    $acc['ifIndex'] = $port['ifIndex'];
    unset($port);
    $ma_db_array[$acc['ifIndex'] . '-' . $acc['vlan_id'] . '-' . $acc['mac']] = $acc;
}
if ($debug) {
    print_vars($ma_db_array);
}
echo count($ma_db_array) . " entries. ";
if (is_device_mib($device, 'JUNIPER-MAC-MIB')) {
    $datas = snmp_walk($device, "JUNIPER-MAC-MIB::jnxMacStatsEntry", "-OUqsX", "JUNIPER-MAC-MIB", mib_dirs("juniper"));
    foreach (explode("\n", $datas) as $data) {
        list($oid, $ifIndex, $vlan, $mac, $value) = parse_oid2($data);
        list($a_a, $a_b, $a_c, $a_d, $a_e, $a_f) = explode(":", $mac);
        $ah_a = zeropad($a_a);
        $ah_b = zeropad($a_b);
开发者ID:skive,项目名称:observium,代码行数:31,代码来源:mac-accounting.inc.php

示例13: dbFetchRow

<?php

/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage graphs
 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
if (is_numeric($vars['id'])) {
    $data = dbFetchRow("SELECT * FROM `eigrp_ports` WHERE `eigrp_port_id` = ?", array($vars['id']));
    if (is_numeric($data['device_id']) && ($auth || device_permitted($data['device_id']))) {
        $device = device_by_id_cache($data['device_id']);
        $port = get_port_by_id($data['port_id']);
        $rrd_filename = get_rrd_path($device, "eigrp_port-" . $data['eigrp_vpn'] . "-" . $data['eigrp_as'] . "-" . $port['ifIndex'] . ".rrd");
        $title = generate_device_link($device);
        $title .= " :: EIGRP :: Port :: " . htmlentities($port['label']);
        $auth = TRUE;
    }
}
// EOF
开发者ID:skive,项目名称:observium,代码行数:24,代码来源:auth.inc.php

示例14: get_entity_by_id_cache

function get_entity_by_id_cache($entity_type, $entity_id)
{
    global $cache;
    $translate = entity_type_translate_array($entity_type);
    if (is_array($cache[$entity_type][$entity_id])) {
        return $cache[$entity_type][$entity_id];
    } else {
        switch ($entity_type) {
            case "bill":
                if (function_exists('get_bill_by_id')) {
                    $entity = get_bill_by_id($entity_id);
                }
                break;
            case "port":
                $entity = get_port_by_id($entity_id);
                break;
            default:
                $sql = 'SELECT * FROM `' . $translate['table'] . '`';
                if (isset($translate['state_table'])) {
                    $sql .= ' LEFT JOIN `' . $translate['state_table'] . '` USING (`' . $translate['id_field'] . '`)';
                }
                $sql .= ' WHERE `' . $translate['table'] . '`.`' . $translate['id_field'] . '` = ?';
                $entity = dbFetchRow($sql, array($entity_id));
                if (function_exists('humanize_' . $entity_type)) {
                    $do = 'humanize_' . $entity_type;
                    $do($entity);
                } else {
                    if (isset($translate['humanize_function']) && function_exists($translate['humanize_function'])) {
                        $do = $translate['humanize_function'];
                        $do($entity);
                    }
                }
                break;
        }
        if (is_array($entity)) {
            entity_rewrite($entity_type, $entity);
            $cache[$entity_type][$entity_id] = $entity;
            return $entity;
        }
    }
    return FALSE;
}
开发者ID:Natolumin,项目名称:observium,代码行数:42,代码来源:entities.inc.php

示例15: get_status_array

function get_status_array($status)
{
    // Mike: I know that there are duplicated variables, but later will remove global
    global $config;
    global $cache;
    $param = array();
    if ($_SESSION['userlevel'] >= 5) {
        $query_perms = '';
        $query_user = '';
    } else {
        $query_perms = 'LEFT JOIN devices_perms AS P ON D.device_id = P.device_id ';
        $query_user = ' AND P.user_id = ? ';
        $param[] = $_SESSION['user_id'];
    }
    // Don't show ignored and disabled devices
    $query_device = ' AND D.ignore = 0 ';
    if (!$config['web_show_disabled']) {
        $query_device .= 'AND D.disabled = 0 ';
    }
    // Show Device Status
    if ($status['devices']) {
        $query = 'SELECT * FROM `devices` AS D ';
        $query .= $query_perms;
        $query .= 'WHERE D.status = 0' . $query_device . $query_user;
        $query .= 'ORDER BY D.hostname ASC';
        $entries = dbFetchRows($query, $param);
        foreach ($entries as $device) {
            $boxes[] = array('sev' => 100, 'class' => 'Device', 'event' => 'Down', 'device_link' => generate_device_link($device, shorthost($device['hostname'])), 'time' => deviceUptime($device, 'short-3'));
        }
    }
    // Uptime
    if ($status['uptime']) {
        if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) {
            $query = 'SELECT * FROM `devices` AS D ';
            $query .= $query_perms;
            $query .= 'WHERE D.status = 1 AND D.uptime > 0 AND D.uptime < ' . $config['uptime_warning'] . $query_device . $query_user;
            $query .= 'ORDER BY D.hostname ASC';
            $entries = dbFetchRows($query, $param);
            foreach ($entries as $device) {
                $boxes[] = array('sev' => 10, 'class' => 'Device', 'event' => 'Rebooted', 'device_link' => generate_device_link($device, shorthost($device['hostname'])), 'time' => deviceUptime($device, 'short-3'), 'location' => $device['location']);
            }
        }
    }
    // Ports Down
    if ($status['ports'] || $status['links']) {
        // warning about deprecated option: $config['warn']['ifdown']
        if (isset($config['warn']['ifdown']) && !$config['warn']['ifdown']) {
            echo '
  <div class="alert">
     <button type="button" class="close" data-dismiss="alert">&times;</button>
     <p><i class="oicon-bell"></i> <strong>Config option obsolete</strong></p>
     <p>Please note that config option <strong>$config[\'warn\'][\'ifdown\']</strong> is now obsolete.<br />Use options: <strong>$config[\'frontpage\'][\'device_status\'][\'ports\']</strong> and <strong>$config[\'frontpage\'][\'device_status\'][\'errors\']</strong></p>
     <p>To remove this message, delete <strong>$config[\'warn\'][\'ifdown\']</strong> from configuration file.</p>
  </div>';
        }
        $query = 'SELECT * FROM `ports` AS I ';
        if ($status['links'] && !$status['ports']) {
            $query .= 'INNER JOIN links as L ON I.port_id = L.local_port_id ';
        }
        $query .= 'LEFT JOIN `devices` AS D ON I.device_id = D.device_id ';
        $query .= $query_perms;
        $query .= "WHERE I.ifOperStatus = 'down' AND I.ifAdminStatus = 'up' AND I.ignore = 0 AND I.deleted = 0 ";
        if ($status['links'] && !$status['ports']) {
            $query .= ' AND L.active = 1 ';
        }
        $query .= $query_device . $query_user;
        $query .= ' AND I.ifLastChange >= DATE_SUB(NOW(), INTERVAL 24 HOUR) ';
        $query .= 'ORDER BY I.ifLastChange DESC, D.hostname ASC, I.ifDescr * 1 ASC ';
        $entries = dbFetchRows($query, $param);
        //$count = count($entries);
        $i = 1;
        foreach ($entries as $port) {
            if ($i > 200) {
                // Limit to 200 ports on overview page
                $string .= '  <tr><td></td><td><span class="badge badge-info">Port</span></td>';
                $string .= '<td><span class="label label-important">Port Down</span></td>';
                $string .= '<td colspan=3>Too many ports down. See <strong><a href="' . generate_url(array('page' => 'ports'), array('state' => 'down')) . '">All DOWN ports</a></strong>.</td></tr>' . PHP_EOL;
                break;
            }
            humanize_port($port);
            $boxes[] = array('sev' => 50, 'class' => 'Port', 'event' => 'Down', 'device_link' => generate_device_link($port, shorthost($port['hostname'])), 'entity_link' => generate_port_link($port, truncate(makeshortif($port['label']), 13, '')), 'time' => formatUptime($config['time']['now'] - strtotime($port['ifLastChange'])), 'location' => $device['location']);
            // We don't do anything with this here at the moment. There is no comment on it, what is it for?
            // if ($status['links'] && !$status['ports']) { $string .= ' ('.strtoupper($port['protocol']).': ' .$port['remote_hostname'].' / ' .$port['remote_port'] .')'; }
        }
    }
    // Ports Errors (only deltas)
    if ($status['errors']) {
        foreach ($cache['ports_errored'] as $port_id) {
            $port = get_port_by_id($port_id);
            if (port_permitted($port)) {
                $device = device_by_id_cache($port['device_id']);
                humanize_port($port);
                if ($port['ifInErrors_delta']) {
                    $port['string'] .= 'Rx: ' . $port['ifInErrors_delta'];
                }
                if ($port['ifInErrors_delta'] && $port['ifOutErrors_delta']) {
                    $port['string'] .= ', ';
                }
                if ($port['ifOutErrors_delta']) {
                    $port['string'] .= 'Tx: ' . $port['ifOutErrors_delta'];
//.........这里部分代码省略.........
开发者ID:RomanBogachev,项目名称:observium,代码行数:101,代码来源:functions-print.inc.php


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