accesspoint support (probably) from ethan sommer (#50)

git-svn-id: http://www.observium.org/svn/observer/trunk@3223 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2012-05-21 18:17:23 +00:00
parent fcef689504
commit d3796004ae
21 changed files with 596 additions and 2 deletions
+46
View File
@@ -294,6 +294,7 @@ function print_graph_tag($args)
function generate_graph_tag($args)
{
foreach ($args as $key => $arg)
{
$urlargs[] = $key."=".$arg;
@@ -538,4 +539,49 @@ function foldersize($path)
return array($total_size, $total_files);
}
function generate_ap_link($args, $text = NULL, $type = NULL)
{
global $config;
$args = ifNameDescr($args);
if (!$text) { $text = fixIfName($args['label']); }
if ($type) { $args['graph_type'] = $type; }
if (!isset($args['graph_type'])) { $args['graph_type'] = 'port_bits'; }
if (!isset($args['hostname'])) { $args = array_merge($args, device_by_id_cache($args['device_id'])); }
$content = "<div class=list-large>".$args['text']." - " . fixifName($args['label']) . "</div>";
if ($args['ifAlias']) { $content .= $args['ifAlias']."<br />"; }
$content .= "<div style=\'width: 850px\'>";
$graph_array['type'] = $args['graph_type'];
$graph_array['legend'] = "yes";
$graph_array['height'] = "100";
$graph_array['width'] = "340";
$graph_array['to'] = $config['time']['now'];
$graph_array['from'] = $config['time']['day'];
$graph_array['id'] = $args['accesspoint_id'];
$content .= generate_graph_tag($graph_array);
$graph_array['from'] = $config['time']['week'];
$content .= generate_graph_tag($graph_array);
$graph_array['from'] = $config['time']['month'];
$content .= generate_graph_tag($graph_array);
$graph_array['from'] = $config['time']['year'];
$content .= generate_graph_tag($graph_array);
$content .= "</div>";
$url = generate_ap_url($args);
if (port_permitted($args['interface_id'], $args['device_id'])) {
return overlib_link($url, $text, $content, $class);
} else {
return fixifName($text);
}
}
function generate_ap_url($ap, $vars=array())
{
return generate_url(array('page' => 'device', 'device' => $ap['device_id'], 'tab' => 'accesspoint', 'ap' => $ap['accesspoint_id']), $vars);
}
?>
@@ -0,0 +1,17 @@
<?php
if (is_numeric($vars['id']))
{
$ap = accesspoint_by_id($id);
if (is_numeric($ap['device_id']) && ($auth || device_permitted($ap['device_id'])))
{
$device = device_by_id_cache($ap['device_id']);
$title = generate_device_link($device);
$title .= " :: AP :: " . htmlentities($ap['name']);
$auth = TRUE;
}
}
?>
@@ -0,0 +1,24 @@
<?php
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] ."/". safename("arubaap-$ap[name].$ap[radio_number].rrd");
$rrd_list[0]['filename'] = $rrd_filename;
$rrd_list[0]['descr'] = "Channel";
$rrd_list[0]['ds'] = "channel";
$unit_text = "Channel";
$units='';
$total_units='';
$colours='mixed';
$scale_min = "0";
$nototal = 1;
if ($rrd_list)
{
include("includes/graphs/generic_multi_line.inc.php");
}
?>
@@ -0,0 +1,27 @@
<?php
$ap=accesspoint_by_id($id);
$device = device_by_id_cache($ap['device_id']);
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] ."/".
safename("arubaap-$ap[name].$ap[radio_number].rrd");
$rrd_list[0]['filename'] = $rrd_filename;
$rrd_list[0]['descr'] = "Interference";
$rrd_list[0]['ds'] = "interference";
$unit_text = "Int";
$units='';
$total_units='';
$colours='mixed';
$scale_min = "0";
$nototal = 1;
if ($rrd_list)
{
include("includes/graphs/generic_multi_line.inc.php");
}
?>
@@ -0,0 +1,28 @@
<?php
$ap=accesspoint_by_id($id);
$device = device_by_id_cache($ap['device_id']);
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] ."/".
safename("arubaap-$ap[name].$ap[radio_number].rrd");
$rrd_list[0]['filename'] = $rrd_filename;
$rrd_list[0]['descr'] = "Num Clients";
$rrd_list[0]['ds'] = "numasoclients";
$unit_text = "Clients";
$units='';
$total_units='';
$colours='mixed';
$scale_min = "0";
$nototal = 1;
if ($rrd_list)
{
include("includes/graphs/generic_multi_line.inc.php");
}
?>
@@ -0,0 +1,29 @@
<?php
$ap=accesspoint_by_id($id);
$device = device_by_id_cache($ap['device_id']);
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] ."/".
safename("arubaap-$ap[name].$ap[radio_number].rrd");
$rrd_list[0]['filename'] = $rrd_filename;
$rrd_list[0]['descr'] = "MonBSSIDs";
$rrd_list[0]['ds'] = "nummonbssid";
$unit_text = "BSSIDs";
$units='';
$total_units='';
$colours='mixed';
$scale_min = "0";
$nototal = 1;
if ($rrd_list)
{
include("includes/graphs/generic_multi_line.inc.php");
}
?>
@@ -0,0 +1,28 @@
<?php
$ap=accesspoint_by_id($id);
$device = device_by_id_cache($ap['device_id']);
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] ."/".
safename("arubaap-$ap[name].$ap[radio_number].rrd");
$rrd_list[0]['filename'] = $rrd_filename;
$rrd_list[0]['descr'] = "Mon Clients";
$rrd_list[0]['ds'] = "nummonclients";
$unit_text = "Clients";
$units='';
$total_units='';
$colours='mixed';
$scale_min = "0";
$nototal = 1;
if ($rrd_list)
{
include("includes/graphs/generic_multi_line.inc.php");
}
?>
@@ -0,0 +1,30 @@
<?php
$ap=accesspoint_by_id($id);
$device = device_by_id_cache($ap['device_id']);
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] ."/".
safename("arubaap-$ap[name].$ap[radio_number].rrd");
$rrd_list[0]['filename'] = $rrd_filename;
$rrd_list[0]['descr'] = "radioutil";
$rrd_list[0]['ds'] = "radioutil";
$unit_text = "Percent";
$units='';
$total_units='';
$colours='mixed';
$scale_min = "0";
$nototal = 1;
if ($rrd_list)
{
include("includes/graphs/generic_multi_line.inc.php");
}
?>
@@ -0,0 +1,31 @@
<?php
$ap=accesspoint_by_id($id);
$device = device_by_id_cache($ap['device_id']);
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] ."/".
safename("arubaap-$ap[name].$ap[radio_number].rrd");
$rrd_list[0]['filename'] = $rrd_filename;
$rrd_list[0]['descr'] = "txpow";
$rrd_list[0]['ds'] = "txpow";
$unit_text = "dBm";
$units='';
$total_units='';
$colours='mixed';
$scale_min = "0";
$nototal = 1;
if ($rrd_list)
{
include("includes/graphs/generic_multi_line.inc.php");
}
?>
+4 -1
View File
@@ -65,10 +65,11 @@ if (is_file($config['install_dir'] . "/html/includes/graphs/$type/$subtype.inc.p
{
include($config['install_dir'] . "/html/includes/graphs/$type/$subtype.inc.php");
}
}
else
{
graph_error("Graph Template Missing");
graph_error("$type*$subtype ");//Graph Template Missing");
}
function graph_error($string)
@@ -106,6 +107,7 @@ function graph_error($string)
}
}
if ($error_msg) {
/// We have an error :(
@@ -141,6 +143,7 @@ if ($error_msg) {
unlink($graphfile);
echo("</div>");
} else {
if ($rrd_options)
{
rrdtool_graph($graphfile, $rrd_options);
@@ -0,0 +1,13 @@
<?php
global $config;
$graph_array['height'] = "100";
$graph_array['width'] = "215";
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = $ap['accesspoint_id'];
$graph_array['type'] = $graph_type;
include("includes/print-quadgraphs.inc.php");
?>
+92
View File
@@ -0,0 +1,92 @@
<?php
if($int_colour)
{
$row_colour = $int_colour;
} else {
if (!is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
}
$text=$ap['name'] ." ".$ap['type'];
$ap['text']=$text;
echo("<tr style=\"background-color: $row_colour;\" valign=top onmouseover=\"this.style.backgroundColor='$list_highlight';\" onmouseout=\"this.style.backgroundColor='$row_colour';\" onclick=\"location.href='" . generate_ap_url($ap) . "/'\" style='cursor: pointer;'>
<td valign=top width=350>");
echo(" <span class=list-large> " . generate_ap_link($ap, " $text </span><br />"));
echo("<span class=interface-desc>");
echo("$break".$ap['mac_addr']."<br>".$ap['type']. " - channel ".$ap['channel']);
echo("<br />txpow $ap[txpow]");
echo("</span>");
echo("</td><td width=100>");
echo("</td><td width=150>");
$ap['graph_type'] = "accesspoints_numasoclients";
echo(generate_ap_link($ap, "<img src='graph.php?type=$ap[graph_type]&amp;id=".$ap['accesspoint_id']."&amp;from=".$config['time']['day']."&amp;to=".$config['time']['now']."&amp;width=100&amp;height=20&amp;legend=no&amp;bg=".str_replace("#","", $row_colour)."'>"));
echo("<br>\n");
$ap['graph_type'] = "accesspoints_radioutil";
echo(generate_ap_link($ap, "<img src='graph.php?type=$ap[graph_type]&amp;id=".$ap['accesspoint_id']."&amp;from=".$config['time']['day']."&amp;to=".$config['time']['now']."&amp;width=100&amp;height=20&amp;legend=no&amp;bg=".str_replace("#","", $row_colour)."'>"));
echo("<br>\n");
$ap['graph_type'] = "accesspoints_interference";
echo(generate_ap_link($ap, "<img src='graph.php?type=$ap[graph_type]&amp;id=".$ap['accesspoint_id']."&amp;from=".$config['time']['day']."&amp;to=".$config['time']['now']."&amp;width=100&amp;height=20&amp;legend=no&amp;bg=".str_replace("#","", $row_colour)."'>"));
echo("<br>\n");
echo("</td><td width=120>");
echo("<img src='images/icons/wireless.png' style='height:20px; width:20px;' align=absmiddle /> ".format_bi($ap[numasoclients])." Clients<br />");
echo("<img src='images/icons/wireless.png' style='height:20px; width:20px;' align=absmiddle /> ".format_bi($ap[radioutil])." % busy<br />");
echo("<img src='images/icons/wireless.png' style='height:20px; width:20px;' align=absmiddle /> ".format_bi($ap[interference])." interference index<br />");
echo("</td></tr>");
if ($vars['tab'] == "accesspoint") {
$graph_type='accesspoints_numasoclients';
echo("<tr style='background-color: $row_colour; padding: 0px;'><td colspan=7>");
echo("<div class='graphhead'>Associated Clients</div>");
include("includes/print-accesspoint-graphs.inc.php");
echo("</td></tr>");
$graph_type='accesspoints_interference';
echo("<tr style='background-color: $row_colour; padding: 0px;'><td colspan=7>");
echo("<div class='graphhead'>Interference</div>");
include("includes/print-accesspoint-graphs.inc.php");
echo("</td></tr>");
$graph_type='accesspoints_channel';
echo("<tr style='background-color: $row_colour; padding: 0px;'><td colspan=7>");
echo("<div class='graphhead'>Channel</div>");
include("includes/print-accesspoint-graphs.inc.php");
echo("</td></tr>");
$graph_type='accesspoints_txpow';
echo("<tr style='background-color: $row_colour; padding: 0px;'><td colspan=7>");
echo("<div class='graphhead'>Transmit Power</div>");
include("includes/print-accesspoint-graphs.inc.php");
echo("</td></tr>");
$graph_type='accesspoints_radioutil';
echo("<tr style='background-color: $row_colour; padding: 0px;'><td colspan=7>");
echo("<div class='graphhead'>Radio Utilization</div>");
include("includes/print-accesspoint-graphs.inc.php");
echo("</td></tr>");
$graph_type='accesspoints_nummonclients';
echo("<tr style='background-color: $row_colour; padding: 0px;'><td colspan=7>");
echo("<div class='graphhead'>Monitored Clients</div>");
include("includes/print-accesspoint-graphs.inc.php");
echo("</td></tr>");
$graph_type='accesspoints_nummonbssid';
echo("<tr style='background-color: $row_colour; padding: 0px;'><td colspan=7>");
echo("<div class='graphhead'>Number of monitored BSSIDs</div>");
include("includes/print-accesspoint-graphs.inc.php");
echo("</td></tr>");
}
?>