array('regexp' => '/^([0-9]+|all)$/')));
get_filter_request_var('local_graph_id');
get_filter_request_var('graph_end');
get_filter_request_var('graph_start');
get_filter_request_var('view_type', FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => '/^([a-zA-Z0-9]+)$/')));
/* ==================================================== */
api_plugin_hook_function('graph');
include_once('./lib/html_tree.php');
top_graph_header();
if (!isset_request_var('rra_id')) {
set_request_var('rra_id', 'all');
}
if (get_request_var('rra_id') == 'all' || isempty_request_var('rra_id')) {
$sql_where = ' AND dspr.id IS NOT NULL';
} else {
$sql_where = ' AND dspr.id=' . get_request_var('rra_id');
}
$exists = db_fetch_cell_prepared('SELECT local_graph_id
FROM graph_templates_graph
WHERE local_graph_id = ?',
array(get_request_var('local_graph_id')));
/* make sure the graph requested exists (sanity) */
if (!$exists) {
print '' . __('GRAPH DOES NOT EXIST') . '';
bottom_footer();
exit;
}
/* take graph permissions into account here */
if (!is_graph_allowed(get_request_var('local_graph_id'))) {
header('Location: permission_denied.php');
exit;
}
$graph_title = get_graph_title(get_request_var('local_graph_id'));
if (get_request_var('action') != 'properties') {
print "
";
}
$rras = get_associated_rras(get_request_var('local_graph_id'), $sql_where);
switch (get_request_var('action')) {
case 'view':
api_plugin_hook_function('page_buttons',
array(
'lgid' => get_request_var('local_graph_id'),
'leafid' => '',//$leaf_id,
'mode' => 'mrtg',
'rraid' => get_request_var('rra_id')
)
);
?>
|
'>
|
$max_timespan) {
$max_timespan = $rra['steps'] * $rra['rows'] * $rra['rrd_step'];
}
}
}
/* fetch information for the current RRA */
if (isset_request_var('rra_id') && get_request_var('rra_id') > 0) {
$rra = db_fetch_row_prepared('SELECT dspr.id, step, steps, dspr.name, `rows`
FROM data_source_profiles_rra AS dspr
INNER JOIN data_source_profiles AS dsp
ON dsp.id=dspr.data_source_profile_id
WHERE dspr.id = ?', array(get_request_var('rra_id')));
$rra['timespan'] = $rra['steps'] * $rra['step'] * $rra['rows'];
} else {
$rra = db_fetch_row_prepared('SELECT dspr.id, step, steps, dspr.name, `rows`
FROM data_source_profiles_rra AS dspr
INNER JOIN data_source_profiles AS dsp
ON dsp.id=dspr.data_source_profile_id
WHERE dspr.id = ?', array($rras[0]['id']));
$rra['timespan'] = $rra['steps'] * $rra['step'] * $rra['rows'];
}
/* define the time span, which decides which rra to use */
$timespan = -($rra['timespan']);
/* find the step and how often this graph is updated with new data */
$ds_step = db_fetch_cell_prepared('SELECT
data_template_data.rrd_step
FROM (data_template_data, data_template_rrd, graph_templates_item)
WHERE graph_templates_item.task_item_id = data_template_rrd.id
AND data_template_rrd.local_data_id = data_template_data.local_data_id
AND graph_templates_item.local_graph_id = ?
LIMIT 0,1', array(get_request_var('local_graph_id')));
$ds_step = empty($ds_step) ? 300 : $ds_step;
$seconds_between_graph_updates = ($ds_step * $rra['steps']);
$now = time();
if (isset_request_var('graph_end') && (get_request_var('graph_end') <= $now - $seconds_between_graph_updates)) {
$graph_end = get_request_var('graph_end');
} else {
$graph_end = $now - $seconds_between_graph_updates;
}
if (isset_request_var('graph_start')) {
if (($graph_end - get_request_var('graph_start'))>$max_timespan) {
$graph_start = $now - $max_timespan;
}else {
$graph_start = get_request_var('graph_start');
}
} else {
$graph_start = $now + $timespan;
}
/* required for zoom out function */
if ($graph_start == $graph_end) {
$graph_start--;
}
$graph = db_fetch_row_prepared('SELECT width, height, title_cache, local_graph_id, graph_template_id
FROM graph_templates_graph
WHERE local_graph_id = ?',
array(get_request_var('local_graph_id')));
$graph_height = $graph['height'];
$graph_width = $graph['width'];
$graph_template_id = $graph['graph_template_id'];
if (read_user_setting('custom_fonts') == 'on' && read_user_setting('title_size') != '') {
$title_font_size = read_user_setting('title_size');
} elseif (read_config_option('title_size') != '') {
$title_font_size = read_config_option('title_size');
}else {
$title_font_size = 10;
}
?>
|
|
|
'>
|
|
\n";
print "\n";
print "\n";
print "\n";
print "" . __('RRDtool Command:') . " ";
$null_param = array();
print @rrdtool_function_graph(get_request_var('local_graph_id'), get_request_var('rra_id'), $graph_data_array, '', $null_param, $_SESSION['sess_user_id']);
unset($graph_data_array['print_source']);
print "" . __('RRDtool Says:') . " ";
if ($config['poller_id'] == 1) {
print @rrdtool_function_graph(get_request_var('local_graph_id'), get_request_var('rra_id'), $graph_data_array, '', $null_param, $_SESSION['sess_user_id']);
} else {
print __esc('Not Checked');
}
print " | \n";
print " |
\n";
exit;
break;
}
print '';
bottom_footer();