Exemplo n.º 1
0
/**
 * 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.
}
Exemplo n.º 2
0
}
if ($port_adsl['adslLineCoding']) {
    echo "</td><td width=150>";
    echo $port_adsl['adslLineCoding'] . "/" . rewrite_adslLineType($port_adsl['adslLineType']);
    echo "<br />";
    echo "Sync:" . formatRates($port_adsl['adslAtucChanCurrTxRate']) . "/" . formatRates($port_adsl['adslAturChanCurrTxRate']);
    echo "<br />";
    echo "Max:" . formatRates($port_adsl['adslAtucCurrAttainableRate']) . "/" . formatRates($port_adsl['adslAturCurrAttainableRate']);
    echo "</td><td width=150>";
    echo "Atten:" . $port_adsl['adslAtucCurrAtn'] . "dB/" . $port_adsl['adslAturCurrAtn'] . "dB";
    echo "<br />";
    echo "SNR:" . $port_adsl['adslAtucCurrSnrMgn'] . "dB/" . $port_adsl['adslAturCurrSnrMgn'] . "dB";
} else {
    echo "</td><td width=150>";
    if ($port['ifType'] && $port['ifType'] != "") {
        echo "<span class=box-desc>" . fixiftype($port['ifType']) . "</span>";
    } else {
        echo "-";
    }
    echo "<br />";
    if ($ifHardType && $ifHardType != "") {
        echo "<span class=box-desc>" . $ifHardType . "</span>";
    } else {
        echo "-";
    }
    echo "</td><td width=150>";
    if ($port['ifPhysAddress'] && $port['ifPhysAddress'] != "") {
        echo "<span class=box-desc>" . formatMac($port['ifPhysAddress']) . "</span>";
    } else {
        echo "-";
    }
Exemplo n.º 3
0
//end if
if ($port_adsl['adslLineCoding']) {
    echo "</td><td width=150 onclick=\"location.href='" . generate_port_url($port) . "'\" >";
    echo $port_adsl['adslLineCoding'] . '/' . rewrite_adslLineType($port_adsl['adslLineType']);
    echo '<br />';
    echo 'Sync:' . formatRates($port_adsl['adslAtucChanCurrTxRate']) . '/' . formatRates($port_adsl['adslAturChanCurrTxRate']);
    echo '<br />';
    echo 'Max:' . formatRates($port_adsl['adslAtucCurrAttainableRate']) . '/' . formatRates($port_adsl['adslAturCurrAttainableRate']);
    echo "</td><td width=150 onclick=\"location.href='" . generate_port_url($port) . "'\" >";
    echo 'Atten:' . $port_adsl['adslAtucCurrAtn'] . 'dB/' . $port_adsl['adslAturCurrAtn'] . 'dB';
    echo '<br />';
    echo 'SNR:' . $port_adsl['adslAtucCurrSnrMgn'] . 'dB/' . $port_adsl['adslAturCurrSnrMgn'] . 'dB';
} else {
    echo "</td><td width=150 onclick=\"location.href='" . generate_port_url($port) . "'\" >";
    if ($port['ifType'] && $port['ifType'] != '') {
        echo '<span class=box-desc>' . fixiftype($port['ifType']) . '</span>';
    } else {
        echo '-';
    }
    echo '<br />';
    if ($ifHardType && $ifHardType != '') {
        echo '<span class=box-desc>' . $ifHardType . '</span>';
    } else {
        echo '-';
    }
    echo "</td><td width=150 onclick=\"location.href='" . generate_port_url($port) . "'\" >";
    if ($port['ifPhysAddress'] && $port['ifPhysAddress'] != '') {
        echo '<span class=box-desc>' . formatMac($port['ifPhysAddress']) . '</span>';
    } else {
        echo '-';
    }
Exemplo n.º 4
0
}
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'] != "") {
    echo "<span class=box-desc>" . fixiftype($interface['ifType']) . "</span>";
} else {
    echo "-";
}
echo "<br />";
if ($ifHardType && $ifHardType != "") {
    echo "<span class=box-desc>" . $ifHardType . "</span>";
} else {
    echo "-";
}
echo "</td><td width=150>";
if ($interface['ifPhysAddress'] && $interface['ifPhysAddress'] != "") {
    echo "<span class=box-desc>" . $interface['ifPhysAddress'] . "</span>";
} else {
    echo "-";
}
Exemplo n.º 5
0
    $('#form-reset').click(function(event) {
        // reset objects in the form to their previous values
        event.preventDefault();
        $('#ignoreport')[0].reset();
    });
});
</script>

<?php 
foreach (dbFetchRows("SELECT * FROM `ports` WHERE `device_id` = ? ORDER BY `ifIndex` ", array($device['device_id'])) as $port) {
    humanize_port($port);
    echo "<tr>";
    echo "<td align=center>" . $port['ifIndex'] . "</td>";
    echo "<td align=left>" . $port['label'] . "<br />" . $port['ifAlias'] . "</td>";
    $enabled = $port['ifAdminStatus'] == 'up' ? " class='green'" : "";
    echo "<td align=left>" . fixiftype($port['ifType']) . "<br />";
    # Mark interfaces which are OperDown (but not AdminDown) yet not ignored or disabled, or up yet ignored or disabled
    # - as to draw the attention to a possible problem.
    $isportbad = $port['ifOperStatus'] != 'up' && $port['ifAdminStatus'] != 'down' ? 1 : 0;
    $dowecare = $port['ignore'] == 0 && $port['disabled'] == 0 ? $isportbad : !$isportbad;
    $outofsync = $dowecare ? " class='red'" : " class='green'";
    echo "<span {$enabled}>" . $port['ifAdminStatus'] . "</span> / <span name='operstatus_" . $port['port_id'] . "'" . $outofsync . ">" . $port['ifOperStatus'] . "</span></td>";
    echo '<td align=center style="vertical-align: middle;">';
    echo "<div id='disabled_" . $port['port_id'] . "' class='switch switch-mini' data-on='danger' data-off='primary' data-on-label='No' data-off-label='Yes'><input type=checkbox name='disabled_" . $port['port_id'] . "'" . ($port['disabled'] ? 'checked' : '') . "></div>";
    echo "<input type=hidden name='olddis_" . $port['port_id'] . "' value=" . ($port['disabled'] ? 1 : 0) . ">";
    echo "</td>";
    echo '<td align=center style="vertical-align: middle;">';
    echo "<div id='ignore_" . $port['port_id'] . "' class='switch switch-mini' data-on='danger' data-off='primary' data-on-label='No' data-off-label='Yes'><input type=checkbox name='ignore_" . $port['port_id'] . "'" . ($port['ignore'] ? 'checked' : '') . "></div>";
    echo "<input type=hidden name='oldign_" . $port['port_id'] . "' value=" . ($port['ignore'] ? 1 : 0) . ">";
    echo "</td>";
    ?>