• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP humanspeed函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: array_sort

    case 'errors':
        $ports = array_sort($ports, 'ifErrors_rate', SORT_DESC);
        break;
    case 'speed':
        $ports = array_sort($ports, 'ifSpeed', SORT_DESC);
        break;
    case 'port':
        $ports = array_sort($ports, 'ifDescr', SORT_ASC);
        break;
    case 'media':
        $ports = array_sort($ports, 'ifType', SORT_ASC);
        break;
    case 'descr':
        $ports = array_sort($ports, 'ifAlias', SORT_ASC);
        break;
    case 'device':
    default:
        $ports = array_sort($ports, 'hostname', SORT_ASC);
}
//end switch
$csv[] = array('Device', 'Port', 'Speed', 'Down', 'Up', 'Media', 'Description');
foreach ($ports as $port) {
    if (port_permitted($port['port_id'], $port['device_id'])) {
        $speed = humanspeed($port['ifSpeed']);
        $type = humanmedia($port['ifType']);
        $port['in_rate'] = formatRates($port['ifInOctets_rate'] * 8);
        $port['out_rate'] = formatRates($port['ifOutOctets_rate'] * 8);
        $port = ifLabel($port, $device);
        $csv[] = array($port['hostname'], fixIfName($port['label']), $speed, $port['in_rate'], $port['out_rate'], $type, $port['ifAlias']);
    }
}
开发者ID:sfromm,项目名称:librenms,代码行数:31,代码来源:ports.csv.inc.php


示例2: WHERE

      <select name="ifSpeed" id="ifSpeed" class="form-control input-sm">
        <option value="">All Speeds</option>
<?php 
    if (is_admin() === TRUE || is_read() === TRUE) {
        $sql = "SELECT `ifSpeed` FROM `ports` GROUP BY `ifSpeed` ORDER BY `ifSpeed`";
    } else {
        $sql = "SELECT `ifSpeed` FROM `ports` AS `I`, `devices` AS `D`, `devices_perms` AS `P`, `ports_perms` AS `PP` WHERE ((`P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id`) OR (`PP`.`user_id` = ? AND `PP`.`port_id` = `I`.`port_id` AND `I`.`device_id` = `D`.`device_id`)) AND `D`.`device_id` = `I`.`device_id` GROUP BY `ifSpeed` ORDER BY `ifSpeed`";
        $param[] = array($_SESSION['user_id'], $_SESSION['user_id']);
    }
    foreach (dbFetchRows($sql, $param) as $data) {
        if ($data['ifSpeed']) {
            echo "<option value='" . $data['ifSpeed'] . "'";
            if ($data['ifSpeed'] == $vars['ifSpeed']) {
                echo "selected";
            }
            echo ">" . humanspeed($data['ifSpeed']) . "</option>";
        }
    }
    ?>
       </select>
    </div>
    <div class="form-group">
      <select name="ifType" id="ifType" class="form-control input-sm">
        <option value="">All Media</option>
<?php 
    if (is_admin() === TRUE || is_read() === TRUE) {
        $sql = "SELECT `ifType` FROM `ports` GROUP BY `ifType` ORDER BY `ifType`";
    } else {
        $sql = "SELECT `ifType` FROM `ports` AS `I`, `devices` AS `D`, `devices_perms` AS `P`, `ports_perms` AS `PP` WHERE ((`P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id`) OR (`PP`.`user_id` = ? AND `PP`.`port_id` = `I`.`port_id` AND `I`.`device_id` = `D`.`device_id`)) AND `D`.`device_id` = `I`.`device_id` GROUP BY `ifType` ORDER BY `ifType`";
        $param[] = array($_SESSION['user_id'], $_SESSION['user_id']);
    }
开发者ID:sfromm,项目名称:librenms,代码行数:31,代码来源:ports.inc.php


示例3: humanize_port

/**
 * Humanize port.
 *
 * Returns a the $port array with processed information:
 * label, humans_speed, human_type, html_class and human_mac
 * row_class, table_tab_colour
 *
 * @param array $ports
 * @return array $ports
 *
 */
function humanize_port(&$port)
{
    global $config;
    // Process port data to make it pretty for printing. EVOLUTION, BITCHES.
    // Lots of hacky shit will end up here with if (os);
    $device = device_by_id_cache($port['device_id']);
    $os = $device['os'];
    $port['human_speed'] = humanspeed($port['ifSpeed']);
    $port['human_type'] = fixiftype($port['ifType']);
    $port['html_class'] = ifclass($port['ifOperStatus'], $port['ifAdminStatus']);
    $port['human_mac'] = formatMac($port['ifPhysAddress']);
    if (isset($config['os'][$os]['ifname'])) {
        $port['label'] = $port['ifName'];
        if ($port['ifName'] == "") {
            $port['label'] = $port['ifDescr'];
        } else {
            $port['label'] = $port['ifName'];
        }
    } elseif (isset($config['os'][$os]['ifalias'])) {
        $port['label'] = $port['ifAlias'];
    } else {
        $port['label'] = $port['ifDescr'];
        if (isset($config['os'][$os]['ifindex'])) {
            $port['label'] = $port['label'] . " " . $port['ifIndex'];
        }
    }
    if ($device['os'] == "speedtouch") {
        list($port['label']) = explode("thomson", $port['label']);
    }
    if ($port['ifAdminStatus'] == "down") {
        $port['table_tab_colour'] = "#aaaaaa";
        $port['row_class'] = "";
    } elseif ($port['ifAdminStatus'] == "up" && $port['ifOperStatus'] == "down") {
        $port['table_tab_colour'] = "#cc0000";
        $port['row_class'] = "error";
    } elseif ($port['ifAdminStatus'] == "up" && $port['ifOperStatus'] == "lowerLayerDown") {
        $port['table_tab_colour'] = "#ff6600";
        $port['row_class'] = "warning";
    } elseif ($port['ifAdminStatus'] == "up" && $port['ifOperStatus'] == "up") {
        $port['table_tab_colour'] = "#194B7F";
        $port['row_class'] = "";
    }
    $port['humanized'] = TRUE;
    /// Set this so we can check it later.
}
开发者ID:RomanBogachev,项目名称:observium,代码行数:56,代码来源:rewrites.php


示例4: generate_port_link

if ($port_details) {
    $port['graph_type'] = "port_bits";
    echo generate_port_link($port, "<img src='graph.php?type=port_bits&amp;id=" . $port['port_id'] . "&amp;from=" . $config['time']['day'] . "&amp;to=" . $config['time']['now'] . "&amp;width=100&amp;height=20&amp;legend=no' alt=\"\" />");
    $port['graph_type'] = "port_upkts";
    echo generate_port_link($port, "<img src='graph.php?type=port_upkts&amp;id=" . $port['port_id'] . "&amp;from=" . $config['time']['day'] . "&amp;to=" . $config['time']['now'] . "&amp;width=100&amp;height=20&amp;legend=no' alt=\"\" />");
    $port['graph_type'] = "port_errors";
    echo generate_port_link($port, "<img src='graph.php?type=port_errors&amp;id=" . $port['port_id'] . "&amp;from=" . $config['time']['day'] . "&amp;to=" . $config['time']['now'] . "&amp;width=100&amp;height=20&amp;legend=no' alt=\"\" />");
}
echo '</td><td style="width: 120px; white-space: nowrap;">';
if ($port['ifOperStatus'] == "up" || $port['ifOperStatus'] == "monitoring") {
    // Colours generated by humanize_port
    echo '<i class="icon-circle-arrow-down" style="', $port['bps_in_style'], '"></i> <span class="small" style="', $port['bps_in_style'], '">', formatRates($port['in_rate']), '</span><br />', '<i class="icon-circle-arrow-up"   style="', $port['bps_out_style'], '"></i> <span class="small" style="', $port['bps_out_style'], '">', formatRates($port['out_rate']), '</span><br />', '<i class="icon-circle-arrow-down" style="', $port['pps_in_style'], '"></i> <span class="small" style="', $port['pps_in_style'], '">', format_bi($port['ifInUcastPkts_rate']), 'pps</span><br />', '<i class="icon-circle-arrow-up"   style="', $port['pps_out_style'], '"></i> <span class="small" style="', $port['pps_out_style'], '">', format_bi($port['ifOutUcastPkts_rate']), 'pps</span>';
}
echo '</td><td style="width: 75px;">';
if ($port['ifSpeed']) {
    echo "<span class=small>" . humanspeed($port['ifSpeed']) . "</span>";
}
echo "<br />";
if ($port['ifDuplex'] != "unknown") {
    echo "<span class=small>" . $port['ifDuplex'] . "</span>";
} else {
    echo "-";
}
if ($port['ifTrunk']) {
    if ($port['ifVlan']) {
        // Native VLAN
        if (!isset($ports_vlan_cache)) {
            $native_state = dbFetchCell('SELECT `state` FROM `ports_vlans` WHERE `device_id` = ? AND `port_id` = ?', array($device['device_id'], $port['port_id']));
            $native_name = dbFetchCell('SELECT `vlan_name` FROM vlans     WHERE `device_id` = ? AND `vlan_vlan` = ?;', array($device['device_id'], $port['ifVlan']));
        } else {
            $native_state = $ports_vlan_cache[$port['port_id']][$port['ifVlan']]['state'];
开发者ID:skive,项目名称:observium,代码行数:31,代码来源:print-interface.inc.php


示例5: generate_port_link

    $port['graph_type'] = "port_upkts";
    echo generate_port_link($port, "<img src='graph.php?type=port_upkts&amp;id=" . $port['port_id'] . "&amp;from=" . $config['time']['day'] . "&amp;to=" . $config['time']['now'] . "&amp;width=100&amp;height=20&amp;legend=no&amp;bg=" . str_replace("#", "", $row_colour) . "'>");
    $port['graph_type'] = "port_errors";
    echo generate_port_link($port, "<img src='graph.php?type=port_errors&amp;id=" . $port['port_id'] . "&amp;from=" . $config['time']['day'] . "&amp;to=" . $config['time']['now'] . "&amp;width=100&amp;height=20&amp;legend=no&amp;bg=" . str_replace("#", "", $row_colour) . "'>");
}
echo "</td><td width=120>";
if ($port['ifOperStatus'] == "up") {
    $port['in_rate'] = $port['ifInOctets_rate'] * 8;
    $port['out_rate'] = $port['ifOutOctets_rate'] * 8;
    $in_perc = @round($port['in_rate'] / $port['ifSpeed'] * 100);
    $out_perc = @round($port['in_rate'] / $port['ifSpeed'] * 100);
    echo "<img src='images/16/arrow_left.png' align=absmiddle> <span style='color: " . percent_colour($in_perc) . "'>" . formatRates($port['in_rate']) . "<br />\n        <img align=absmiddle src='images/16/arrow_out.png'> <span style='color: " . percent_colour($out_perc) . "'>" . formatRates($port['out_rate']) . "<br />\n        <img src='images/icons/arrow_pps_in.png' align=absmiddle> " . format_bi($port['ifInUcastPkts_rate']) . "pps</span><br />\n        <img src='images/icons/arrow_pps_out.png' align=absmiddle> " . format_bi($port['ifOutUcastPkts_rate']) . "pps</span>";
}
echo "</td><td width=75>";
if ($port['ifSpeed']) {
    echo "<span class=box-desc>" . humanspeed($port['ifSpeed']) . "</span>";
}
echo "<br />";
if ($port[ifDuplex] != "unknown") {
    echo "<span class=box-desc>" . $port['ifDuplex'] . "</span>";
} else {
    echo "-";
}
if ($device['os'] == "ios" || $device['os'] == "iosxe") {
    if ($port['ifTrunk']) {
        echo '<p class=box-desc><span class=purple><a title="';
        $vlans = dbFetchRows("SELECT * FROM `ports_vlans` AS PV, vlans AS V WHERE PV.`port_id` ='" . $port['port_id'] . "' and PV.`device_id` = '" . $device['device_id'] . "' AND V.`vlan_vlan` = PV.vlan AND V.device_id = PV.device_id");
        foreach ($vlans as $vlan) {
            if ($vlan['state'] == "blocking") {
                $class = "red";
            } elseif ($vlan['state'] == "forwarding") {
开发者ID:REAP720801,项目名称:librenms,代码行数:31,代码来源:print-interface.inc.php


示例6: mysql_query

<?php

if (!isset($_GET['optb'])) {
    $_GET['optb'] = "graphs";
}
$interface_query = mysql_query("select * from ports WHERE interface_id = '" . $_GET['opta'] . "'");
$interface = mysql_fetch_array($interface_query);
$port_details = 1;
$hostname = $device['hostname'];
$hostid = $device['interface_id'];
$ifname = $interface['ifDescr'];
$ifIndex = $interface['ifIndex'];
$speed = humanspeed($interface['ifSpeed']);
$ifalias = $interface['name'];
if ($interface['ifPhysAddress']) {
    $mac = "{$interface['ifPhysAddress']}";
}
$color = "black";
if ($interface['ifAdminStatus'] == "down") {
    $status = "<span class='grey'>Disabled</span>";
}
if ($interface['ifAdminStatus'] == "up" && $interface['ifOperStatus'] == "down") {
    $status = "<span class='red'>Enabled / Disconnected</span>";
}
if ($interface['ifAdminStatus'] == "up" && $interface['ifOperStatus'] == "up") {
    $status = "<span class='green'>Enabled / Connected</span>";
}
$i = 1;
$inf = fixifName($ifname);
$bg = "#ffffff";
$show_all = 1;
开发者ID:kyrisu,项目名称:observernms,代码行数:31,代码来源:interface.inc.php


示例7: generateiflink

    $interface['graph_type'] = "port_upkts";
    echo generateiflink($interface, "<img src='graph.php?type=port_upkts&port=" . $interface['interface_id'] . "&from=" . $day . "&to=" . $now . "&width=100&height=20&legend=no&bg=" . str_replace("#", "", $row_colour) . "'>", $interface['graph_type']);
    $interface['graph_type'] = "port_errors";
    echo generateiflink($interface, "<img src='graph.php?type=port_errors&port=" . $interface['interface_id'] . "&from=" . $day . "&to=" . $now . "&width=100&height=20&legend=no&bg=" . str_replace("#", "", $row_colour) . "'>", $interface['graph_type']);
}
echo "</td><td width=120>";
if ($interface['ifOperStatus'] == "up") {
    $interface['in_rate'] = $interface['ifInOctets_rate'] * 8;
    $interface['out_rate'] = $interface['ifOutOctets_rate'] * 8;
    $in_perc = @round($interface['in_rate'] / $interface['ifSpeed'] * 100);
    $out_perc = @round($interface['in_rate'] / $interface['ifSpeed'] * 100);
    echo "<img src='images/16/arrow_left.png' align=absmiddle> <span style='color: " . percent_colour($in_perc) . "'>" . formatRates($interface['in_rate']) . "<br />\n          <img align=absmiddle src='images/16/arrow_out.png'> <span style='color: " . percent_colour($out_perc) . "'>" . formatRates($interface['out_rate']) . "<br />\n          <img src='images/icons/arrow_pps_in.png' align=absmiddle> " . format_bi($interface['ifInUcastPkts_rate']) . "pps</span><br />\n          <img src='images/icons/arrow_pps_out.png' align=absmiddle> " . format_bi($interface['ifOutUcastPkts_rate']) . "pps</span>";
}
echo "</td><td width=75>";
if ($interface['ifSpeed'] && $interface['ifAlias'] != "") {
    echo "<span class=box-desc>" . humanspeed($interface['ifSpeed']) . "</span>";
}
echo "<br />";
#  if($interface[ifDuplex] != unknown) { echo("<span class=box-desc>Duplex " . $interface['ifDuplex'] . "</span>"); } else { echo("-"); }
if ($device['os'] == "ios" || $device['os'] == "iosxe") {
    if ($interface['ifTrunk']) {
        echo "<span class=box-desc><span class=red>" . $interface['ifTrunk'] . "</span></span>";
    } elseif ($interface['ifVlan']) {
        echo "<span class=box-desc><span class=blue>VLAN " . $interface['ifVlan'] . "</span></span>";
    } elseif ($interface['ifVrf']) {
        $vrf = mysql_fetch_array(mysql_query("SELECT * FROM vrfs WHERE vrf_id = '" . $interface['ifVrf'] . "'"));
        echo "<span style='color: green;'>" . $vrf['vrf_name'] . "</span>";
    }
}
echo "</td><td width=150>";
if ($interface['ifType'] && $interface['ifType'] != "") {
开发者ID:kyrisu,项目名称:observernms,代码行数:31,代码来源:print-interface.inc.php


示例8: testHumanspeed

 /**
  * @dataProvider providerHumanspeed
  */
 public function testHumanspeed($value, $result)
 {
     $this->assertSame($result, humanspeed($value));
 }
开发者ID:skive,项目名称:observium,代码行数:7,代码来源:IncludesCommonTest.php


示例9: generate_port_link

    $port['graph_type'] = 'port_upkts';
    echo generate_port_link($port, "<img src='graph.php?type=port_upkts&amp;id=" . $port['port_id'] . '&amp;from=' . $config['time']['day'] . '&amp;to=' . $config['time']['now'] . '&amp;width=100&amp;height=20&amp;legend=no&amp;bg=' . str_replace('#', '', $row_colour) . "'>");
    $port['graph_type'] = 'port_errors';
    echo generate_port_link($port, "<img src='graph.php?type=port_errors&amp;id=" . $port['port_id'] . '&amp;from=' . $config['time']['day'] . '&amp;to=' . $config['time']['now'] . '&amp;width=100&amp;height=20&amp;legend=no&amp;bg=' . str_replace('#', '', $row_colour) . "'>");
}
echo "</td><td width=120 onclick=\"location.href='" . generate_port_url($port) . "'\" >";
if ($port['ifOperStatus'] == 'up') {
    $port['in_rate'] = $port['ifInOctets_rate'] * 8;
    $port['out_rate'] = $port['ifOutOctets_rate'] * 8;
    $in_perc = @round($port['in_rate'] / $port['ifSpeed'] * 100);
    $out_perc = @round($port['in_rate'] / $port['ifSpeed'] * 100);
    echo "<img src='images/16/arrow_left.png' align=absmiddle> <span style='color: " . percent_colour($in_perc) . "'>" . formatRates($port['in_rate']) . "<br />\n        <img align=absmiddle src='images/16/arrow_out.png'> <span style='color: " . percent_colour($out_perc) . "'>" . formatRates($port['out_rate']) . "<br />\n        <img src='images/icons/arrow_pps_in.png' align=absmiddle> " . format_bi($port['ifInUcastPkts_rate']) . "pps</span><br />\n        <img src='images/icons/arrow_pps_out.png' align=absmiddle> " . format_bi($port['ifOutUcastPkts_rate']) . 'pps</span>';
}
echo "</td><td width=75 onclick=\"location.href='" . generate_port_url($port) . "'\" >";
if ($port['ifSpeed']) {
    echo '<span class=box-desc>' . humanspeed($port['ifSpeed']) . '</span>';
}
echo '<br />';
if ($port[ifDuplex] != 'unknown') {
    echo '<span class=box-desc>' . $port['ifDuplex'] . '</span>';
} else {
    echo '-';
}
if ($device['os'] == 'ios' || $device['os'] == 'iosxe') {
    if ($port['ifTrunk']) {
        echo '<p class=box-desc><span class=purple><a title="';
        $vlans = dbFetchRows("SELECT * FROM `ports_vlans` AS PV, vlans AS V WHERE PV.`port_id` ='" . $port['port_id'] . "' and PV.`device_id` = '" . $device['device_id'] . "' AND V.`vlan_vlan` = PV.vlan AND V.device_id = PV.device_id");
        foreach ($vlans as $vlan) {
            if ($vlan['state'] == 'blocking') {
                $class = 'red';
            } elseif ($vlan['state'] == 'forwarding') {
开发者ID:Tatermen,项目名称:librenms,代码行数:31,代码来源:print-interface.inc.php


示例10: array

$query = "SELECT * FROM `ports` AS P, `devices` AS D WHERE P.device_id = D.device_id ";
$query .= "AND `ifPhysAddress` LIKE ?";
$param = array("%" . str_replace(array(':', ' ', '-', '.', '0x'), '', mres($_POST['address'])) . "%");
if (is_numeric($_POST['device_id'])) {
    $query .= " AND P.device_id = ?";
    $param[] = $_POST['device_id'];
}
if ($_POST['interface']) {
    $query .= " AND P.ifDescr LIKE ?";
    $param[] = $_POST['interface'];
}
$query .= " ORDER BY P.ifPhysAddress";
echo '<tr><th>Device</a></th><th>Interface</th><th>MAC Address</th><th>Description</th></tr>';
foreach (dbFetchRows($query, $param) as $entry) {
    if (!$ignore) {
        $speed = humanspeed($entry['ifSpeed']);
        $type = humanmedia($entry['ifType']);
        if ($entry['in_errors'] > 0 || $entry['out_errors'] > 0) {
            $error_img = generate_port_link($entry, "<img src='images/16/chart_curve_error.png' alt='Interface Errors' border=0>", errors);
        } else {
            $error_img = "";
        }
        if (port_permitted($entry['port_id'])) {
            $interface = ifLabel($interface, $interface);
            echo '<tr>
          <td>' . generate_device_link($entry) . '</td>
          <td>' . generate_port_link($entry, makeshortif(fixifname($entry['ifDescr']))) . ' ' . $error_img . '</td>
          <td>' . formatMac($entry['ifPhysAddress']) . '</td>
          <td>' . $entry['ifAlias'] . "</td>\n        </tr>\n";
        }
    }
开发者ID:CumulusNetworks,项目名称:cldemo-archive,代码行数:31,代码来源:mac.inc.php


示例11: humanize_port

function humanize_port(&$port)
{
    global $config, $cache;
    // Exit if already humanized
    if ($port['humanized']) {
        return;
    }
    // Process port data to make it pretty for printing. EVOLUTION, BITCHES.
    // Lots of hacky shit will end up here with if (os);
    // If we can get the device data from the global cache, do it, else pull it from the db (mostly for external scripts)
    if (is_array($GLOBALS['cache']['devices']['id'][$port['device_id']])) {
        $device =& $GLOBALS['cache']['devices']['id'][$port['device_id']];
    } else {
        $device = device_by_id_cache($port['device_id']);
    }
    $os = $device['os'];
    $port['human_speed'] = humanspeed($port['ifSpeed']);
    $port['human_type'] = rewrite_iftype($port['ifType']);
    $port['html_class'] = ifclass($port['ifOperStatus'], $port['ifAdminStatus']);
    $port['human_mac'] = format_mac($port['ifPhysAddress']);
    // Here definition override for ifDescr, because Calix switch ifDescr <> ifName since fw 2.2
    // Note, only for 'calix' os now
    if ($os == 'calix') {
        unset($config['os'][$os]['ifname']);
        $version_parts = explode('.', $device['version']);
        if ($version_parts[0] > 2 || $version_parts[0] == 2 && $version_parts[1] > 1) {
            $config['os'][$os]['ifname'] = 1;
        }
    }
    if (isset($config['os'][$os]['ifname'])) {
        if ($port['ifName'] == "") {
            $port['label'] = $port['ifDescr'];
        } else {
            $port['label'] = $port['ifName'];
        }
    } elseif (isset($config['os'][$os]['ifalias'])) {
        $port['label'] = $port['ifAlias'];
    } else {
        $port['label'] = $port['ifDescr'];
        if (isset($config['os'][$os]['ifindex'])) {
            $port['label'] .= ' ' . $port['ifIndex'];
        } else {
            $port['label'] = $port['ifDescr'];
        }
    }
    // Set entity variables for use by code which uses entities
    $port['entity_name'] = $port['label'];
    $port['entity_shortname'] = $port['label'];
    $port['entity_descr'] = $port['ifAlias'];
    if ($device['os'] == "speedtouch") {
        list($port['label']) = explode("thomson", $port['label']);
    }
    $port['table_tab_colour'] = "#aaaaaa";
    $port['row_class'] = "";
    // Default
    $port['admin_status'] = $port['ifAdminStatus'];
    if ($port['ifAdminStatus'] == "down") {
        $port['admin_status'] = 'disabled';
        $port['row_class'] = "warning";
        $port['icon'] = 'port-disabled';
    } elseif ($port['ifAdminStatus'] == "up") {
        $port['admin_status'] = 'enabled';
        switch ($port['ifOperStatus']) {
            case 'down':
                $port['table_tab_colour'] = "#cc0000";
                $port['row_class'] = "error";
                $port['icon'] = 'port-down';
                break;
            case 'monitoring':
                // This is monitoring ([e|r]span) ports
                $port['table_tab_colour'] = "#008C00";
                $port['row_class'] = "success";
                $port['icon'] = 'port-up';
                break;
            case 'lowerLayerDown':
                $port['table_tab_colour'] = "#ff6600";
                $port['row_class'] = "warning";
                $port['icon'] = 'port-down';
                break;
            case 'testing':
                $port['table_tab_colour'] = "#85004b";
                $port['row_class'] = "info";
                $port['icon'] = 'port-ignored';
                break;
            case 'up':
                $port['table_tab_colour'] = "#194B7F";
                $port['row_class'] = "";
                $port['icon'] = 'port-up';
                break;
        }
    }
    // If the device is down, colour the row/tab as 'warning' meaning that the entity is down because of something below it.
    if ($device['status'] == '0') {
        $port['table_tab_colour'] = "#ff6600";
        $port['row_class'] = "warning";
        $port['icon'] = 'port-ignored';
    }
    $port['in_rate'] = $port['ifInOctets_rate'] * 8;
    $port['out_rate'] = $port['ifOutOctets_rate'] * 8;
    // Colour in bps based on speed if > 50, else by UI convention.
//.........这里部分代码省略.........
开发者ID:skive,项目名称:observium,代码行数:101,代码来源:rewrites.inc.php


示例12: generate_port_row


//.........这里部分代码省略.........
            $port['graph_type'] = "port_bits";
            $graph_array = array();
            $graph_array['to'] = $config['time']['now'];
            $graph_array['id'] = $port['port_id'];
            $graph_array['type'] = $port['graph_type'];
            $graph_array['width'] = 100;
            $graph_array['height'] = 20;
            $graph_array['bg'] = 'ffffff00';
            $graph_array['from'] = $config['time']['day'];
            $string .= generate_port_link($port, generate_graph_tag($graph_array));
            $port['graph_type'] = "port_upkts";
            $graph_array['type'] = $port['graph_type'];
            $string .= generate_port_link($port, generate_graph_tag($graph_array));
            $port['graph_type'] = "port_errors";
            $graph_array['type'] = $port['graph_type'];
            $string .= generate_port_link($port, generate_graph_tag($graph_array));
            $string .= '</td>';
            $string .= '<td style="width: 100px; white-space: nowrap;">';
            if ($port['ifOperStatus'] == "up" || $port['ifOperStatus'] == "monitoring") {
                // Colours generated by humanize_port
                $string .= '<i class="icon-circle-arrow-down" style="' . $port['bps_in_style'] . '"></i> <span class="small" style="' . $port['bps_in_style'] . '">' . formatRates($port['in_rate']) . '</span><br />
      <i class="icon-circle-arrow-up"   style="' . $port['bps_out_style'] . '"></i> <span class="small" style="' . $port['bps_out_style'] . '">' . formatRates($port['out_rate']) . '</span><br />
      <i class="icon-circle-arrow-down" style="' . $port['pps_in_style'] . '"></i> <span class="small" style="' . $port['pps_in_style'] . '">' . format_bi($port['ifInUcastPkts_rate']) . 'pps</span><br />
      <i class="icon-circle-arrow-up"   style="' . $port['pps_out_style'] . '"></i> <span class="small" style="' . $port['pps_out_style'] . '">' . format_bi($port['ifOutUcastPkts_rate']) . 'pps</span>';
            }
            $string .= '</td><td style="width: 110px;">';
            if ($port['ifType'] && $port['ifType'] != "") {
                $string .= '<span class="small">' . $port['human_type'] . '</span>';
            } else {
                $string .= '-';
            }
            $string .= '<br />';
            if ($port['ifSpeed']) {
                $string .= '<span class="small">' . humanspeed($port['ifSpeed']) . '</span>';
            }
            if ($port['ifDuplex'] && $port['ifDuplex'] != "unknown") {
                $string .= '<span class="small"> (' . str_replace("Duplex", "", $port['ifDuplex']) . ')</span>';
            }
            $string .= '<br />';
            if ($port['ifMtu'] && $port['ifMtu'] != "") {
                $string .= '<span class="small">MTU ' . $port['ifMtu'] . '</span>';
            } else {
                $string .= '<span class="small">Unknown MTU</span>';
            }
            // if ($ifHardType && $ifHardType != "") { $string .= '<span class="small">" . $ifHardType . "</span>"); } else { $string .= '-'; }
            //$string .= '<br />';
            // Set VLAN data if the port has ifTrunk populated
            if ($port['ifTrunk']) {
                if ($port['ifVlan']) {
                    // Native VLAN
                    if (!isset($cache['ports_vlan'])) {
                        $native_state = dbFetchCell('SELECT `state` FROM `ports_vlans` WHERE `device_id` = ? AND `port_id` = ?', array($device['device_id'], $port['port_id']));
                        $native_name = dbFetchCell('SELECT `vlan_name` FROM vlans     WHERE `device_id` = ? AND `vlan_vlan` = ?;', array($device['device_id'], $port['ifVlan']));
                    } else {
                        $native_state = $cache['ports_vlan'][$port['port_id']][$port['ifVlan']]['state'];
                        $native_name = $cache['ports_vlan'][$port['port_id']][$port['ifVlan']]['vlan_name'];
                    }
                    switch ($native_state) {
                        case 'blocking':
                            $class = 'text-danger';
                            break;
                        case 'forwarding':
                            $class = 'text-success';
                            break;
                        default:
                            $class = 'muted';
开发者ID:Natolumin,项目名称:observium,代码行数:67,代码来源:port.inc.php


示例13: humanize_port

function humanize_port(&$port)
{
    global $config, $cache;
    // Exit if already humanized
    if ($port['humanized']) {
        return;
    }
    // If we can get the device data from the global cache, do it, else pull it from the db (mostly for external scripts)
    if (is_array($GLOBALS['cache']['devices']['id'][$port['device_id']])) {
        $device =& $GLOBALS['cache']['devices']['id'][$port['device_id']];
    } else {
        $device = device_by_id_cache($port['device_id']);
    }
    // Workaround for devices/ports who long time not updated and have empty port_label
    if (empty($port['port_label']) || strlen($port['port_label_base'] . $port['port_label_num']) == 0) {
        process_port_label($port, $device);
    }
    // Set humanised values for use in UI
    $port['human_speed'] = humanspeed($port['ifSpeed']);
    $port['human_type'] = rewrite_iftype($port['ifType']);
    $port['html_class'] = port_html_class($port['ifOperStatus'], $port['ifAdminStatus'], $port['encrypted']);
    $port['human_mac'] = format_mac($port['ifPhysAddress']);
    // Set entity_* values for code which expects them.
    $port['entity_name'] = $port['port_label'];
    $port['entity_shortname'] = $port['port_label_short'];
    $port['entity_descr'] = $port['ifAlias'];
    $port['table_tab_colour'] = "#aaaaaa";
    $port['row_class'] = "";
    $port['icon'] = 'port-ignored';
    // Default
    $port['admin_status'] = $port['ifAdminStatus'];
    if ($port['ifAdminStatus'] == "down") {
        $port['admin_status'] = 'disabled';
        $port['row_class'] = "disabled";
        $port['icon'] = 'port-disabled';
    } elseif ($port['ifAdminStatus'] == "up") {
        $port['admin_status'] = 'enabled';
        switch ($port['ifOperStatus']) {
            case 'up':
                $port['table_tab_colour'] = "#194B7F";
                $port['row_class'] = "up";
                $port['icon'] = 'port-up';
                break;
            case 'monitoring':
                // This is monitoring ([e|r]span) ports
                $port['table_tab_colour'] = "#008C00";
                $port['row_class'] = "success";
                $port['icon'] = 'port-up';
                break;
            case 'down':
                $port['table_tab_colour'] = "#cc0000";
                $port['row_class'] = "error";
                $port['icon'] = 'port-down';
                break;
            case 'lowerLayerDown':
                $port['table_tab_colour'] = "#ff6600";
                $port['row_class'] = "warning";
                $port['icon'] = 'port-down';
                break;
            case 'testing':
            case 'unknown':
            case 'dormant':
            case 'notPresent':
                $port['table_tab_colour'] = "#85004b";
                $port['row_class'] = "info";
                $port['icon'] = 'port-ignored';
                break;
        }
    }
    // If the device is down, colour the row/tab as 'warning' meaning that the entity is down because of something below it.
    if ($device['status'] == '0') {
        $port['table_tab_colour'] = "#ff6600";
        $port['row_class'] = "warning";
        $port['icon'] = 'port-ignored';
    }
    $port['in_rate'] = $port['ifInOctets_rate'] * 8;
    $port['out_rate'] = $port['ifOutOctets_rate'] * 8;
    // Colour in bps based on speed if > 50, else by UI convention.
    if ($port['ifSpeed'] > 0) {
        $in_perc = round($port['in_rate'] / $port['ifSpeed'] * 100);
        $out_perc = round($port['out_rate'] / $port['ifSpeed'] * 100);
    } else {
        // exclude division by zero error
        $in_perc = 0;
        $out_perc = 0;
    }
    if ($port['in_rate'] == 0) {
        $port['bps_in_style'] = '';
    } elseif ($in_perc < '50') {
        $port['bps_in_style'] = 'color: #008C00;';
    } else {
        $port['bps_in_style'] = 'color: ' . percent_colour($in_perc) . '; ';
    }
    // Colour out bps based on speed if > 50, else by UI convention.
    if ($port['out_rate'] == 0) {
        $port['bps_out_style'] = '';
    } elseif ($out_perc < '50') {
        $port['bps_out_style'] = 'color: #394182;';
    } else {
        $port['bps_out_style'] = 'color: ' . percent_colour($out_perc) . '; ';
//.........这里部分代码省略.........
开发者ID:Natolumin,项目名称:observium,代码行数:101,代码来源:rewrites.inc.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP hybrid_after_singular函数代码示例发布时间:2022-05-15
下一篇:
PHP humanize_port函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap