mirror of
https://github.com/librenms/librenms.git
synced 2024-09-23 11:29:23 +00:00
adding new web-only includes for functions and add thumbnail graphs to pseudowires
git-svn-id: http://www.observium.org/svn/observer/trunk@478 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
parent
ccf67209fd
commit
233cc0a773
55
html/includes/functions.inc.php
Normal file
55
html/includes/functions.inc.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
function generate_if_link($args)
|
||||
{
|
||||
global $twoday; global $now; global $config; global $day; global $month;
|
||||
$args = ifNameDescr($args);
|
||||
if(!$args['content']) { $args['content'] = fixIfName($args['label']); }
|
||||
if(!$args['graph_type']) { $args['graph_type'] = 'bits'; }
|
||||
$class = ifclass($args['ifOperStatus'], $args['ifAdminStatus']);
|
||||
$graph_url = $config['base_url'] . "/graph.php?if=" . $args['interface_id'] . "&from=$day&to=$now&width=400&height=100&type=" . $args['graph_type'];
|
||||
$graph_url_month = $config['base_url'] . "/graph.php?if=" . $args['interface_id'] . "&from=$month&to=$now&width=400&height=100&type=" . $args['graph_type'];
|
||||
$device_id = getifhost($args['interface_id']);
|
||||
$link = "<a class=$class href='".$config['base_url']."/device/$device_id/interface/" . $args['interface_id'] . "/' ";
|
||||
$link .= "onmouseover=\" return overlib('";
|
||||
$link .= "<img src=\'$graph_url\'><br /><img src=\'$graph_url_month\'>', CAPTION, '<span class=list-large>" . $args['hostname'] . " - " . fixifName($args['label']) . "</span>";
|
||||
if($args['ifAlias']) { $link .= "<br />" . $args['ifAlias']; }
|
||||
$link .= "' ";
|
||||
$link .= $config['overlib_defaults'].");\" onmouseout=\"return nd();\" >".$args['content']."</a>";
|
||||
return $link;
|
||||
}
|
||||
|
||||
function generate_port_thumbnail($args) {
|
||||
if(!$args['bg']) { $args['bg'] = "FFFFF"; }
|
||||
$args['content'] = "<img src='graph.php?type=".$args['graph_type']."&if=".$args['interface_id']."&from=".$args['from']."&to=".$args['to']."&width=".$args['width']."&height=".$args['height']."&legend=no&bg=".$args['bg']."'>";
|
||||
$output = generate_if_link($args);
|
||||
echo $output;
|
||||
}
|
||||
|
||||
function print_optionbar_start () {
|
||||
echo("
|
||||
<div style='margin:auto; text-align: center; margin-top: 0px; margin-bottom: 10px;'>
|
||||
<b class='rounded'>
|
||||
<b class='rounded1'><b></b></b>
|
||||
<b class='rounded2'><b></b></b>
|
||||
<b class='rounded3'></b>
|
||||
<b class='rounded4'></b>
|
||||
<b class='rounded5'></b></b>
|
||||
<div class='roundedfg' style='padding: 0px 5px;'>
|
||||
<div style='margin: auto; text-align: left; padding: 2px 5px; padding-left: 11px; clear: both; display:block; height:20px;'>");
|
||||
}
|
||||
|
||||
|
||||
function print_optionbar_end () {
|
||||
echo(" </div>
|
||||
</div>
|
||||
<b class='rounded'>
|
||||
<b class='rounded5'></b>
|
||||
<b class='rounded4'></b>
|
||||
<b class='rounded3'></b>
|
||||
<b class='rounded2'><b></b></b>
|
||||
<b class='rounded1'><b></b></b></b>
|
||||
</div>");
|
||||
}
|
||||
|
||||
?>
|
@ -3,7 +3,7 @@
|
||||
ini_set('display_errors', 0);
|
||||
|
||||
|
||||
if($_GET[debug]) {
|
||||
if($debug) {
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
ini_set('log_errors', 1);
|
||||
@ -12,6 +12,7 @@ if($_GET[debug]) {
|
||||
|
||||
include("../config.php");
|
||||
include("../includes/functions.php");
|
||||
include("includes/functions.inc.php");
|
||||
include("includes/authenticate.inc");
|
||||
$start = utime();
|
||||
|
||||
|
@ -1,16 +1,8 @@
|
||||
<?php
|
||||
echo("
|
||||
<div style='margin:auto; text-align: center; margin-top: 0px; margin-bottom: 10px;'>
|
||||
<b class='rounded'>
|
||||
<b class='rounded1'><b></b></b>
|
||||
<b class='rounded2'><b></b></b>
|
||||
<b class='rounded3'></b>
|
||||
<b class='rounded4'></b>
|
||||
<b class='rounded5'></b></b>
|
||||
<div class='roundedfg' style='padding: 0px 5px;'>
|
||||
<div style='margin: auto; text-align: left; padding: 2px 5px; padding-left: 11px; clear: both; display:block; height:20px;'>
|
||||
|
||||
<a href='".$config['base_url']."/device/" . $device['device_id'] . "/ports/'>Basic</a> |
|
||||
print_optionbar_start();
|
||||
|
||||
echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/ports/'>Basic</a> |
|
||||
<a href='".$config['base_url']."/device/" . $device['device_id'] . "/ports/details/'>Details</a> |
|
||||
<a href='".$config['base_url']."/device/" . $device['device_id'] . "/ports/arp/'>ARP Table</a> | Graphs:
|
||||
<a href='".$config['base_url']."/device/" . $device['device_id'] . "/ports/graphs/bits/'>Bits</a>
|
||||
@ -20,17 +12,9 @@ echo("
|
||||
<a href='".$config['base_url']."/device/" . $device['device_id'] . "/ports/graphs/nupkts/'>NU Packets</a>
|
||||
(<a href='".$config['base_url']."/device/" . $device['device_id'] . "/ports/graphs/nupkts/thumbs/'>Mini</a>) |
|
||||
<a href='".$config['base_url']."/device/" . $device['device_id'] . "/ports/graphs/errors/'>Errors</a>
|
||||
(<a href='".$config['base_url']."/device/" . $device['device_id'] . "/ports/graphs/errors/thumbs/'>Mini</a>)</a>
|
||||
</div>
|
||||
</div>
|
||||
<b class='rounded'>
|
||||
<b class='rounded5'></b>
|
||||
<b class='rounded4'></b>
|
||||
<b class='rounded3'></b>
|
||||
<b class='rounded2'><b></b></b>
|
||||
<b class='rounded1'><b></b></b></b>
|
||||
</div>
|
||||
");
|
||||
(<a href='".$config['base_url']."/device/" . $device['device_id'] . "/ports/graphs/errors/thumbs/'>Mini</a>)</a>");
|
||||
|
||||
print_optionbar_end();
|
||||
|
||||
if($_GET['opta'] == graphs ) {
|
||||
if($_GET['optb']) { $graph_type = $_GET['optb']; } else { $graph_type = "bits"; }
|
||||
|
@ -1,6 +1,16 @@
|
||||
<?php
|
||||
|
||||
echo("<table cellpadding=7 cellspacing=0 class=devicetable width=100%>");
|
||||
print_optionbar_start();
|
||||
|
||||
echo("<a href='".$config['base_url']."/pseudowires/'>Details</a> | Graphs :
|
||||
<a href='".$config['base_url']."/pseudowires/graphs/mini/'>Mini</a>
|
||||
");
|
||||
|
||||
print_optionbar_end();
|
||||
|
||||
list($opta, $optb, $optc, $optd, $opte) = explode("/", $_GET['opta']);
|
||||
|
||||
echo("<table cellpadding=5 cellspacing=0 class=devicetable width=100%>");
|
||||
|
||||
$sql = "SELECT * FROM pseudowires AS P, interfaces AS I, devices AS D WHERE P.interface_id = I.interface_id AND I.device_id = D.device_id ORDER BY D.hostname,I.ifDescr";
|
||||
$query = mysql_query($sql);
|
||||
@ -25,14 +35,49 @@ while($pw_a = mysql_fetch_array($query)) {
|
||||
if($skip) {
|
||||
unset($skip);
|
||||
} else {
|
||||
if($bg == "#ffffff") { $bg = "#e5e5e5"; } else { $bg="#ffffff"; }
|
||||
|
||||
echo("<tr style=\"background-color: $bg;\"><td rowspan=2 style='font-size:18px; padding:4px;'>".$pw_a['cpwVcID']."</td><td>".generatedevicelink($pw_a)."</td><td>".generateiflink($pw_a)."</td>
|
||||
<td rowspan=2> => </td>
|
||||
if($bg == "ffffff") { $bg = "e5e5e5"; } else { $bg="ffffff"; }
|
||||
echo("<tr style=\"background-color: #$bg;\"><td rowspan=2 style='font-size:18px; padding:4px;'>".$pw_a['cpwVcID']."</td><td>".generatedevicelink($pw_a)."</td><td>".generateiflink($pw_a)."</td>
|
||||
<td rowspan=2> <img src='".$config['base_url']."/images/16/arrow_right.png'> </td>
|
||||
<td>".generatedevicelink($pw_b)."</td><td>".generateiflink($pw_b)."</td></tr>");
|
||||
echo("<tr style=\"background-color: $bg;\"><td colspan=2>".$pw_a['ifAlias']."</td><td colspan=2>".$pw_b['ifAlias']."</td></tr>");
|
||||
echo("<tr style=\"background-color: #$bg;\"><td colspan=2>".$pw_a['ifAlias']."</td><td colspan=2>".$pw_b['ifAlias']."</td></tr>");
|
||||
if($opta == "graphs") {
|
||||
echo("<tr style=\"background-color: #$bg;\"><td></td><td colspan=2>");
|
||||
if(!$optb) { $optb = "mini"; }
|
||||
if($pw_a) {
|
||||
$pw_a['width'] = "150";
|
||||
$pw_a['height'] = "30";
|
||||
$pw_a['from'] = $day;
|
||||
$pw_a['to'] = $now;
|
||||
$pw_a['bg'] = $bg;
|
||||
$types = array('bits','pkts','errors');
|
||||
foreach($types as $graph_type) {
|
||||
$pw_a['graph_type'] = $graph_type;
|
||||
generate_port_thumbnail($pw_a);
|
||||
}
|
||||
}
|
||||
echo("</td><td></td><td colspan=2>");
|
||||
|
||||
if($pw_b) {
|
||||
$pw_b['width'] = "150";
|
||||
$pw_b['height'] = "30";
|
||||
$pw_b['from'] = $day;
|
||||
$pw_b['to'] = $now;
|
||||
$pw_b['bg'] = $bg;
|
||||
$types = array('bits','pkts','errors');
|
||||
foreach($types as $graph_type) {
|
||||
$pw_b['graph_type'] = $graph_type;
|
||||
generate_port_thumbnail($pw_b);
|
||||
}
|
||||
}
|
||||
|
||||
echo("</td></tr>");
|
||||
|
||||
}
|
||||
|
||||
$linkdone[] = $pw_b['device_id'] . $pw_b['interface_id'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
echo("</table>");
|
||||
|
Loading…
Reference in New Issue
Block a user