many lovely GUI changes.

git-svn-id: http://www.observium.org/svn/observer/trunk@2454 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong 2011-09-14 13:38:01 +00:00
parent ef143ece1b
commit e9f14f8f85
19 changed files with 743 additions and 158 deletions

View File

@ -1,19 +1,6 @@
Options FollowSymlinks Multiviews
RewriteBase /
RewriteEngine on
RewriteCond %{REQUEST_URI} !^(.*)\.php$
RewriteCond %{REQUEST_URI} !^(.*)\.css$
RewriteCond %{REQUEST_URI} !^(.*)\.jpg$
RewriteCond %{REQUEST_URI} !^(.*)\.gif$
RewriteCond %{REQUEST_URI} !^(.*)\.png$
RewriteRule ^([a-z|0-9]+)/(.+)/(.+)/(.+)/(.+)/(.+)/(.+)/(.+)/(.+)/$ ?page=$1&opta=$2&optb=$3&optc=$4&optd=$5&opte=$6&optf=$7&optg=$8&opth=$9
RewriteRule ^([a-z|0-9]+)/(.+)/(.+)/(.+)/(.+)/(.+)/(.+)/(.+)/$ ?page=$1&opta=$2&optb=$3&optc=$4&optd=$5&opte=$6&optf=$7&optg=$8
RewriteRule ^([a-z|0-9]+)/(.+)/(.+)/(.+)/(.+)/(.+)/(.+)/$ ?page=$1&opta=$2&optb=$3&optc=$4&optd=$5&opte=$6&optf=$7
RewriteRule ^([a-z|0-9]+)/(.+)/(.+)/(.+)/(.+)/(.+)/$ ?page=$1&opta=$2&optb=$3&optc=$4&optd=$5&opte=$6
RewriteRule ^([a-z|0-9]+)/(.+)/(.+)/(.+)/(.+)/$ ?page=$1&opta=$2&optb=$3&optc=$4&optd=$5
RewriteRule ^([a-z|0-9]+)/(.+)/(.+)/(.+)/$ ?page=$1&opta=$2&optb=$3&optc=$4
RewriteRule ^([a-z|0-9]+)/(.+)/(.+)/$ ?page=$1&opta=$2&optb=$3
RewriteRule ^([a-z|0-9]+)/(.+)/$ ?page=$1&opta=$2
RewriteRule ^([a-z|0-9]+)/$ ?page=$1
RewriteBase /
RewriteCond %{REQUEST_URI} !\.(js|ico|txt|gif|jpg|png|css|php)
RewriteRule ^(.*)$ index.php/$1/

View File

@ -1195,3 +1195,16 @@ a.interface-upup:hover, a.interface-updown:hover, a.interface-admindown:hover {
background-position: center left !important;
text-decoration: none;
}
/* Tooltip */
.bubbleInfo {
position: relative;
}
.popup {
position: absolute;
display: none; /* keeps the popup hidden if no JS available */
}

View File

@ -1,5 +1,26 @@
<?php
function generate_url($vars, $new_vars = array())
{
$vars = array_merge($vars, $new_vars);
$url = "/".$vars['page']."/";
unset($vars['page']);
foreach($vars as $var => $value)
{
if($value != "")
{
$url .= $var ."=".$value."/";
}
}
return($url);
}
function get_percentage_colours($percentage)
{
@ -314,7 +335,7 @@ function generate_port_thumbnail($args)
echo(generate_port_link($args, $args['content']));
}
function print_optionbar_start ($height = 20, $width = 0, $marginbottom = 5)
function print_optionbar_start ($height = 0, $width = 0, $marginbottom = 5)
{
echo("
<div style='text-align: center; margin-top: 0px; margin-bottom: ".$marginbottom."px; " . ($width ? 'max-width: ' . $width . (strstr($width,'%') ? '' : 'px') . '; ' : '') . "'>

View File

@ -21,7 +21,7 @@ $rrd_options .= 'DEF:g='.$rrd_filename.':sb_closing:AVERAGE ';
$rrd_options .= 'DEF:h='.$rrd_filename.':sb_logging:AVERAGE ';
$rrd_options .= 'DEF:i='.$rrd_filename.':sb_graceful:AVERAGE ';
$rrd_options .= 'DEF:j='.$rrd_filename.':sb_idle:AVERAGE ';
$rrd_options .= 'COMMENT:"Scoreboard Current Average Maximum" ';
$rrd_options .= 'COMMENT:"Scoreboard Current Average Maximum\n" ';
$rrd_options .= 'AREA:a#4444FFFF:"Waiting " ';
$rrd_options .= 'GPRINT:a:LAST:"%6.2lf %s" ';
$rrd_options .= 'GPRINT:a:AVERAGE:"%6.2lf %s" ';

View File

@ -7,6 +7,10 @@ if ($_GET['height']) { $height = mres($_GET['height']); }
if ($_GET['inverse']) { $in = 'out'; $out = 'in'; } else { $in = 'in'; $out = 'out'; }
if ($_GET['legend'] == "no") { $rrd_options = " -g"; }
if ($_GET['title'] == "yes") { $rrd_options .= " --title='".$graph_title."' "; }
if (isset($_GET['graph_title'])) { $rrd_options .= " --title='".$_GET['graph_title']."' "; }
if (!$scale_min && !$scale_max) { $rrd_options .= " --alt-autoscale-max"; }
if (isset($scale_min)) { $rrd_options .= " -l $scale_min"; }
@ -26,4 +30,4 @@ else { $rrd_options .= " --font LEGEND:8:" . $config['mono_font'
$rrd_options .= " --font-render-mode normal";
?>
?>

View File

@ -4,6 +4,7 @@ if (is_numeric($id) && ($config['allow_unauth_graphs'] || device_permitted($id))
{
$device = device_by_id_cache($id);
$title = generate_device_link($device);
$graph_title = $device['hostname'];
$auth = TRUE;
}

View File

@ -39,6 +39,8 @@ foreach (dbFetchRows("SELECT * FROM `ports` WHERE `device_id` = ?", array($id))
$rra_in = "INOCTETS";
$rra_out = "OUTOCTETS";
$graph_title .= "::bits";
$colour_line_in = "006600";
$colour_line_out = "000099";
$colour_area_in = "CDEB8B";

View File

@ -6,9 +6,12 @@ if (is_numeric($id) && ($config['allow_unauth_graphs'] || port_permitted($id)))
$device = device_by_id_cache($port['device_id']);
$title = generate_device_link($device);
$title .= " :: Port ".generate_port_link($port);
$graph_title = $device['hostname'] . "::" . $port['ifDescr'];
$auth = TRUE;
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/port-" . safename($port['ifIndex'] . ".rrd");
}
?>
?>

View File

@ -0,0 +1,44 @@
<?php
if ($bg == $list_colour_b) { $bg = $list_colour_a; } else { $bg = $list_colour_b; }
if ($device['status'] == '0')
{
$class = "list-device-down";
} else {
$class = "list-device";
}
if ($device['ignore'] == '1')
{
$class = "list-device-ignored";
if ($device['status'] == '1')
{
$class = "list-device-ignored-up";
}
}
if ($device['disabled'] == '1')
{
$class = "list-device-disabled";
}
$type = strtolower($device['os']);
if ($device['os'] == "ios") { formatCiscoHardware($device, true); }
$device['os_text'] = $config['os'][$device['os']]['text'];
echo(' <tr class="'.$class.'" bgcolor="' . $bg . '" onmouseover="this.style.backgroundColor=\'#fdd\';" onmouseout="this.style.backgroundColor=\'' . $bg . '\';"
onclick="location.href=\'device/'.$device['device_id'].'/\'" style="cursor: pointer;">
<td width="300"><span style="font-size: 15px;">' . generate_device_link($device) . '</span></td>'
);
echo(' <td>' . $device['hardware'] . ' ' . $device['features'] . '</td>');
echo(' <td>' . $device['os_text'] . ' ' . $device['version'] . '</td>');
echo(' <td>' . formatUptime($device['uptime'], 'short') . ' <br />');
if (get_dev_attrib($device,'override_sysLocation_bool')) { $device['location'] = get_dev_attrib($device,'override_sysLocation_string'); }
echo(' ' . truncate($device['location'],32, '') . '</td>');
echo (' </tr>');
?>

View File

@ -217,7 +217,7 @@ if ($config['show_locations'])
<?php
foreach (getlocations() as $location)
{
echo(' <li><a href="devices/location|' . urlencode($location) . '/"><img src="images/16/building.png" border="0" align="absmiddle" /> ' . $location . ' </a></li>');
echo(' <li><a href="devices/location=' . urlencode($location) . '/"><img src="images/16/building.png" border="0" align="absmiddle" /> ' . $location . ' </a></li>');
}
?>
</ul>

View File

@ -1,5 +1,9 @@
<?php
#echo($_SERVER['PATH_INFO']);
#phpinfo();
ob_start();
ini_set('allow_url_fopen', 0);
@ -27,6 +31,69 @@ include("includes/functions.inc.php");
include("includes/authenticate.inc.php");
foreach($_GET as $key=>$get_var) {
if(strstr($key, "opt")) {
list($name, $value) = explode("|", $get_var);
if(!isset($value)) { $value = "yes"; }
$vars[$name] = $value;
}
}
$segments = explode('/', trim($_SERVER['REQUEST_URI'], '/'));
foreach($segments as $pos => $segment) {
$segment = urldecode($segment);
if($pos == "0")
{
$vars['page'] = $segment;
} else {
if(TRUE) // do this to keep everything working whilst we fiddle
{
if ($pos == "1")
{
$_GET['opta'] = $segment;
}
if ($pos == "2")
{
$_GET['optb'] = $segment;
}
if ($pos == "3")
{
$_GET['optc'] = $segment;
}
if ($pos == "4")
{
$_GET['optd'] = $segment;
}
if ($pos == "5")
{
$_GET['opte'] = $segment;
}
if ($pos == "6")
{
$_GET['optf'] = $segment;
}
}
list($name, $value) = explode("=", $segment);
if($value == "" || !isset($value))
{
$vars[$name] = yes;
} else {
$vars[$name] = $value;
}
}
}
foreach($_POST as $name => $value)
{
# if($value == "" || !isset($value))
# {
# } else {
$vars[$name] = $value;
# }
}
#print_r($vars);
if(strstr($_SERVER['REQUEST_URI'], 'widescreen=yes')) { $_SESSION['widescreen'] = 1; }
if(strstr($_SERVER['REQUEST_URI'], 'widescreen=no')) { unset($_SESSION['widescreen']); }
@ -92,6 +159,68 @@ if ($config['page_refresh']) { echo("<meta http-equiv='refresh' content='".$conf
<script type="text/javascript" src="js/jqplot/plugins/jqplot.pieRenderer.min.js"></script>
<script type="text/javascript" src="js/jqplot/plugins/jqplot.donutRenderer.min.js"></script>
<script type="text/javascript">
<!--
$(function () {
$('.bubbleInfo').each(function () {
var distance = 10;
var time = 250;
var hideDelay = 500;
var hideDelayTimer = null;
var beingShown = false;
var shown = false;
var trigger = $('.trigger', this);
var info = $('.popup', this).css('opacity', 0);
$([trigger.get(0), info.get(0)]).mouseover(function () {
if (hideDelayTimer) clearTimeout(hideDelayTimer);
if (beingShown || shown) {
// don't trigger the animation again
return;
} else {
// reset position of info box
beingShown = true;
info.css({
top: -90,
left: -33,
display: 'block'
}).animate({
top: '-=' + distance + 'px',
opacity: 1
}, time, 'swing', function() {
beingShown = false;
shown = true;
});
}
return false;
}).mouseout(function () {
if (hideDelayTimer) clearTimeout(hideDelayTimer);
hideDelayTimer = setTimeout(function () {
hideDelayTimer = null;
info.animate({
top: '-=' + distance + 'px',
opacity: 0
}, time, 'swing', function () {
shown = false;
info.css('display', 'none');
});
}, hideDelay);
return false;
});
});
});
//-->
</script>
<script type="text/javascript">
<!-- Begin
function popUp(URL)
{
@ -106,9 +235,13 @@ function popUp(URL)
<?php
include("includes/".$config['web_header']);
if(!$vars['bare'] == "yes") {
if ($_SESSION['authenticated']) { include("includes/print-menubar.php"); } else { echo('<hr color="#444444" />'); }
include("includes/".$config['web_header']);
if ($_SESSION['authenticated']) { include("includes/print-menubar.php"); } else { echo('<hr color="#444444" />'); }
}
?>
<div class="clearer"></div>
@ -119,9 +252,9 @@ if ($_SESSION['authenticated']) { include("includes/print-menubar.php"); } else
if ($_SESSION['authenticated'])
{
## Authenticated. Print a page.
if (isset($_GET['page']) && !strstr("..", $_GET['page']) && is_file("pages/" . $_GET['page'] . ".inc.php"))
if (isset($vars['page']) && !strstr("..", $vars['page']) && is_file("pages/" . $vars['page'] . ".inc.php"))
{
include("pages/" . $_GET['page'] . ".inc.php");
include("pages/" . $vars['page'] . ".inc.php");
} else {
if (isset($config['front_page']) && is_file($config['front_page']))
{
@ -159,15 +292,20 @@ echo('</a>. Copyright &copy; 2006-'. date("Y"). ' by Adam Armstrong. All rights
if ($config['page_gen'])
{
echo('<br />MySQL: Cell '.($db_stats['fetchcell']+0).'/'.round($db_stats['fetchcell_sec']+0,2).'s'.
' Row '.($db_stats['fetchrow']+0). '/'.round($db_stats['fetchrow_sec']+0,2).'s'.
' Rows '.($db_stats['fetchrows']+0).'/'.round($db_stats['fetchrows_sec']+0,2).'s'.
' Column '.($db_stats['fetchcol']+0). '/'.round($db_stats['fetchcol_sec']+0,2).'s');
echo('<br />MySQL: Cell '.($db_stats['fetchcell']+0).'/'.round($db_stats['fetchcell_sec']+0,3).'s'.
' Row '.($db_stats['fetchrow']+0). '/'.round($db_stats['fetchrow_sec']+0,3).'s'.
' Rows '.($db_stats['fetchrows']+0).'/'.round($db_stats['fetchrows_sec']+0,3).'s'.
' Column '.($db_stats['fetchcol']+0). '/'.round($db_stats['fetchcol_sec']+0,3).'s');
echo('<br />Generated in ' . $gentime . ' seconds.');
}
echo('</div>');
?>
<script class="content_tooltips" type="text/javascript">
$(document).ready(function() { $('#content a[title]').qtip({ content: { text: false }, style: 'light' }); });
</script>
</body>
</html>

View File

@ -167,7 +167,7 @@ if (device_permitted($_GET['opta']) || $check_device == $_GET['opta'])
if (dbFetchCell("SELECT COUNT(service_id) FROM services WHERE device_id = '" . $device['device_id'] . "'") > '0')
{
echo('<li class="' . $select['srv'] . '">
echo('<li class="' . $select['services'] . '">
<a href="device/' . $device['device_id'] . '/services/">
<img src="images/icons/services.png" align="absmiddle" border="0" /> Services
</a>

View File

@ -111,7 +111,3 @@ foreach (dbFetchRows("SELECT * FROM `cef_switching` WHERE `device_id` = ? ORDER
echo("</table></div>");
?>
<script class="content_tooltips" type="text/javascript">
$(document).ready(function() { $('#content a[title]').qtip({ content: { text: false }, style: 'light' }); });
</script>

View File

@ -1,37 +1,34 @@
<?php
### FIXME - this code might suck cock. is there a better way?
### Set Defaults here
### Turn /devices/os|linux/location|France/ into
### $_POST[os] = "linux"; $_POST['location'] = "France"
$sql_param = array();
foreach($_GET as $key=>$get_var) {
if(strstr($key, "opt")) {
list($name, $value) = explode("|", $get_var);
$_POST[$name] = $value;
}
}
if(!isset($graph)) { $graph = "bits"; }
### FIXME - build this string in new method
if ($vars['hostname']) { $where .= " AND hostname LIKE ?"; $sql_param[] = "%".$vars['hostname']."%"; }
if ($vars['os']) { $where .= " AND os = ?"; $sql_param[] = $vars['os']; }
if ($vars['version']) { $where .= " AND version = ?"; $sql_param[] = $vars['version']; }
if ($vars['hardware']) { $where .= " AND hardware = ?"; $sql_param[] = $vars['hardware']; }
if ($vars['features']) { $where .= " AND features = ?"; $sql_param[] = $vars['features']; }
if ($vars['type']) { $where .= " AND type = ?"; $sql_param[] = $vars['type']; }
if ($_POST['hostname']) { $where .= " AND hostname LIKE '%".mres($_POST['hostname'])."%'"; }
if ($_POST['os']) { $where .= " AND os = '".mres($_POST['os'])."'"; }
if ($_POST['version']) { $where .= " AND version = '".mres($_POST['version'])."'"; }
if ($_POST['hardware']) { $where .= " AND hardware = '".mres($_POST['hardware'])."'"; }
if ($_POST['features']) { $where .= " AND features = '".mres($_POST['features'])."'"; }
if ($_GET['location'] == "Unset") { $location_filter = ''; }
if ($_GET['location'] && !isset($_POST['location'])) { $location_filter = $_GET['location']; }
if ($_POST['location']) { $location_filter = $_POST['location']; }
if ($vars['location'] == "Unset") { $location_filter = ''; }
if ($vars['location']) { $location_filter = $vars['location']; }
print_optionbar_start();
if($vars['searchbar'] != "hide")
{
print_optionbar_start(62);
?>
<form method="post" action="">
<table cellpadding="4" cellspacing="0" class="devicetable" width="100%">
<tr>
<td width="30" align="center" valign="middle"></td>
<td width="300"><span style="font-weight: bold; font-size: 14px;"></span>
<input type="text" name="hostname" id="hostname" size="40" value="<?php echo($_POST['hostname']); ?>" />
<input type="text" name="hostname" id="hostname" size="40" value="<?php echo($vars['hostname']); ?>" />
</td>
<td width="200">
<select name='os' id='os'>
@ -43,7 +40,7 @@ foreach(dbFetch('SELECT `os` FROM `devices` AS D WHERE 1 GROUP BY `os` ORDER BY
if ($data['os'])
{
echo("<option value='".$data['os']."'");
if ($data['os'] == $_POST['os']) { echo(" selected"); }
if ($data['os'] == $vars['os']) { echo(" selected"); }
echo(">".$config['os'][$data['os']]['text']."</option>");
}
}
@ -59,7 +56,7 @@ foreach(dbFetch('SELECT `version` FROM `devices` AS D WHERE 1 GROUP BY `version`
if ($data['version'])
{
echo("<option value='".$data['version']."'");
if ($data['version'] == $_POST['version']) { echo(" selected"); }
if ($data['version'] == $vars['version']) { echo(" selected"); }
echo(">".$data['version']."</option>");
}
}
@ -75,7 +72,7 @@ foreach(dbFetch('SELECT `hardware` FROM `devices` AS D WHERE 1 GROUP BY `hardwar
if ($data['hardware'])
{
echo('<option value="'.$data['hardware'].'"');
if ($data['hardware'] == $_POST['hardware']) { echo(" selected"); }
if ($data['hardware'] == $vars['hardware']) { echo(" selected"); }
echo(">".$data['hardware']."</option>");
}
}
@ -91,7 +88,7 @@ foreach(dbFetch('SELECT `features` FROM `devices` AS D WHERE 1 GROUP BY `feature
if ($data['features'])
{
echo('<option value="'.$data['features'].'"');
if ($data['features'] == $_POST['features']) { echo(" selected"); }
if ($data['features'] == $vars['features']) { echo(" selected"); }
echo(">".$data['features']."</option>");
}
}
@ -102,49 +99,188 @@ foreach(dbFetch('SELECT `features` FROM `devices` AS D WHERE 1 GROUP BY `feature
<select name="location" id="location">
<option value="">All Locations</option>
<?php
### fix me function?
foreach (getlocations() as $location) ## FIXME function name sucks maybe get_locations ?
{
if ($location)
{
echo('<option value="'.$location.'"');
if ($location == $_POST['location']) { echo(" selected"); }
if ($location == $vars['location']) { echo(" selected"); }
echo(">".$location."</option>");
}
}
?>
</select>
<br />
<select name="type" id="type">
<option value="">All Device Types</option>
<?php
foreach(dbFetch('SELECT `type` FROM `devices` AS D WHERE 1 GROUP BY `type` ORDER BY `type`') as $data)
{
if ($data['type'])
{
echo("<option value='".$data['type']."'");
if ($data['type'] == $vars['type']) { echo(" selected"); }
echo(">".ucfirst($data['type'])."</option>");
}
}
?>
</select>
<input class="submit" type="submit" class="submit" value="Search">
<input class="submit" type="submit" class="submit" style="float: right;" value="Search">
</td>
<td align=center>
<a href="<?php echo(generate_url($vars)); ?>" title="Update the browser URL to reflect the search criteria." >Update URL</a>
<a href="<?php echo(generate_url(array('page' => 'monitor', 'section' => $vars['section'], 'bare' => $vars['bare']))); ?>" title="Reset critera to default." >Reset</a>
</td>
<td width="10"></td>
</tr>
</table>
</form>
<?php
print_optionbar_end();
<hr />
<?php
$sql = "SELECT * FROM devices WHERE 1 $where ORDER BY `disabled` ASC, `ignore`, `status`, `hostname`";
if ($_GET['status'] == "alerted")
{
$sql = "SELECT * FROM devices " . $device_alert_sql . " GROUP BY `device_id` ORDER BY `ignore`, `status`, `os`, `hostname`";
}
echo('<table cellpadding="7" cellspacing="0" class="devicetable sortable" width="100%">
<tr class="tablehead"><th></th><th>Device</th><th></th><th>Operating System</th><th>Platform</th><th>Uptime/Location</th></tr>');
echo('<span style="font-weight: bold;">Lists</span> &#187; ');
foreach(dbFetch($sql) as $device)
$menu_options = array('basic' => 'Basic',
'detail' => 'Detail');
$sep = "";
foreach ($menu_options as $option => $text)
{
if (device_permitted($device['device_id']))
echo($sep);
if ($vars['format'] == "list_".$option)
{
if (!$location_filter || ((get_dev_attrib($device,'override_sysLocation_bool') && get_dev_attrib($device,'override_sysLocation_string') == $location_filter)
|| $device['location'] == $location_filter))
{
include("includes/hostbox.inc.php");
}
echo("<span class='pagemenu-selected'>");
}
echo('<a href="' . generate_url($vars, array('format' => "list_".$option)) . '">' . $text . '</a>');
if ($vars['format'] == "list_".$option)
{
echo("</span>");
}
$sep = " | ";
}
echo("</table>");
?>
|
<span style="font-weight: bold;">Graphs</span> &#187;
<?php
$menu_options = array('bits' => 'Bits',
'processor' => 'CPU',
'mempool' => 'Memory',
'uptime' => 'Uptime');
$sep = "";
foreach ($menu_options as $option => $text)
{
echo($sep);
if ($vars['format'] == 'graph_'.$option)
{
echo("<span class='pagemenu-selected'>");
}
echo('<a href="' . generate_url($vars, array('format' => 'graph_'.$option)) . '">' . $text . '</a>');
if ($vars['format'] == 'graph_'.$option)
{
echo("</span>");
}
$sep = " | ";
}
?>
<div style="float: right;">
<?php
if($vars['searchbar'] == "hide")
{
echo('<a href="'. generate_url($vars, array('searchbar' => '')).'">Restore Search</a>');
} else {
echo('<a href="'. generate_url($vars, array('searchbar' => 'hide')).'">Remove Search</a>');
}
echo(" | ");
if($vars['bare'] == "yes")
{
echo('<a href="'. generate_url($vars, array('bare' => '')).'">Restore Header</a>');
} else {
echo('<a href="'. generate_url($vars, array('bare' => 'yes')).'">Remove Header</a>');
}
?>
</div>
<?php
print_optionbar_end();
$query = "SELECT * FROM `devices` WHERE 1 ".$where." ORDER BY hostname";
list($format, $subformat) = explode("_", $vars['format']);
if($format == "graph")
{
$row = 1;
foreach (dbFetchRows($query, $sql_param) as $device)
{
if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
if (device_permitted($device['device_id']))
{
if (!$location_filter || ((get_dev_attrib($device,'override_sysLocation_bool') && get_dev_attrib($device,'override_sysLocation_string') == $location_filter)
|| $device['location'] == $location_filter))
{
$graph_type = "device_".$subformat;
echo("<div style='display: block; padding: 1px; margin: 2px; min-width: 393px; max-width:393px; min-height:180px; max-height:180px; text-align: center; float: left; background-color: #f5f5f5;'>
<a href='device/".$device['device_id']."/port/".$device['device_id']."/' onmouseover=\"return overlib('\
<div style=\'font-size: 16px; padding:5px; font-weight: bold; color: #e5e5e5;\'>".$device['hostname']." - ".$interface['ifDescr']."</div>\
<img src=\'graph.php?type=$graph_type&amp;id=".$device['device_id']."&amp;from=".$config['time']['day']."&amp;to=".$config['time']['now']."&amp;width=450&amp;height=150&amp;title=yes\'>\
', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >".
"<img src='graph.php?type=$graph_type&amp;id=".$device['device_id']."&amp;from=".$config['time']['day']."&amp;to=".$config['time']['now']."&amp;width=315&amp;height=110&amp;legend=no&amp;title=yes'>
</a>
</div>");
}
}
}
} else {
echo('<table cellpadding="7" cellspacing="0" class="devicetable sortable" width="100%">');
# <tr class="tablehead"><th></th><th>Device</th><th></th><th>Operating System</th><th>Platform</th><th>Uptime/Location</th></tr>');
foreach (dbFetchRows($query, $sql_param) as $device)
{
if (device_permitted($device['device_id']))
{
if (!$location_filter || ((get_dev_attrib($device,'override_sysLocation_bool') && get_dev_attrib($device,'override_sysLocation_string') == $location_filter)
|| $device['location'] == $location_filter))
{
if($subformat == "detail")
{
include("includes/hostbox.inc.php");
} else {
include("includes/hostbox-basic.inc.php");
}
}
}
}
echo("</table>");
}
?>

View File

@ -1,4 +1,35 @@
<?php
print_optionbar_start();
echo('<span style="font-weight: bold;">Locations</span> &#187; ');
$menu_options = array('basic' => 'Basic',
'traffic' => 'Traffic');
if (!$vars['view']) { $vars['view'] = "basic"; }
$sep = "";
foreach ($menu_options as $option => $text)
{
echo($sep);
if ($vars['view'] == $option)
{
echo("<span class='pagemenu-selected'>");
}
echo('<a href="locations/view=' . $option . '/">' . $text . '</a>');
if ($vars['view'] == $option)
{
echo("</span>");
}
$sep = " | ";
}
unset($sep);
print_optionbar_end();
echo('<table cellpadding="7" cellspacing="0" class="devicetable" width="100%">');
foreach (getlocations() as $location)
@ -25,7 +56,7 @@ foreach (getlocations() as $location)
if ($location != "")
{
echo(' <tr bgcolor="' . $bg . '">
<td class="interface" width="300"><a class="list-bold" href="?page=devices&amp;location=' . urlencode($location) . '">' . $location . '</a></td>
<td class="interface" width="300"><a class="list-bold" href="devices/location=' . urlencode($location) . '/">' . $location . '</a></td>
<td width="100">' . $alert . '</td>
<td width="100">' . $num . ' devices</td>
<td width="100">' . $net . ' network</td>
@ -34,6 +65,21 @@ foreach (getlocations() as $location)
</tr>
');
if($vars['view'] == "traffic")
{
echo('<tr bgcolor="' . $bg . '"><td colspan=6>');
$graph_array['type'] = "location_bits";
$graph_array['height'] = "100";
$graph_array['width'] = "220";
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = $location;
include("includes/print-quadgraphs.inc.php");
echo("</tr></td>");
}
$done = "yes";
}
}

View File

@ -1,7 +1,241 @@
<?php
$file = $config['install_dir'] . "/html/pages/ports/" . safename($_GET['opta']) . ".inc.php";
### Set Defaults here
if (is_file($file)) { include($file); } else { include("ports/default.inc.php"); }
if(!isset($vars['format'])) { $vars['format'] = "list_basic"; }
?>
if($vars['searchbar'] != "hide")
{
print_optionbar_start();
?>
<table style="text-align: left;" cellpadding=0 cellspacing=5 class=devicetable width=100%>
<tr style='padding: 0px;'>
<form method='post' action=''>
<td width='200'>
<select name='device_id' id='device_id'>
<option value=''>All Devices</option>
<?php
foreach (dbFetchRows("SELECT `device_id`,`hostname` FROM `devices` GROUP BY `hostname` ORDER BY `hostname`") as $data)
{
echo("<option value='".$data['device_id']."'");
if ($data['device_id'] == $vars['device_id']) { echo("selected"); }
echo(">".$data['hostname']."</option>");
}
?>
</select>
</td>
<td width='150'>
<select name='state' id='state'>
<option value=''>All States</option>
<option value='up' <?php if ($vars['state'] == "up") { echo("selected"); } ?>>Up</option>
<option value='down'<?php if ($vars['state'] == "down") { echo("selected"); } ?>>Down</option>
<option value='admindown' <?php if ($vars['state'] == "admindown") { echo("selected"); } ?>>Shutdown</option>
<option value='errors' <?php if ($vars['state'] == "errors") { echo("selected"); } ?>>Errors</option>
<option value='ignored' <?php if ($vars['state'] == "ignored") { echo("selected"); } ?>>Ignored</option>
<option value='ethernet' <?php if ($vars['state'] == "ethernet") { echo("selected"); } ?>>Ethernet</option>
<option value='l2vlan' <?php if ($vars['state'] == "l2vlan") { echo("selected"); } ?>>L2 VLAN</option>
<option value='sonet' <?php if ($vars['state'] == "sonet") { echo("selected"); } ?>>SONET</option>
<option value='propvirtual' <?php if ($vars['state'] == "propvirtual") { echo("selected"); } ?>>Virtual</option>
<option value='ppp' <?php if ($vars['state'] == "ppp") { echo("selected"); } ?>>PPP</option>
<option value='loopback' <?php if ($vars['state'] == "loopback") { echo("selected"); } ?>>Loopback</option>
</select>
</td>
<td width=110>
<select name='ifSpeed' id='ifSpeed'>
<option value=''>All Speeds</option>
<?php
foreach (dbFetchRows("SELECT `ifSpeed` FROM `ports` GROUP BY `ifSpeed` ORDER BY `ifSpeed`") as $data)
{
if ($data['ifSpeed'])
{
echo("<option value='".$data['ifSpeed']."'");
if ($data['ifSpeed'] == $vars['ifSpeed']) { echo("selected"); }
echo(">".humanspeed($data['ifSpeed'])."</option>");
}
}
?>
</select>
</td>
<td width=200>
<select name='ifType' id='ifType'>
<option value=''>All Media</option>
<?php
foreach (dbFetchRows("SELECT `ifType` FROM `ports` GROUP BY `ifType` ORDER BY `ifType`") as $data)
{
if ($data['ifType'])
{
echo("<option value='".$data['ifType']."'");
if ($data['ifType'] == $vars['ifType']) { echo("selected"); }
echo(">".$data['ifType']."</option>");
}
}
?>
</select>
</td>
<td>
<input type="text" name="ifAlias" id="ifAlias" size=40 value="<?php echo($vars['ifAlias']); ?>" />
Deleted <input type=checkbox id="deleted" name="deleted" value=1 <?php if ($vars['deleted']) { echo("checked"); } ?> ></input>
</td>
<td style="text-align: right;">
<input style="align:right;" type=submit class=submit value=Search></div>
</td>
<td align=center>
<a href="<?php echo(generate_url($vars)); ?>" title="Update the browser URL to reflect the search criteria." >Update URL</a> <br />
<a href="<?php echo(generate_url(array('page' => 'monitor', 'section' => $vars['section'], 'bare' => $vars['bare']))); ?>" title="Reset critera to default." >Reset</a>
</td>
</form>
</tr>
</table>
<hr />
<?php }
echo('<span style="font-weight: bold;">Lists</span> &#187; ');
$menu_options = array('basic' => 'Basic',
'detail' => 'Detail');
$sep = "";
foreach ($menu_options as $option => $text)
{
echo($sep);
if ($vars['format'] == "list_".$option)
{
echo("<span class='pagemenu-selected'>");
}
echo('<a href="' . generate_url($vars, array('format' => "list_".$option)) . '">' . $text . '</a>');
if ($vars['format'] == "list_".$option)
{
echo("</span>");
}
$sep = " | ";
}
?>
|
<span style="font-weight: bold;">Graphs</span> &#187;
<?php
$menu_options = array('bits' => 'Basic',
'upkts' => 'Unicast Packets',
'nupkts' => 'Non-Unicast Packets',
'errors' => 'Errors');
$sep = "";
foreach ($menu_options as $option => $text)
{
echo($sep);
if ($vars['format'] == 'graph_'.$option)
{
echo("<span class='pagemenu-selected'>");
}
echo('<a href="' . generate_url($vars, array('format' => 'graph_'.$option)) . '">' . $text . '</a>');
if ($vars['format'] == 'graph_'.$option)
{
echo("</span>");
}
$sep = " | ";
}
echo('<div style="float: right;">');
if($vars['searchbar'] == "hide")
{
echo('<a href="'. generate_url($vars, array('searchbar' => '')).'">Restore Search</a>');
} else {
echo('<a href="'. generate_url($vars, array('searchbar' => 'hide')).'">Remove Search</a>');
}
echo(" | ");
if($vars['bare'] == "yes")
{
echo('<a href="'. generate_url($vars, array('bare' => '')).'">Restore Header</a>');
} else {
echo('<a href="'. generate_url($vars, array('bare' => 'yes')).'">Remove Header</a>');
}
echo('</div>');
print_optionbar_end();
#if ($_SESSION['userlevel'] >= '5') {
# $sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id ORDER BY D.hostname, I.ifDescr";
#} else {
# $sql = "SELECT * FROM `ports` AS I, `devices` AS D, `devices_perms` AS P WHERE I.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' ORDER BY D.hostname, I.ifDescr";
#}
$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 (is_numeric($vars['device_id']))
{
$where .= " AND I.device_id = ?";
$param[] = $vars['device_id'];
}
if ($vars['ifType'])
{
$where .= " AND I.ifType = ?";
$param[] = $vars['ifType'];
}
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";
$row = 1;
list($format, $subformat) = explode("_", $vars['format']);
if(file_exists('pages/ports/'.$format.'.inc.php'))
{
include('pages/ports/'.$format.'.inc.php');
}
?>

View File

@ -0,0 +1,34 @@
<?
foreach (dbFetchRows($query, $param) as $interface)
{
if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
$speed = humanspeed($interface['ifSpeed']);
$type = humanmedia($interface['ifType']);
$interface['in_rate'] = formatRates($interface['ifInOctets_rate'] * 8);
$interface['out_rate'] = formatRates($interface['ifOutOctets_rate'] * 8);
if ($interface['in_errors'] > 0 || $interface['out_errors'] > 0)
{
$error_img = generate_port_link($interface,"<img src='images/16/chart_curve_error.png' alt='Interface Errors' border=0>",errors);
} else { $error_img = ""; }
if (port_permitted($interface['interface_id'], $interface['device_id']))
{
$interface = ifLabel($interface, $device);
$graph_type = "port_" . $subformat;
echo("<div style='display: block; padding: 1px; margin: 2px; min-width: 393px; max-width:393px; min-height:180px; max-height:180px; text-align: center; float: left; background-color: #f5f5f5;'>
<a href='device/".$device['device_id']."/port/".$interface['interface_id']."/' onmouseover=\"return overlib('\
<div style=\'font-size: 16px; padding:5px; font-weight: bold; color: #e5e5e5;\'>".$device['hostname']." - ".$interface['ifDescr']."</div>\
<img src=\'graph.php?type=$graph_type&amp;id=".$interface['interface_id']."&amp;from=".$config['time']['day']."&amp;to=".$config['time']['now']."&amp;width=450&amp;height=150&amp;title=yes\'>\
', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >".
"<img src='graph.php?type=$graph_type&amp;id=".$interface['interface_id']."&amp;from=".$config['time']['day']."&amp;to=".$config['time']['now']."&amp;width=315&amp;height=110&amp;legend=no&amp;title=yes'>
</a>
</div>");
}
}
?>

View File

@ -1,79 +1,3 @@
<?php print_optionbar_start(50); ?>
<table style="text-align: left;" cellpadding=0 cellspacing=5 class=devicetable width=100%>
<tr style='padding: 0px;'>
<form method='post' action=''>
<td width='200'>
<select name='device_id' id='device_id'>
<option value=''>All Devices</option>
<?php
foreach (dbFetchRows("SELECT `device_id`,`hostname` FROM `devices` GROUP BY `hostname` ORDER BY `hostname`") as $data)
{
echo("<option value='".$data['device_id']."'");
if ($data['device_id'] == $_POST['device_id']) { echo("selected"); }
echo(">".$data['hostname']."</option>");
}
?>
</select>
</td>
<td width='150'>
<select name='state' id='state'>
<option value=''>All States</option>
<option value='up' <?php if ($_POST['state'] == "up") { echo("selected"); } ?>>Up</option>
<option value='down'<?php if ($_POST['state'] == "down") { echo("selected"); } ?>>Down</option>
<option value='admindown' <?php if ($_POST['state'] == "admindown") { echo("selected"); } ?>>Shutdown</option>
<option value='errors' <?php if ($_POST['state'] == "errors") { echo("selected"); } ?>>Errors</option>
<option value='ignored' <?php if ($_POST['state'] == "ignored") { echo("selected"); } ?>>Ignored</option>
<option value='ethernet' <?php if ($_POST['state'] == "ethernet") { echo("selected"); } ?>>Ethernet</option>
<option value='l2vlan' <?php if ($_POST['state'] == "l2vlan") { echo("selected"); } ?>>L2 VLAN</option>
<option value='sonet' <?php if ($_POST['state'] == "sonet") { echo("selected"); } ?>>SONET</option>
<option value='propvirtual' <?php if ($_POST['state'] == "propvirtual") { echo("selected"); } ?>>Virtual</option>
<option value='ppp' <?php if ($_POST['state'] == "ppp") { echo("selected"); } ?>>PPP</option>
<option value='loopback' <?php if ($_POST['state'] == "loopback") { echo("selected"); } ?>>Loopback</option>
</select>
</td>
<td width=110>
<select name='ifSpeed' id='ifSpeed'>
<option value=''>All Speeds</option>
<?php
foreach (dbFetchRows("SELECT `ifSpeed` FROM `ports` GROUP BY `ifSpeed` ORDER BY `ifSpeed`") as $data)
{
if ($data['ifSpeed'])
{
echo("<option value='".$data['ifSpeed']."'");
if ($data['ifSpeed'] == $_POST['ifSpeed']) { echo("selected"); }
echo(">".humanspeed($data['ifSpeed'])."</option>");
}
}
?>
</select>
</td>
<td width=200>
<select name='ifType' id='ifType'>
<option value=''>All Media</option>
<?php
foreach (dbFetchRows("SELECT `ifType` FROM `ports` GROUP BY `ifType` ORDER BY `ifType`") as $data)
{
if ($data['ifType'])
{
echo("<option value='".$data['ifType']."'");
if ($data['ifType'] == $_POST['ifType']) { echo("selected"); }
echo(">".$data['ifType']."</option>");
}
}
?>
</select>
</td>
<td>
<input type="text" name="ifAlias" id="ifAlias" size=40 value="<?php echo($_POST['ifAlias']); ?>" />
Deleted <input type=checkbox id="deleted" name="deleted" value=1 <?php if ($_POST['deleted']) { echo("checked"); } ?> ></input>
</td>
<td style="text-align: right;">
<input style="align:right;" type=submit class=submit value=Search></div>
</td>
</form>
</tr>
</table>
<?php print_optionbar_end(); ?>
<table cellpadding=3 cellspacing=0 class="devicetable sortable" width=100%>

View File

@ -1,4 +1,6 @@
<?php print_optionbar_start();
<?php
print_optionbar_start();
echo('<span style="font-weight: bold;">Services</span> &#187; ');