Skip to content

Commit

Permalink
make legacy realtime work in mrtg view
Browse files Browse the repository at this point in the history
  • Loading branch information
cigamit committed Apr 2, 2016
1 parent b0607bb commit 1b5cadf
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 22 deletions.
34 changes: 17 additions & 17 deletions graph_realtime.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@

/* construct the image name */
$graph_data_array['export_realtime'] = read_config_option('realtime_cache_path') . '/user_' . session_id() . '_lgi_' . get_request_var('local_graph_id') . '.png';
$graph_data_array['output_flag'] = RRDTOOL_OUTPUT_GRAPH_DATA;
$graph_data_array['output_flag'] = RRDTOOL_OUTPUT_GRAPH_DATA;

rrdtool_function_graph(get_request_var('local_graph_id'), '', $graph_data_array);

Expand All @@ -148,11 +148,11 @@
/* send text information back to browser as well as image information */
$return_array = array(
'local_graph_id' => get_request_var('local_graph_id'),
'top' => get_request_var('top'),
'left' => get_request_var('left'),
'ds_step' => (isset($_SESSION['sess_realtime_ds_step']) ? $_SESSION['sess_realtime_ds_step']:$graph_data_array['ds_step']),
'graph_start' => (isset($_SESSION['sess_realtime_graph_start']) ? $_SESSION['sess_realtime_graph_start']:$graph_data_array['graph_start']),
'data' => (isset($data) ? $data:'')
'top' => get_request_var('top'),
'left' => get_request_var('left'),
'ds_step' => (isset($_SESSION['sess_realtime_ds_step']) ? $_SESSION['sess_realtime_ds_step']:$graph_data_array['ds_step']),
'graph_start' => (isset($_SESSION['sess_realtime_graph_start']) ? $_SESSION['sess_realtime_graph_start']:$graph_data_array['graph_start']),
'data' => (isset($data) ? $data:'')
);

print json_encode($return_array);
Expand Down Expand Up @@ -245,7 +245,7 @@
<table align='center'>
<tr>
<td>
<strong>Timespan</strong>
Window
</td>
<td>
<select name='graph_start' id='graph_start' onChange='imageOptionsChanged("timespan")'>
Expand All @@ -259,7 +259,7 @@
</select>
</td>
<td>
<strong>Interval</strong>
Refresh
</td>
<td>
<select name='ds_step' id='ds_step' onChange="imageOptionsChanged('interval')">
Expand All @@ -275,7 +275,7 @@
</tr>
<tr>
<td align='center' colspan='6'>
<span id='countdown'><strong><?php echo get_request_var('ds_step'); ?> seconds left.</strong></span>
<span id='countdown'><?php echo get_request_var('ds_step'); ?> seconds left.</span>
</td>
</tr>
</table>
Expand All @@ -291,36 +291,36 @@
var ds_step = 0;
var sizeset = false;
var count = 0;
var browser = "";
var browser = '';

function countdown_update() {
ds_step--;

if (ds_step < 0) {
ds_step = $("#ds_step").val();
ds_step = $('#ds_step').val();
imageOptionsChanged('countdown');
sizeset = false;
}

$('#countdown').html( '<strong>' + ds_step + ' seconds left.</strong>');
$('#countdown').html(ds_step + ' seconds left.');

browser = realtimeDetectBrowser();

/* set the window size */
height = $(".graphimage").height();
width = $(".graphimage").width();
height = $('.graphimage').height();
width = $('.graphimage').width();

if (height > 40) {
if (browser == "IE") {
if (browser == 'IE') {
width = width + 30;
height = height + 110;
}else{
width = width + 40;
height = height + 165;
height = height + 170;
}

if (sizeset == false) {
if (browser == "FF") {
if (browser == 'FF') {
window.outerHeight = height;
window.outerWidth = width;
}else{
Expand Down
2 changes: 1 addition & 1 deletion include/global_arrays.php
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,7 @@
$realtime_refresh = array(
5 => __('%d Seconds', 5),
10 => __('%d Seconds', 10),
15 => __('%d Seconds', 25),
15 => __('%d Seconds', 15),
20 => __('%d Seconds', 20),
30 => __('%d Seconds', 30),
60 => __('1 Minute'),
Expand Down
19 changes: 15 additions & 4 deletions include/realtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var originalRefresh = 0;
var timeOffset;
var realtimeTimer;
var rtWidth = 0;
var rtheight = 0;
var rtHeight = 0;
var url;

function realtimeDetectBrowser() {
Expand All @@ -30,12 +30,23 @@ function imageOptionsChanged(action) {
graph_start = $("#graph_start").val();
graph_end = 0;
ds_step = $("#ds_step").val();
local_graph_id = $('#local_graph_id').val();

url="?top=0&left=0&action="+action+"&graph_start=-"+graph_start+"&ds_step="+ds_step+"&count="+count;
if (rtWidth == 0) {
rtWidth = $(window).width();
}

if (rtHeight == 0) {
rtHeight = $(window).height()+50;
}

url="?top=0&left=0&action="+action+"&local_graph_id="+local_graph_id+"&graph_start=-"+graph_start+"&ds_step="+ds_step+"&count="+count;

Pace.stop;

$.get(url);
$.getJSON(url, function(data) {
$('#image').empty().append('<img class="graphimage" src="data:image/png;base64,'+data.data+'"/>');
});
}

function stopRealtime() {
Expand Down Expand Up @@ -127,7 +138,7 @@ function realtimeGrapher() {
});
}
}

if (inRealtime == false) {
stopRealtime();
} else {
Expand Down

0 comments on commit 1b5cadf

Please sign in to comment.