From 3fcf8375111472e84bf098f7f624b1437182ce6a Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Thu, 27 Oct 2011 09:23:12 +0000 Subject: [PATCH] turn ifSpeed into bigint(20). add more sort options to /ports/ git-svn-id: http://www.observium.org/svn/observer/trunk@2702 61d68cd4-352d-0410-923a-c4978735b2b8 --- database-schema.sql | 2 +- database-update.sql | 1 + html/pages/device/latency.inc.php | 19 ++++++++++---- html/pages/ports.inc.php | 43 +++++++++++++++++++++++++------ html/pages/ports/list.inc.php | 27 ++++++++++++++++--- 5 files changed, 75 insertions(+), 17 deletions(-) diff --git a/database-schema.sql b/database-schema.sql index 6bfb8ae527..f2f94178a5 100644 --- a/database-schema.sql +++ b/database-schema.sql @@ -713,7 +713,7 @@ CREATE TABLE IF NOT EXISTS `ports` ( `ifName` varchar(64) DEFAULT NULL, `portName` varchar(128) DEFAULT NULL, `ifIndex` int(11) DEFAULT '0', - `ifSpeed` text, + `ifSpeed` bigint(20) DEFAULT NULL, `ifConnectorPresent` varchar(12) DEFAULT NULL, `ifPromiscuousMode` varchar(12) DEFAULT NULL, `ifHighSpeed` int(11) DEFAULT NULL, diff --git a/database-update.sql b/database-update.sql index b0bf92f1e1..89820c3449 100644 --- a/database-update.sql +++ b/database-update.sql @@ -7,3 +7,4 @@ ALTER TABLE `devices` CHANGE `port` `port` SMALLINT( 5 ) UNSIGNED NOT NULL DEF CREATE TABLE IF NOT EXISTS `ipsec_tunnels` ( `tunnel_id` int(11) NOT NULL AUTO_INCREMENT, `device_id` int(11) NOT NULL, `peer_port` int(11) NOT NULL, `peer_addr` varchar(64) COLLATE utf8_unicode_ci NOT NULL, `local_addr` varchar(64) COLLATE utf8_unicode_ci NOT NULL, `local_port` int(11) NOT NULL, `tunnel_name` varchar(96) COLLATE utf8_unicode_ci NOT NULL, `tunnel_status` varchar(11) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`tunnel_id`), UNIQUE KEY `unique_index` (`device_id`,`peer_addr`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; ALTER TABLE `syslog` ADD INDEX ( `program` ); ALTER TABLE `devices` ADD `sysObjectID` VARCHAR( 64 ) NULL DEFAULT NULL AFTER `bgpLocalAs`; +ALTER TABLE `ports` CHANGE `ifSpeed` `ifSpeed` BIGINT NULL DEFAULT NULL; diff --git a/html/pages/device/latency.inc.php b/html/pages/device/latency.inc.php index d2d93e12c3..bc653b40fa 100644 --- a/html/pages/device/latency.inc.php +++ b/html/pages/device/latency.inc.php @@ -1,17 +1,19 @@ Latency » "); -$menu_options = array('incoming' => 'Incoming', - 'outgoing' => 'Outgoing'); +if(count($smokeping_files['in'][$device['hostname']])) + $menu_options['incoming'] = 'Incoming'; + +if(count($smokeping_files['out'][$device['hostname']])) + $menu_options['outgoing'] = 'Outgoing'; $sep = ""; foreach ($menu_options as $option => $text) { + if(!$vars['view']) { $vars['view'] = $option; } echo($sep); if ($vars['view'] == $option) { @@ -29,6 +31,7 @@ unset($sep); print_optionbar_end(); + if($vars['view'] == "incoming") { @@ -42,7 +45,7 @@ if($vars['view'] == "incoming") } -} else { +} elseif ($vars['view'] == "outgoing") { if (count($smokeping_files['out'][$device['hostname']])) { @@ -52,6 +55,12 @@ if($vars['view'] == "incoming") include("includes/print-quadgraphs.inc.php"); + + foreach($smokeping_files['out'][$device['hostname']] AS $host) + { + print_r($); + } + } } diff --git a/html/pages/ports.inc.php b/html/pages/ports.inc.php index 86a544cefe..62bc7b8fb2 100644 --- a/html/pages/ports.inc.php +++ b/html/pages/ports.inc.php @@ -126,14 +126,28 @@ foreach ($ports as $data) @@ -322,6 +336,19 @@ switch ($vars['sort']) case 'errors': $query_sort = " ORDER BY (I.ifInErrors + I.ifOutErrors) DESC"; break; + case 'speed': + $query_sort = " ORDER BY (I.ifSpeed) DESC"; + break; + case 'port': + $query_sort = " ORDER BY (I.ifDescr) ASC"; + break; + case 'media': + $query_sort = " ORDER BY (I.ifType) ASC"; + break; + case 'descr': + $query_sort = " ORDER BY (I.ifAlias) ASC"; + break; + case 'device': default: $query_sort = " ORDER BY D.hostname, I.ifIndex ASC"; } diff --git a/html/pages/ports/list.inc.php b/html/pages/ports/list.inc.php index 899970d755..bc8368e081 100644 --- a/html/pages/ports/list.inc.php +++ b/html/pages/ports/list.inc.php @@ -3,7 +3,26 @@ DeviceInterfaceSpeedDownUpMediaDescription"); +echo(""); + +$cols = array('device' => 'Device', + 'port' => 'Port', + 'speed' => 'Speed', + 'traffic_in' => 'Down', + 'traffic_out' => 'Up', + 'media' => 'Media', + 'descr' => 'Description' ); + +foreach ($cols as $sort => $col) +{ + if($vars['sort'] == $sort) { + echo(''.$col.' *'); + } else { + echo(''.$col.''); + } +} + +echo(" "); $row = 1; @@ -51,9 +70,11 @@ foreach ($ports as $port) } } -echo(""); -echo("Ports: $ports_total ( Up $ports_up | Down $ports_down | Disabled $ports_disabled )"); +echo(""); +echo("Matched Ports: $ports_total ( Up $ports_up | Down $ports_down | Disabled $ports_disabled )"); +echo(""); +echo(''); ?>