From 5072bfe3538d7329ed7f59ac5c01392cbbf8157b Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Wed, 26 Mar 2008 12:25:25 +0000 Subject: [PATCH] better front page git-svn-id: http://www.observium.org/svn/observer/trunk@202 61d68cd4-352d-0410-923a-c4978735b2b8 --- html/.htaccess | 2 + html/includes/hostbox.inc | 4 +- html/includes/print-menubar.php | 2 +- html/pages/bills.php | 2 +- html/pages/default.php | 78 ++++++++++++++++------------- includes/discovery/interfaces.php | 2 +- includes/functions.php | 16 ++++-- includes/polling/interfaces.inc.php | 2 +- 8 files changed, 64 insertions(+), 44 deletions(-) diff --git a/html/.htaccess b/html/.htaccess index cc382a664..994950273 100644 --- a/html/.htaccess +++ b/html/.htaccess @@ -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 + diff --git a/html/includes/hostbox.inc b/html/includes/hostbox.inc index 6a752843a..47eddd51c 100644 --- a/html/includes/hostbox.inc +++ b/html/includes/hostbox.inc @@ -12,8 +12,8 @@ $image = getImage($device['device_id']); - echo(" - + echo(" $image " . generatedevicelink($device) . "
$device[purpose] diff --git a/html/includes/print-menubar.php b/html/includes/print-menubar.php index fa13ff2c3..fca04b3a8 100644 --- a/html/includes/print-menubar.php +++ b/html/includes/print-menubar.php @@ -149,7 +149,7 @@ echo(" - + diff --git a/html/pages/default.php b/html/pages/default.php index fa7c44bd1..e0cd80796 100644 --- a/html/pages/default.php +++ b/html/pages/default.php @@ -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("
+
".generatedevicelink($device, shorthost($device['hostname']))."
+ Device Down + ".truncate($device['location'], 20)." +
"); + } $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("
+
".generatedevicelink($interface, shorthost($interface['hostname']))."
+ Port Down + ".generateiflink($interface, makeshortif($interface['ifDescr']))."
+ ".truncate($interface['ifAlias'], 20)." +
"); + } -$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("
+
".generatedevicelink($service, shorthost($service['hostname']))."
+ Service Down + ".$service['service_type']."
+ ".truncate($interface['ifAlias'], 20)." +
"); + } +$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("
+
".generatedevicelink($peer, shorthost($peer['hostname']))."
+ BGP Down + ".$peer['bgpPeerIdentifier']."
+ AS".$peer['bgpPeerRemoteAs']." ".truncate($peer['astext'], 10)." +
"); + +} + + + foreach($nodes as $node) { unset($srvpop); @@ -126,8 +133,9 @@ foreach($nodes as $node) { $device['device_id'] = $node; - $errorboxes .= "
-
".generatedevicelink($device, $shorthost)."
"; + $errorboxes .= " +
+
".generatedevicelink($device, $shorthost)."
"; if(hoststatus($node)) { $errorboxes .= " ".formatuptime($uptime, short)."
"; diff --git a/includes/discovery/interfaces.php b/includes/discovery/interfaces.php index 5708b888a..24da15bae 100755 --- a/includes/discovery/interfaces.php +++ b/includes/discovery/interfaces.php @@ -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 diff --git a/includes/functions.php b/includes/functions.php index ab8274dc7..977616903 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -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; diff --git a/includes/polling/interfaces.inc.php b/includes/polling/interfaces.inc.php index 3422ca93b..2f277713c 100644 --- a/includes/polling/interfaces.inc.php +++ b/includes/polling/interfaces.inc.php @@ -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");
    -
  • All Sessions
  • +
  • All Sessions

  • External BGP
  • diff --git a/html/pages/bills.php b/html/pages/bills.php index f1584e6dc..22ff69432 100644 --- a/html/pages/bills.php +++ b/html/pages/bills.php @@ -42,7 +42,7 @@ if($_GET['bill']) { echo("
".$bill['bill_name']."".$bill['bill_name']." $notes $type $allowed