From daa24154d44af2311db6e6c6a1395807424b4b8f Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Mon, 19 Sep 2011 11:15:01 +0000 Subject: [PATCH] update ports page and some other things git-svn-id: http://www.observium.org/svn/observer/trunk@2506 61d68cd4-352d-0410-923a-c4978735b2b8 --- html/css/styles.css | 3 + html/includes/print-menubar.php | 56 +++++----- html/index.php | 8 ++ html/pages/ports.inc.php | 188 ++++++++++++++++++++------------ html/pages/ports/graph.inc.php | 26 ++--- html/pages/ports/list.inc.php | 28 ++--- html/pages/search.inc.php | 13 ++- 7 files changed, 189 insertions(+), 133 deletions(-) diff --git a/html/css/styles.css b/html/css/styles.css index b5f71369b5..3e1f837fb1 100644 --- a/html/css/styles.css +++ b/html/css/styles.css @@ -1256,3 +1256,6 @@ a.interface-upup:hover, a.interface-updown:hover, a.interface-admindown:hover { } +.auto-hint { + color:#AAAAAA; +} diff --git a/html/includes/print-menubar.php b/html/includes/print-menubar.php index 13cd91cb0c..51b392a854 100644 --- a/html/includes/print-menubar.php +++ b/html/includes/print-menubar.php @@ -30,35 +30,33 @@ foreach (dbFetchRows("SELECT * FROM `devices`") as $device) } ?> - +
diff --git a/html/index.php b/html/index.php index 4e80ab537a..837d5fd14f 100755 --- a/html/index.php +++ b/html/index.php @@ -303,6 +303,14 @@ echo(''); diff --git a/html/pages/ports.inc.php b/html/pages/ports.inc.php index 447a3cdf18..053c1991d0 100644 --- a/html/pages/ports.inc.php +++ b/html/pages/ports.inc.php @@ -14,7 +14,7 @@ if($vars['searchbar'] != "hide")
- +
+ /> - - @@ -42,10 +44,9 @@ foreach (dbFetchRows("SELECT `device_id`,`hostname` FROM `devices` GROUP BY `hos - +
- - - -
- + + + + + /> + - - - - Deleted > - - - - - Update URL
- Reset - + + +
+ +
+ + + + +
+ Reset + +
@@ -162,7 +191,11 @@ foreach ($menu_options as $option => $text) } echo('
'); +?> + Update URL | + + '')).'">Search'); @@ -193,60 +226,75 @@ print_optionbar_end(); $param = array(); + + # FIXME block below is not totally used, at least the iftype stuff is bogus? -if ($_GET['opta'] == "down" || $_GET['type'] == "down" || $vars['state'] == "down") -{ - $where .= "AND I.ifAdminStatus = 'up' AND I.ifOperStatus = 'down' AND I.ignore = '0'"; -} elseif ($_GET['optb'] == "admindown" || $_GET['type'] == "admindown" || $vars['state'] == "admindown") { - $where .= "AND I.ifAdminStatus = 'down'"; -} elseif ($_GET['optb'] == "errors" || $_GET['type'] == "errors" || $vars['state'] == "errors") { - $where .= "AND (I.`ifInErrors_delta` > '0' OR I.`ifOutErrors_delta` > '0')"; -} elseif ($_GET['type'] == "up" || $vars['state'] == "up") { - $where .= "AND I.ifOperStatus = 'up'"; -} elseif ($_GET['optb'] == "ignored" || $_GET['type'] == "ignored" || $vars['state'] == "ignored") { - $where .= "AND I.ignore = '1'"; -} elseif ($_GET['type'] == "l2vlan" || $vars['state'] == "l2vlan") { - $where .= " AND I.ifType = 'l2vlan'"; -} elseif ($_GET['type'] == "ethernet" || $vars['state'] == "ethernet") { - $where .= " AND I.ifType = 'ethernetCsmacd'"; -} elseif ($_GET['type'] == "loopback" || $vars['state'] == "loopback") { - $where .= " AND I.ifType = 'softwareLoopback'"; -} elseif ($_GET['type'] == "sonet" || $vars['state'] == "sonet") { - $where .= " AND I.ifType = 'sonet'"; -} elseif ($vars['state'] == "propvirtual") { - $where .= " AND I.ifType = 'propVirtual'"; -} elseif ($vars['state'] == "ppp") { - $where .= " AND I.ifType = 'ppp'"; -} +#if ($vars['status'] == "down" || $_GET['type'] == "down" || $vars['state'] == "down") +#{ +# $where .= "AND I.ifAdminStatus = 'up' AND I.ifOperStatus = 'down' AND I.ignore = '0'"; +#} +#if ($_GET['optb'] == "admindown" || $_GET['type'] == "admindown" || $vars['state'] == "admindown") { +# $where .= "AND I.ifAdminStatus = 'down'"; +#} +#if ($_GET['optb'] == "errors" || $_GET['type'] == "errors" || $vars['state'] == "errors") { +# $where .= "AND (I.`ifInErrors_delta` > '0' OR I.`ifOutErrors_delta` > '0')"; +#} +#if ($vars['state'] == "up") { +# $where .= "AND I.ifOperStatus = 'up'"; +#} +if(!isset($vars['ignore'])) { $vars['ignore'] = "0"; } +if(!isset($vars['disabled'])) { $vars['disabled'] = "0"; } +if(!isset($vars['deleted'])) { $vars['deleted'] = "0"; } -if (is_numeric($vars['device_id'])) -{ - $where .= " AND I.device_id = ?"; - $param[] = $vars['device_id']; -} -if ($vars['ifType']) +foreach($vars as $var => $value) { - $where .= " AND I.ifType = ?"; - $param[] = $vars['ifType']; + if($value != "") + { + switch ($var) + { + case 'hostname': + case 'location': + $where .= " AND D.$var LIKE ?"; + $param[] = "%".$value."%"; + case 'device_id': + case 'deleted': + case 'ignore': + case 'disable': + case 'ifSpeed': + if (is_numeric($value)) + { + $where .= " AND I.$var = ?"; + $param[] = $value; + } + break; + case 'ifType': + $where .= " AND I.$var = ?"; + $param[] = $value; + break; + case 'ifAlias': + case 'port_descr_type': + $where .= " AND I.$var LIKE ?"; + $param[] = "%".$value."%"; + break; + case 'state': + if ($value == "down") + { + $where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ?"; + $param[] = "up"; + $param[] = "down"; + } elseif($value == "up") { + $where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ?"; + $param[] = "up"; + $param[] = "up"; + } elseif($value == "admindown") { + $where .= "AND I.ifAdminStatus = ?"; + $param[] = "down"; + } + break; + } + } } -if ($vars['port_descr_type']) -{ - $where .= " AND I.port_descr_type = ?"; - $param[] = $vars['port_descr_type']; -} -if (is_numeric($vars['ifSpeed'])) -{ - $where .= " AND I.ifSpeed = ?"; - $param[] = $vars['ifSpeed']; -} - -if ($vars['ifAlias']) { - $where .= " AND I.ifAlias LIKE ?"; - $param[] = "%".$vars['ifAlias']."%"; -} - -if ($vars['deleted'] || $_GET['type'] == "deleted") { $where .= " AND I.deleted = '1'"; } $query = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id ".$where." ORDER BY D.hostname, I.ifIndex"; @@ -254,6 +302,8 @@ $row = 1; list($format, $subformat) = explode("_", $vars['format']); +$ports = dbFetchRows($query, $param); + if(file_exists('pages/ports/'.$format.'.inc.php')) { include('pages/ports/'.$format.'.inc.php'); diff --git a/html/pages/ports/graph.inc.php b/html/pages/ports/graph.inc.php index d1c23ac994..6d85fd99d8 100644 --- a/html/pages/ports/graph.inc.php +++ b/html/pages/ports/graph.inc.php @@ -1,32 +1,32 @@ 0 || $interface['out_errors'] > 0) + if ($port['in_errors'] > 0 || $port['out_errors'] > 0) { - $error_img = generate_port_link($interface,"Interface Errors",errors); + $error_img = generate_port_link($port,"Interface Errors",errors); } else { $error_img = ""; } - if (port_permitted($interface['interface_id'], $interface['device_id'])) + if (port_permitted($port['interface_id'], $port['device_id'])) { - $interface = ifLabel($interface, $device); + $port = ifLabel($port, $device); $graph_type = "port_" . $subformat; echo("
- ".$device['hostname']." - ".$interface['ifDescr']."
\ - \ + ".$device['hostname']." - ".$port['ifDescr']."
\ + \ ', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >". - " + " "); } diff --git a/html/pages/ports/list.inc.php b/html/pages/ports/list.inc.php index 00984036d4..8079a5f52a 100644 --- a/html/pages/ports/list.inc.php +++ b/html/pages/ports/list.inc.php @@ -7,35 +7,35 @@ echo("DeviceInterfaceSpee $row = 1; -foreach (dbFetchRows($query, $param) as $interface) +foreach ($ports as $port) { - if (port_permitted($interface['interface_id'], $interface['device_id'])) + if (port_permitted($port['interface_id'], $port['device_id'])) { if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } - $speed = humanspeed($interface['ifSpeed']); - $type = humanmedia($interface['ifType']); + $speed = humanspeed($port['ifSpeed']); + $type = humanmedia($port['ifType']); - if ($interface['in_errors'] > 0 || $interface['out_errors'] > 0) + if ($port['in_errors'] > 0 || $port['out_errors'] > 0) { - $error_img = generate_port_link($interface,"Interface Errors",errors); + $error_img = generate_port_link($port,"Interface Errors",errors); } else { $error_img = ""; } - $interface['in_rate'] = formatRates($interface['ifInOctets_rate'] * 8); - $interface['out_rate'] = formatRates($interface['ifOutOctets_rate'] * 8); + $port['in_rate'] = formatRates($port['ifInOctets_rate'] * 8); + $port['out_rate'] = formatRates($port['ifOutOctets_rate'] * 8); - $interface = ifLabel($interface, $device); + $port = ifLabel($port, $device); echo(" - ".$interface['hostname']." - ".fixIfName($interface['label'])." $error_img + ".$port['hostname']." + ".fixIfName($port['label'])." $error_img $speed - ".$interface['in_rate']." - ".$interface['out_rate']." + ".$port['in_rate']." + ".$port['out_rate']." $type - " . $interface['ifAlias'] . " + " . $port['ifAlias'] . " \n"); $row++; diff --git a/html/pages/search.inc.php b/html/pages/search.inc.php index 8fe1cb9ffe..a3a373a4f5 100644 --- a/html/pages/search.inc.php +++ b/html/pages/search.inc.php @@ -2,7 +2,7 @@ $sections = array('ipv4' => 'IPv4 Address', 'ipv6' => 'IPv6 Address', 'mac' => 'MAC Address'); -if (!$_GET['opta']) { $_GET['opta'] = "ipv4"; } +if (!isset($vars['search'])) { $vars['search'] = "ipv4"; } print_optionbar_start('', ''); @@ -12,14 +12,15 @@ unset($sep); foreach ($sections as $type => $texttype) { echo($sep); - if ($_GET['opta'] == $type) + if ($vars['search'] == $type) { echo(""); } - echo('' . $texttype .''); +# echo('' . $texttype .''); + echo(generate_link($texttype, array('page'=>'search','search'=>$type))); - if ($_GET['opta'] == $type) { echo(""); } + if ($vars['search'] == $type) { echo(""); } $sep = ' | '; } @@ -27,12 +28,12 @@ unset ($sep); print_optionbar_end('', ''); -switch ($_GET['opta']) +switch ($vars['search']) { case 'ipv4': case 'ipv6': case 'mac': - include('pages/search/'.$_GET['opta'].'.inc.php'); + include('pages/search/'.$vars['search'].'.inc.php'); break; default: echo("

Error. Please report this to observium developers.

");