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
This commit is contained in:
Adam Amstrong
2011-10-27 09:23:12 +00:00
parent 6a26a9ce39
commit 3fcf837511
5 changed files with 75 additions and 17 deletions
+1 -1
View File
@@ -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,
+1
View File
@@ -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;
+14 -5
View File
@@ -1,17 +1,19 @@
<?php
if(!$vars['view']) { $vars['view'] = "outgoing"; }
print_optionbar_start();
echo("<span style='font-weight: bold;'>Latency</span> &#187; ");
$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($);
}
}
}
+35 -8
View File
@@ -126,14 +126,28 @@ foreach ($ports as $data)
</td>
<td width=120>
<select name="sort" id="sort" style="width: 110px;">
<option value="">Host & Port Name</option>
<option value="traffic" <?php if ($vars['sort'] == "traffic") { echo("selected"); } ?>>Traffic</option>
<option value="traffic_in" <?php if ($vars['sort'] == "traffic_in") { echo("selected"); } ?>>Traffic In</option>
<option value="traffic_out" <?php if ($vars['sort'] == "traffic_out") { echo("selected"); } ?>>Traffic Out</option>
<option value="packets" <?php if ($vars['sort'] == "packets") { echo("selected"); } ?>>Packets</option>
<option value="packets_in" <?php if ($vars['sort'] == "packets_in") { echo("selected"); } ?>>Packets In</option>
<option value="packets_out" <?php if ($vars['sort'] == "packets_out") { echo("selected"); } ?>>Packets Out</option>
<option value="errors" <?php if ($vars['sort'] == "errors") { echo("selected"); } ?>>Errors</option>
<?php
$sorts = array('device' => 'Device',
'port' => 'Port',
'speed' => 'Speed',
'traffic' => 'Traffic',
'traffic_in' => 'Traffic In',
'traffic_out' => 'Traffic Out',
'packets' => 'Packets',
'packets_in' => 'Packets In',
'packets_out' => 'Packets Out',
'errors' => 'Errors',
'media' => 'Media',
'descr' => 'Description');
foreach ($sorts as $sort => $sort_text)
{
echo('<option value="'.$sort.'" ');
if ($vars['sort'] == $sort) { echo("selected"); }
echo('>'.$sort_text.'</option>');
}
?>
</select>
</td>
<td style="text-align: center;" width=50>
@@ -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";
}
+24 -3
View File
@@ -3,7 +3,26 @@
<?php
echo("<tr class=tablehead><td></td><th>Device</a></th><th>Interface</th><th>Speed</th><th>Down</th><th>Up</th><th>Media</th><th>Description</th></tr>");
echo("<tr class=tablehead><td></td>");
$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('<th>'.$col.' *</th>');
} else {
echo('<th><a href="'. generate_url($vars, array('sort' => $sort)).'">'.$col.'</a></th>');
}
}
echo(" </tr>");
$row = 1;
@@ -51,9 +70,11 @@ foreach ($ports as $port)
}
}
echo("</table>");
echo("Ports: $ports_total ( Up $ports_up | Down $ports_down | Disabled $ports_disabled )");
echo("<tr><td colspan=7>");
echo("<strong>Matched Ports: $ports_total ( <span class=green>Up $ports_up</span> | <span class=red>Down $ports_down</span> | Disabled $ports_disabled )</strong>");
echo("</td></tr>");
echo('</table>');
?>