mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
add click to zoom to soem graphs, and new per-graphtype auth.inc.php to authenticate graphs and click-to-zoom pages.
git-svn-id: http://www.observium.org/svn/observer/trunk@1473 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -69,8 +69,8 @@ function generatedevicelink($device, $text=0, $start=0, $end=0)
|
||||
$graphhead = $entry['text'];
|
||||
$contents .= '<div style="width: 708px">';
|
||||
$contents .= '<span style="margin-left: 5px; font-size: 12px; font-weight: bold;">'.$graphhead.'</span><br />';
|
||||
$contents .= '<img src="' . $config['base_url'] . "/graph.php?device=" . $device['device_id'] . "&from=$start&to=$end&width=275&height=100&type=$graph&legend=no" . '" style="margin: 2px;">';
|
||||
$contents .= '<img src="' . $config['base_url'] . "/graph.php?device=" . $device['device_id'] . "&from=".$config['week']."&to=$end&width=275&height=100&type=$graph&legend=no" . '" style="margin: 2px;">';
|
||||
$contents .= '<img src="' . $config['base_url'] . "/graph.php?id=" . $device['device_id'] . "&from=$start&to=$end&width=275&height=100&type=$graph&legend=no" . '" style="margin: 2px;">';
|
||||
$contents .= '<img src="' . $config['base_url'] . "/graph.php?id=" . $device['device_id'] . "&from=".$config['week']."&to=$end&width=275&height=100&type=$graph&legend=no" . '" style="margin: 2px;">';
|
||||
$contents .= '</div>';
|
||||
}
|
||||
$text = htmlentities($text);
|
||||
|
||||
11
html/includes/graphs/device/auth.inc.php
Normal file
11
html/includes/graphs/device/auth.inc.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?
|
||||
|
||||
if(is_numeric($id)) {
|
||||
$device = device_by_id_cache($id);
|
||||
}
|
||||
|
||||
$title = generatedevicelink($device);
|
||||
|
||||
|
||||
|
||||
?>
|
||||
@@ -18,16 +18,16 @@ if($_GET['debug']) {
|
||||
if(!$_SESSION['authenticated']) { echo("not authenticated"); exit; }
|
||||
}
|
||||
|
||||
if($_GET['device']) {
|
||||
$_GET['id'] = $_GET['device'];
|
||||
$device_id = $_GET['device'];
|
||||
} elseif($_GET['if']) {
|
||||
$_GET['id'] = $_GET['if'];
|
||||
} elseif($_GET['port']) {
|
||||
$_GET['id'] = $_GET['port'];
|
||||
} elseif($_GET['peer']) {
|
||||
$_GET['id'] = $_GET['peer'];
|
||||
}
|
||||
# if($_GET['device']) {
|
||||
# $_GET['id'] = $_GET['device'];
|
||||
# $device_id = $_GET['device'];
|
||||
# } elseif($_GET['if']) {
|
||||
# $_GET['id'] = $_GET['if'];
|
||||
# } elseif($_GET['port']) {
|
||||
# $_GET['id'] = $_GET['port'];
|
||||
# } elseif($_GET['peer']) {
|
||||
# $_GET['id'] = $_GET['peer'];
|
||||
# }
|
||||
|
||||
preg_match('/^(?P<type>[A-Za-z0-9]+)_(?P<subtype>.+)/', mres($_GET['type']), $graphtype);
|
||||
|
||||
|
||||
12
html/includes/graphs/port/auth.inc.php
Normal file
12
html/includes/graphs/port/auth.inc.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?
|
||||
|
||||
if(is_numeric($id)) {
|
||||
$port = get_port_by_id($id);
|
||||
$device = device_by_id_cache($port['device_id']);
|
||||
}
|
||||
|
||||
$title = generatedevicelink($device);
|
||||
$title .= " :: Port ".generateiflink($port);
|
||||
|
||||
|
||||
?>
|
||||
@@ -1,47 +1,15 @@
|
||||
<?php
|
||||
|
||||
$g_i++;
|
||||
if(!is_integer($g_i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
|
||||
|
||||
echo("<div style='background-color: $row_colour;'>");
|
||||
$graph_array['type'] = $graph_type;
|
||||
$graph_array['id'] = $device['device_id'];
|
||||
|
||||
echo('<div style="padding:4px 0px 0px 8px;" class=graphhead>'.$graph_title.'</div>');
|
||||
|
||||
$daily_traffic = "graph.php?device=" . $device['device_id'] . "&type=$graph_type&from=".$config['day']."&to=".$config['now']."&width=215&height=100";
|
||||
$daily_traffic .= $args;
|
||||
$daily_url = "graph.php?device=" . $device['device_id'] . "&type=$graph_type&from=".$config['day']."&to=".$config['now']."&width=400&height=150";
|
||||
$daily_url .= $args;
|
||||
|
||||
$weekly_traffic = "graph.php?device=" . $device['device_id'] . "&type=$graph_type&from=".$config['week']."&to=".$config['now']."&width=215&height=100";
|
||||
$weekly_traffic .= $args;
|
||||
$weekly_url = "graph.php?device=" . $device['device_id'] . "&type=$graph_type&from=".$config['week']."&to=".$config['now']."&width=400&height=150";
|
||||
$weekly_url .= $args;
|
||||
|
||||
$monthly_traffic = "graph.php?device=" . $device['device_id'] . "&type=$graph_type&from=".$config['month']."&to=".$config['now']."&width=215&height=100";
|
||||
$monthly_traffic .= $args;
|
||||
$monthly_url = "graph.php?device=" . $device['device_id'] . "&type=$graph_type&from=".$config['month']."&to=".$config['now']."&width=400&height=150";
|
||||
$monthly_url .= $args;
|
||||
|
||||
$yearly_traffic = "graph.php?device=" . $device['device_id'] . "&type=$graph_type&from=".$config['year']."&to=".$config['now']."&width=215&height=100";
|
||||
$yearly_traffic .= $args;
|
||||
$yearly_url = "graph.php?device=" . $device['device_id'] . "&type=$graph_type&from=".$config['year']."&to=".$config['now']."&width=400&height=150";
|
||||
$yearly_url .= $args;
|
||||
|
||||
$graph_args = $device['device_id'] . "/" . $graph_type . "/";
|
||||
|
||||
echo("<a href='".$config['base_url']."/graphs/" . $graph_args . "' onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT".$config['overlib_defaults'].");\"
|
||||
onmouseout=\"return nd();\"> <img src='$daily_traffic' border=0></a> ");
|
||||
|
||||
echo("<a onmouseover=\"return overlib('<img src=\'$weekly_url\'>', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\">
|
||||
<img src='$weekly_traffic' border=0></a> ");
|
||||
|
||||
echo("<a onmouseover=\"return overlib('<img src=\'$monthly_url\'>', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\">
|
||||
<img src='$monthly_traffic' border=0></a> ");
|
||||
|
||||
echo("<a onmouseover=\"return overlib('<img src=\'$yearly_url\'>', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\">
|
||||
<img src='$yearly_traffic' border=0></a>");
|
||||
|
||||
echo("</div>");
|
||||
$g_i++;
|
||||
if(!is_integer($g_i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
|
||||
echo('<div style="background-color: '.$row_colour.';">');
|
||||
echo('<div style="padding:4px 0px 0px 8px;" class=graphhead>'.$graph_title.'</div>');
|
||||
include("includes/print-quadgraphs.inc.php");
|
||||
echo("</div>");
|
||||
|
||||
?>
|
||||
|
||||
|
||||
@@ -2,27 +2,15 @@
|
||||
|
||||
global $config;
|
||||
|
||||
if(!$graph_type) { $graph_type = $_GET['type']; }
|
||||
|
||||
if(!$device) { $device['device_id'] = getifhost($interface['interface_id']); }
|
||||
#if(!$graph_type) { $graph_type = $_GET['type']; }
|
||||
#if(!$device) { $device['device_id'] = getifhost($interface['interface_id']); }
|
||||
|
||||
$graph_array['height'] = "100";
|
||||
$graph_array['width'] = "215";
|
||||
$graph_array['to'] = $now;
|
||||
$graph_array['port'] = $interface['interface_id'];
|
||||
$graph_array['id'] = $interface['interface_id'];
|
||||
$graph_array['type'] = $graph_type;
|
||||
|
||||
$periods = array('day', 'week', 'month', 'year');
|
||||
|
||||
if($graph_type == "etherlike" && !is_file($config['rrd_dir'] . "/" . $device['hostname'] . "/etherlike-" . $interface['ifIndex'] . ".rrd")) {
|
||||
} else {
|
||||
|
||||
foreach($periods as $period) {
|
||||
$graph_array['from'] = $$period;
|
||||
$graph_array_zoom = $graph_array; $graph_array_zoom['height'] = "150"; $graph_array_zoom['width'] = "400";
|
||||
echo(overlib_link($_SERVER['REQUEST_URI'], generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL));
|
||||
}
|
||||
|
||||
}
|
||||
include("includes/print-quadgraphs.inc.php");
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user