better front page

git-svn-id: http://www.observium.org/svn/observer/trunk@202 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2008-03-26 12:25:25 +00:00
parent b6a7054d28
commit 5072bfe353
8 changed files with 64 additions and 44 deletions

View File

@@ -20,3 +20,5 @@ RewriteRule ^device/([0-9]+) ?page=device&id=$1
RewriteRule ^([a-z]+)/$ ?page=$1
RewriteRule ^([a-z]+)/([a-z]+)/$ ?page=$1&view=$2

View File

@@ -12,8 +12,8 @@
$image = getImage($device['device_id']);
echo("
<tr bgcolor='$bg'>
echo(" <tr bgcolor='$bg' onmouseover=\"this.style.backgroundColor='#fdd';\" onmouseout=\"this.style.backgroundColor='$bg';\"
onclick=\"location.href='/device/".$device['device_id']."/'\" style='cursor: hand;'>
<td width='40' align=center valign=middle>$image</td>
<td width='300'><span style='font-weight: bold; font-size: 14px;'>" . generatedevicelink($device) . "</span>
<br />$device[purpose]</td>

View File

@@ -149,7 +149,7 @@ echo("
<!--[if IE 7]><!--></a><!--<![endif]-->
<table><tr><td>
<ul>
<li><a href='services/'><img src='images/16/link.png' border=0 align=absmiddle> All Sessions </a></li>
<li><a href='bgp/'><img src='images/16/link.png' border=0 align=absmiddle> All Sessions </a></li>
<li><hr width=140 /></li>
<li><a href='bgp/external/'><img src='images/16/world_link.png' border=0 align=absmiddle> External BGP</a></li>

View File

@@ -42,7 +42,7 @@ if($_GET['bill']) {
echo("
<tr bgcolor='$bg'>
<td width='7'></td>
<td width='250'><a href='/bills/".$bill['bill_id']."'><span style='font-weight: bold;' class=interface>".$bill['bill_name']."</span></a></td>
<td width='250'><a href='/bill/".$bill['bill_id']."'><span style='font-weight: bold;' class=interface>".$bill['bill_name']."</span></a></td>
<td>$notes</td>
<td>$type</td>
<td>$allowed</td>

View File

@@ -27,46 +27,53 @@ while($device = mysql_fetch_array($sql)){
$sql = mysql_query("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'");
while($device = mysql_fetch_array($sql)){
unset($already);
$i = 0;
while ($i <= count($nodes)) {
$thisnode = $device['device_id'];
if ($nodes[$i] == $thisnode) {
$already = "yes";
}
$i++;
}
if(!$already) { $nodes[] = $device['device_id']; }
echo("<div style='border: solid 2px #d0D0D0; float: left; padding: 5px; width: 120px; height: 90px; background: #ffbbbb; margin: 4px;'>
<center><strong>".generatedevicelink($device, shorthost($device['hostname']))."</strong><br />
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Device Down</span>
<span class=body-date-1>".truncate($device['location'], 20)."</span>
</center></div>");
}
$sql = mysql_query("SELECT * FROM `interfaces` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'");
while($device = mysql_fetch_array($sql)){
unset($already);
$i = 0;
while ($i <= count($nodes)) {
$thisnode = $device['device_id'];
if ($nodes[$i] == $thisnode) {
$already = "yes";
}
$i++;
}
if(!$already) { $nodes[] = $device['device_id']; }
while($interface = mysql_fetch_array($sql)){
echo("<div style='border: solid 2px #D0D0D0; float: left; padding: 5px; width: 120px; height: 90px; background: #ffddaa; margin: 4px;'>
<center><strong>".generatedevicelink($interface, shorthost($interface['hostname']))."</strong><br />
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Port Down</span>
<strong>".generateiflink($interface, makeshortif($interface['ifDescr']))."</strong> <br />
<span class=body-date-1>".truncate($interface['ifAlias'], 20)."</span>
</center></div>");
}
$sql = mysql_query("SELECT D.device_id FROM `services` AS S, `devices` AS D WHERE S.service_host = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'");
while($device = mysql_fetch_array($sql)){
unset($already);
$i = 0;
while ($i <= count($nodes)) {
$thisnode = $device['device_id'];
if ($nodes[$i] == $thisnode) {
$already = "yes";
}
$i++;
}
if(!$already) { $nodes[] = $device['device_id']; }
$sql = mysql_query("SELECT * FROM `services` AS S, `devices` AS D WHERE S.service_host = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'");
while($service = mysql_fetch_array($sql)){
echo("<div style='border: solid 2px #D0D0D0; float: left; padding: 5px; width: 120px; height: 90px; background: #ffddaa; margin: 4px;'>
<center><strong>".generatedevicelink($service, shorthost($service['hostname']))."</strong><br />
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Service Down</span>
<strong>".$service['service_type']."</strong><br />
<span class=body-date-1>".truncate($interface['ifAlias'], 20)."</span>
</center></div>");
}
$sql = mysql_query("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerState != 'established' AND B.device_id = D.device_id");
while($peer = mysql_fetch_array($sql)){
echo("<div style='border: solid 2px #d0D0D0; float: left; padding: 5px; width: 120px; height: 90px; background: #ffddaa; margin: 4px;'>
<center><strong>".generatedevicelink($peer, shorthost($peer['hostname']))."</strong><br />
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>BGP Down</span>
<strong>".$peer['bgpPeerIdentifier']."</strong> <br />
<span class=body-date-1>AS".$peer['bgpPeerRemoteAs']." ".truncate($peer['astext'], 10)."</span>
</center></div>");
}
foreach($nodes as $node) {
unset($srvpop);
@@ -126,8 +133,9 @@ foreach($nodes as $node) {
$device['device_id'] = $node;
$errorboxes .= "<div style='border: solid 2px #D0D0D0; float: left; padding: 5px; width: 120px; height: 75px; background: $background_color; margin: 4px;'>
<center><strong>".generatedevicelink($device, $shorthost)."</strong><br />";
$errorboxes .= "
<div style='border: solid 2px #D0D0D0; float: left; padding: 5px; width: 120px; height: 75px; background: $background_color; margin: 4px;'>
<center><strong>".generatedevicelink($device, $shorthost)."</strong><br />";
if(hoststatus($node)) {
$errorboxes .= " <span class=body-date-1>".formatuptime($uptime, short)."</span><br />";

View File

@@ -31,7 +31,7 @@
if (preg_match('/ng[0-9]+$/', $if)) { $nullintf = '1'; }
if ($nullintf == 0) {
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `interfaces` WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'"), 0) == '0') {
# mysql_query("INSERT INTO `interfaces` (`device_id`,`ifIndex`,`ifDescr`) VALUES ('$id','$ifIndex','$ifName')");
mysql_query("INSERT INTO `interfaces` (`device_id`,`ifIndex`,`ifDescr`) VALUES ('$id','$ifIndex','$ifName')");
echo("+");
} else {
# Interface Already Exists

View File

@@ -118,15 +118,25 @@ function devicepermitted($device_id) {
}
function formatRates($rate) {
$sizes = Array('bps', 'Kbps', 'Mbps', 'Gbps', 'Tbps', 'Pbps', 'Ebps');
$rate = format_si($rate) . "bps";
return $rate;
}
function formatstorage($rate) {
$rate = format_bi($rate) . "B";
return $rate;
}
function format_si($rate) {
$sizes = Array('', 'K', 'M', 'G', 'T', 'P', 'E');
$round = Array('0','0','0','2','2','2','2','2','2');
$ext = $sizes[0];
for ($i=1; (($i < count($sizes)) && ($rate >= 1000)); $i++) { $rate = $rate / 1000; $ext = $sizes[$i]; }
return round($rate, $round[$i]).$ext;
}
function formatStorage($size) {
$sizes = Array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB');
function format_bi($size) {
$sizes = Array('', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei');
$ext = $sizes[0];
for ($i=1; (($i < count($sizes)) && ($size >= 1024)); $i++) { $size = $size / 1024; $ext = $sizes[$i]; }
return round($size, 2).$ext;

View File

@@ -82,7 +82,7 @@ while ($interface = mysql_fetch_array($interface_query)) {
$update_query = "UPDATE `interfaces` SET ";
$update_query .= $update;
$update_query .= " WHERE `interface_id` = '" . $interface['interface_id'] . "'";
echo("Updating : " . $device['hostname'] . " $ifDescr\nSQL :$update_query\n\n");
# echo("Updating : " . $device['hostname'] . " $ifDescr\nSQL :$update_query\n\n");
$update_result = mysql_query($update_query);
} else {
# echo("Not Updating : " . $device['hostname'] ." $ifDescr ( " . $interface['ifDescr'] . " )\n\n");