mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
webui: Added support for stacked graphs (#7725)
* initial release * newline fix * missed some graphs in edit * style fixes * revert custom function, use Config * unified config option added webui graph config entry added sql entry for webui config * removed config_id from sql file * remove graph stack from defaults * moved transparency and stacked option to functions.php * style fixes * style fixes * changes in code added docs about stacked graphs * return keyed array * new colors and transparency * sql rename
This commit is contained in:
@@ -48,4 +48,4 @@ $config['rrd_purge'] = 0;
|
||||
$config['enable_billing'] = 1;
|
||||
|
||||
# Enable the in-built services support (Nagios plugins)
|
||||
$config['show_services'] = 1;
|
||||
$config['show_services'] = 1;
|
@@ -314,6 +314,9 @@ You can increase this if you want to try and fit more of the hostname in graph t
|
||||
The default value is 12
|
||||
However, this can possibly break graph generation if this is very long.
|
||||
|
||||
You can enable stacked graphs instead of the default inverted graphs.
|
||||
Enabling them is possible via webui Global Settings -> Webui Settings -> Graph settings -> Use stacked graphs
|
||||
|
||||
### Add host settings
|
||||
The following setting controls how hosts are added. If a host is added as an ip address it is checked to ensure the ip is not already present. If the ip is present the host is not added.
|
||||
If host is added by hostname this check is not performed. If the setting is true hostnames are resolved and the check is also performed. This helps prevents accidental duplicate hosts.
|
||||
|
@@ -49,8 +49,8 @@ function var_get($v)
|
||||
function data_uri($file, $mime)
|
||||
{
|
||||
$contents = file_get_contents($file);
|
||||
$base64 = base64_encode($contents);
|
||||
return ('data:'.$mime.';base64,'.$base64);
|
||||
$base64 = base64_encode($contents);
|
||||
return ('data:' . $mime . ';base64,' . $base64);
|
||||
}//end data_uri()
|
||||
|
||||
|
||||
@@ -137,12 +137,12 @@ function toner2colour($descr, $percent)
|
||||
$colour = get_percentage_colours(100 - $percent);
|
||||
|
||||
if (substr($descr, -1) == 'C' || stripos($descr, 'cyan') !== false) {
|
||||
$colour['left'] = '55D6D3';
|
||||
$colour['left'] = '55D6D3';
|
||||
$colour['right'] = '33B4B1';
|
||||
}
|
||||
|
||||
if (substr($descr, -1) == 'M' || stripos($descr, 'magenta') !== false) {
|
||||
$colour['left'] = 'F24AC8';
|
||||
$colour['left'] = 'F24AC8';
|
||||
$colour['right'] = 'D028A6';
|
||||
}
|
||||
|
||||
@@ -150,14 +150,14 @@ function toner2colour($descr, $percent)
|
||||
|| stripos($descr, 'giallo') !== false
|
||||
|| stripos($descr, 'gul') !== false
|
||||
) {
|
||||
$colour['left'] = 'FFF200';
|
||||
$colour['left'] = 'FFF200';
|
||||
$colour['right'] = 'DDD000';
|
||||
}
|
||||
|
||||
if (substr($descr, -1) == 'K' || stripos($descr, 'black') !== false
|
||||
|| stripos($descr, 'nero') !== false
|
||||
) {
|
||||
$colour['left'] = '000000';
|
||||
$colour['left'] = '000000';
|
||||
$colour['right'] = '222222';
|
||||
}
|
||||
|
||||
@@ -181,7 +181,7 @@ function linkify($text)
|
||||
|
||||
function generate_link($text, $vars, $new_vars = array())
|
||||
{
|
||||
return '<a href="'.generate_url($vars, $new_vars).'">'.$text.'</a>';
|
||||
return '<a href="' . generate_url($vars, $new_vars) . '">' . $text . '</a>';
|
||||
}//end generate_link()
|
||||
|
||||
|
||||
@@ -189,12 +189,12 @@ function generate_url($vars, $new_vars = array())
|
||||
{
|
||||
$vars = array_merge($vars, $new_vars);
|
||||
|
||||
$url = $vars['page'].'/';
|
||||
$url = $vars['page'] . '/';
|
||||
unset($vars['page']);
|
||||
|
||||
foreach ($vars as $var => $value) {
|
||||
if ($value == '0' || $value != '' && strstr($var, 'opt') === false && is_numeric($var) === false) {
|
||||
$url .= $var.'='.urlencode($value).'/';
|
||||
$url .= $var . '=' . urlencode($value) . '/';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,10 +212,10 @@ function generate_overlib_content($graph_array, $text)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$overlib_content = '<div class=overlib><span class=overlib-text>'.$text.'</span><br />';
|
||||
$overlib_content = '<div class=overlib><span class=overlib-text>' . $text . '</span><br />';
|
||||
foreach (array('day', 'week', 'month', 'year') as $period) {
|
||||
$graph_array['from'] = $config['time'][$period];
|
||||
$overlib_content .= escape_quotes(generate_graph_tag($graph_array));
|
||||
$overlib_content .= escape_quotes(generate_graph_tag($graph_array));
|
||||
}
|
||||
|
||||
$overlib_content .= '</div>';
|
||||
@@ -234,19 +234,19 @@ function get_percentage_colours($percentage, $component_perc_warn = null)
|
||||
|
||||
$background = array();
|
||||
if ($percentage > $perc_warn) {
|
||||
$background['left'] = 'c4323f';
|
||||
$background['left'] = 'c4323f';
|
||||
$background['right'] = 'C96A73';
|
||||
} elseif ($percentage > '75') {
|
||||
$background['left'] = 'bf5d5b';
|
||||
$background['left'] = 'bf5d5b';
|
||||
$background['right'] = 'd39392';
|
||||
} elseif ($percentage > '50') {
|
||||
$background['left'] = 'bf875b';
|
||||
$background['left'] = 'bf875b';
|
||||
$background['right'] = 'd3ae92';
|
||||
} elseif ($percentage > '25') {
|
||||
$background['left'] = '5b93bf';
|
||||
$background['left'] = '5b93bf';
|
||||
$background['right'] = '92b7d3';
|
||||
} else {
|
||||
$background['left'] = '9abf5b';
|
||||
$background['left'] = '9abf5b';
|
||||
$background['right'] = 'bbd392';
|
||||
}
|
||||
|
||||
@@ -256,7 +256,7 @@ function get_percentage_colours($percentage, $component_perc_warn = null)
|
||||
|
||||
function generate_minigraph_image($device, $start, $end, $type, $legend = 'no', $width = 275, $height = 100, $sep = '&', $class = 'minigraph-image', $absolute_size = 0)
|
||||
{
|
||||
return '<img class="'.$class.'" width="'.$width.'" height="'.$height.'" src="graph.php?'.implode($sep, array('device='.$device['device_id'], "from=$start", "to=$end", "width=$width", "height=$height", "type=$type", "legend=$legend", "absolute=$absolute_size")).'">';
|
||||
return '<img class="' . $class . '" width="' . $width . '" height="' . $height . '" src="graph.php?' . implode($sep, array('device=' . $device['device_id'], "from=$start", "to=$end", "width=$width", "height=$height", "type=$type", "legend=$legend", "absolute=$absolute_size")) . '">';
|
||||
}//end generate_minigraph_image()
|
||||
|
||||
|
||||
@@ -298,34 +298,34 @@ function generate_device_link($device, $text = null, $vars = array(), $start = 0
|
||||
$url = generate_device_url($device, $vars);
|
||||
|
||||
// beginning of overlib box contains large hostname followed by hardware & OS details
|
||||
$contents = '<div><span class="list-large">'.$device['hostname'].'</span>';
|
||||
$contents = '<div><span class="list-large">' . $device['hostname'] . '</span>';
|
||||
if ($device['hardware']) {
|
||||
$contents .= ' - '.$device['hardware'];
|
||||
$contents .= ' - ' . $device['hardware'];
|
||||
}
|
||||
|
||||
if ($device['os']) {
|
||||
$contents .= ' - '.mres($config['os'][$device['os']]['text']);
|
||||
$contents .= ' - ' . mres($config['os'][$device['os']]['text']);
|
||||
}
|
||||
|
||||
if ($device['version']) {
|
||||
$contents .= ' '.mres($device['version']);
|
||||
$contents .= ' ' . mres($device['version']);
|
||||
}
|
||||
|
||||
if ($device['features']) {
|
||||
$contents .= ' ('.mres($device['features']).')';
|
||||
$contents .= ' (' . mres($device['features']) . ')';
|
||||
}
|
||||
|
||||
if (isset($device['location'])) {
|
||||
$contents .= ' - '.htmlentities($device['location']);
|
||||
$contents .= ' - ' . htmlentities($device['location']);
|
||||
}
|
||||
|
||||
$contents .= '</div>';
|
||||
|
||||
foreach ($graphs as $entry) {
|
||||
$graph = $entry['graph'];
|
||||
$graph = $entry['graph'];
|
||||
$graphhead = $entry['text'];
|
||||
$contents .= '<div class="overlib-box">';
|
||||
$contents .= '<span class="overlib-title">'.$graphhead.'</span><br />';
|
||||
$contents .= '<span class="overlib-title">' . $graphhead . '</span><br />';
|
||||
$contents .= generate_minigraph_image($device, $start, $end, $graph);
|
||||
$contents .= generate_minigraph_image($device, $config['time']['week'], $end, $graph);
|
||||
$contents .= '</div>';
|
||||
@@ -353,21 +353,21 @@ function overlib_link($url, $text, $contents, $class = null)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$contents = "<div style=\'background-color: #FFFFFF;\'>".$contents.'</div>';
|
||||
$contents = "<div style=\'background-color: #FFFFFF;\'>" . $contents . '</div>';
|
||||
$contents = str_replace('"', "\'", $contents);
|
||||
if ($class === null) {
|
||||
$output = '<a href="'.$url.'"';
|
||||
$output = '<a href="' . $url . '"';
|
||||
} else {
|
||||
$output = '<a class="'.$class.'" href="'.$url.'"';
|
||||
$output = '<a class="' . $class . '" href="' . $url . '"';
|
||||
}
|
||||
|
||||
if ($config['web_mouseover'] === false) {
|
||||
$output .= '>';
|
||||
} else {
|
||||
$output .= " onmouseover=\"return overlib('".$contents."'".$config['overlib_defaults'].",WRAP,HAUTO,VAUTO); \" onmouseout=\"return nd();\">";
|
||||
$output .= " onmouseover=\"return overlib('" . $contents . "'" . $config['overlib_defaults'] . ",WRAP,HAUTO,VAUTO); \" onmouseout=\"return nd();\">";
|
||||
}
|
||||
|
||||
$output .= $text.'</a>';
|
||||
$output .= $text . '</a>';
|
||||
|
||||
return $output;
|
||||
}//end overlib_link()
|
||||
@@ -380,21 +380,21 @@ function generate_graph_popup($graph_array)
|
||||
// Take $graph_array and print day,week,month,year graps in overlib, hovered over graph
|
||||
$original_from = $graph_array['from'];
|
||||
|
||||
$graph = generate_graph_tag($graph_array);
|
||||
$content = '<div class=list-large>'.$graph_array['popup_title'].'</div>';
|
||||
$content .= "<div style=\'width: 850px\'>";
|
||||
$graph = generate_graph_tag($graph_array);
|
||||
$content = '<div class=list-large>' . $graph_array['popup_title'] . '</div>';
|
||||
$content .= "<div style=\'width: 850px\'>";
|
||||
$graph_array['legend'] = 'yes';
|
||||
$graph_array['height'] = '100';
|
||||
$graph_array['width'] = '340';
|
||||
$graph_array['from'] = $config['time']['day'];
|
||||
$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>';
|
||||
$graph_array['width'] = '340';
|
||||
$graph_array['from'] = $config['time']['day'];
|
||||
$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>';
|
||||
|
||||
$graph_array['from'] = $original_from;
|
||||
|
||||
@@ -414,15 +414,15 @@ function print_graph_popup($graph_array)
|
||||
function permissions_cache($user_id)
|
||||
{
|
||||
$permissions = array();
|
||||
foreach (dbFetchRows("SELECT * FROM devices_perms WHERE user_id = '".$user_id."'") as $device) {
|
||||
foreach (dbFetchRows("SELECT * FROM devices_perms WHERE user_id = '" . $user_id . "'") as $device) {
|
||||
$permissions['device'][$device['device_id']] = 1;
|
||||
}
|
||||
|
||||
foreach (dbFetchRows("SELECT * FROM ports_perms WHERE user_id = '".$user_id."'") as $port) {
|
||||
foreach (dbFetchRows("SELECT * FROM ports_perms WHERE user_id = '" . $user_id . "'") as $port) {
|
||||
$permissions['port'][$port['port_id']] = 1;
|
||||
}
|
||||
|
||||
foreach (dbFetchRows("SELECT * FROM bill_perms WHERE user_id = '".$user_id."'") as $bill) {
|
||||
foreach (dbFetchRows("SELECT * FROM bill_perms WHERE user_id = '" . $user_id . "'") as $bill) {
|
||||
$permissions['bill'][$bill['bill_id']] = 1;
|
||||
}
|
||||
|
||||
@@ -520,10 +520,10 @@ function generate_graph_tag($args)
|
||||
{
|
||||
$urlargs = array();
|
||||
foreach ($args as $key => $arg) {
|
||||
$urlargs[] = $key.'='.urlencode($arg);
|
||||
$urlargs[] = $key . '=' . urlencode($arg);
|
||||
}
|
||||
|
||||
return '<img src="graph.php?'.implode('&', $urlargs).'" border="0" />';
|
||||
return '<img src="graph.php?' . implode('&', $urlargs) . '" border="0" />';
|
||||
}//end generate_graph_tag()
|
||||
|
||||
function generate_lazy_graph_tag($args)
|
||||
@@ -544,17 +544,17 @@ function generate_lazy_graph_tag($args)
|
||||
$lazy_w = $arg;
|
||||
break;
|
||||
}
|
||||
$urlargs[] = $key."=".urlencode($arg);
|
||||
$urlargs[] = $key . "=" . urlencode($arg);
|
||||
}
|
||||
|
||||
if (isset($lazy_w)) {
|
||||
$w=$lazy_w;
|
||||
$w = $lazy_w;
|
||||
}
|
||||
|
||||
if ($config['enable_lazy_load'] === true) {
|
||||
return '<img class="lazy img-responsive" data-original="graph.php?' . implode('&', $urlargs).'" border="0" />';
|
||||
return '<img class="lazy img-responsive" data-original="graph.php?' . implode('&', $urlargs) . '" border="0" />';
|
||||
} else {
|
||||
return '<img class="img-responsive" src="graph.php?' . implode('&', $urlargs).'" border="0" />';
|
||||
return '<img class="img-responsive" src="graph.php?' . implode('&', $urlargs) . '" border="0" />';
|
||||
}
|
||||
}//end generate_lazy_graph_tag()
|
||||
|
||||
@@ -563,9 +563,9 @@ function generate_graph_js_state($args)
|
||||
{
|
||||
// we are going to assume we know roughly what the graph url looks like here.
|
||||
// TODO: Add sensible defaults
|
||||
$from = (is_numeric($args['from']) ? $args['from'] : 0);
|
||||
$to = (is_numeric($args['to']) ? $args['to'] : 0);
|
||||
$width = (is_numeric($args['width']) ? $args['width'] : 0);
|
||||
$from = (is_numeric($args['from']) ? $args['from'] : 0);
|
||||
$to = (is_numeric($args['to']) ? $args['to'] : 0);
|
||||
$width = (is_numeric($args['width']) ? $args['width'] : 0);
|
||||
$height = (is_numeric($args['height']) ? $args['height'] : 0);
|
||||
$legend = str_replace("'", '', $args['legend']);
|
||||
|
||||
@@ -592,13 +592,13 @@ function print_percentage_bar($width, $height, $percent, $left_text, $left_colou
|
||||
}
|
||||
|
||||
$output = '
|
||||
<div class="container" style="width:'.$width.'px; height:'.$height.'px;">
|
||||
<div class="progress" style="min-width: 2em; background-color:#'.$right_background.'; height:'.$height.'px;">
|
||||
<div class="progress-bar" role="progressbar" aria-valuenow="'.$size_percent.'" aria-valuemin="0" aria-valuemax="100" style="min-width: 2em; width:'.$size_percent.'%; background-color: #'.$left_background.';">
|
||||
<div class="container" style="width:' . $width . 'px; height:' . $height . 'px;">
|
||||
<div class="progress" style="min-width: 2em; background-color:#' . $right_background . '; height:' . $height . 'px;">
|
||||
<div class="progress-bar" role="progressbar" aria-valuenow="' . $size_percent . '" aria-valuemin="0" aria-valuemax="100" style="min-width: 2em; width:' . $size_percent . '%; background-color: #' . $left_background . ';">
|
||||
</div>
|
||||
</div>
|
||||
<b class="pull-left" style="padding-left: 4px; height: '.$height.'px;margin-top:-'.($height * 2).'px; color:#'.$left_colour.';">'.$left_text.'</b>
|
||||
<b class="pull-right" style="padding-right: 4px; height: '.$height.'px;margin-top:-'.($height * 2).'px; color:#'.$right_colour.';">'.$right_text.'</b>
|
||||
<b class="pull-left" style="padding-left: 4px; height: ' . $height . 'px;margin-top:-' . ($height * 2) . 'px; color:#' . $left_colour . ';">' . $left_text . '</b>
|
||||
<b class="pull-right" style="padding-right: 4px; height: ' . $height . 'px;margin-top:-' . ($height * 2) . 'px; color:#' . $right_colour . ';">' . $right_text . '</b>
|
||||
</div>
|
||||
';
|
||||
|
||||
@@ -628,7 +628,7 @@ function generate_entity_link($type, $entity, $text = null, $graph_type = null)
|
||||
break;
|
||||
|
||||
default:
|
||||
$link = $entity[$type.'_id'];
|
||||
$link = $entity[$type . '_id'];
|
||||
}
|
||||
|
||||
return ($link);
|
||||
@@ -659,27 +659,27 @@ function generate_port_link($port, $text = null, $type = null, $overlib = 1, $si
|
||||
$port = array_merge($port, device_by_id_cache($port['device_id']));
|
||||
}
|
||||
|
||||
$content = '<div class=list-large>'.$port['hostname'].' - '.fixifName(addslashes(display($port['label']))).'</div>';
|
||||
$content = '<div class=list-large>' . $port['hostname'] . ' - ' . fixifName(addslashes(display($port['label']))) . '</div>';
|
||||
if ($port['ifAlias']) {
|
||||
$content .= addslashes(display($port['ifAlias'])).'<br />';
|
||||
$content .= addslashes(display($port['ifAlias'])) . '<br />';
|
||||
}
|
||||
|
||||
$content .= "<div style=\'width: 850px\'>";
|
||||
$graph_array['type'] = $port['graph_type'];
|
||||
$content .= "<div style=\'width: 850px\'>";
|
||||
$graph_array['type'] = $port['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'] = $port['port_id'];
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$graph_array['width'] = '340';
|
||||
$graph_array['to'] = $config['time']['now'];
|
||||
$graph_array['from'] = $config['time']['day'];
|
||||
$graph_array['id'] = $port['port_id'];
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
if ($single_graph == 0) {
|
||||
$graph_array['from'] = $config['time']['week'];
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$graph_array['from'] = $config['time']['month'];
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$graph_array['from'] = $config['time']['year'];
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
}
|
||||
|
||||
$content .= '</div>';
|
||||
@@ -720,7 +720,7 @@ function generate_port_image($args)
|
||||
$args['bg'] = 'FFFFFF00';
|
||||
}
|
||||
|
||||
return "<img src='graph.php?type=".$args['graph_type'].'&id='.$args['port_id'].'&from='.$args['from'].'&to='.$args['to'].'&width='.$args['width'].'&height='.$args['height'].'&bg='.$args['bg']."'>";
|
||||
return "<img src='graph.php?type=" . $args['graph_type'] . '&id=' . $args['port_id'] . '&from=' . $args['from'] . '&to=' . $args['to'] . '&width=' . $args['width'] . '&height=' . $args['height'] . '&bg=' . $args['bg'] . "'>";
|
||||
}//end generate_port_image()
|
||||
|
||||
|
||||
@@ -728,10 +728,10 @@ function generate_port_thumbnail($port)
|
||||
{
|
||||
global $config;
|
||||
$port['graph_type'] = 'port_bits';
|
||||
$port['from'] = $config['time']['day'];
|
||||
$port['to'] = $config['time']['now'];
|
||||
$port['width'] = 150;
|
||||
$port['height'] = 21;
|
||||
$port['from'] = $config['time']['day'];
|
||||
$port['to'] = $config['time']['now'];
|
||||
$port['width'] = 150;
|
||||
$port['height'] = 21;
|
||||
return generate_port_image($port);
|
||||
}//end generate_port_thumbnail()
|
||||
|
||||
@@ -758,7 +758,7 @@ function print_optionbar_end()
|
||||
|
||||
function overlibprint($text)
|
||||
{
|
||||
return "onmouseover=\"return overlib('".$text."');\" onmouseout=\"return nd();\"";
|
||||
return "onmouseover=\"return overlib('" . $text . "');\" onmouseout=\"return nd();\"";
|
||||
}//end overlibprint()
|
||||
|
||||
|
||||
@@ -806,7 +806,7 @@ function devclass($device)
|
||||
|
||||
function getlocations()
|
||||
{
|
||||
$locations = array();
|
||||
$locations = array();
|
||||
|
||||
// Fetch regular locations
|
||||
if ($_SESSION['userlevel'] >= '5') {
|
||||
@@ -831,18 +831,18 @@ function getlocations()
|
||||
|
||||
function foldersize($path)
|
||||
{
|
||||
$total_size = 0;
|
||||
$files = scandir($path);
|
||||
$total_size = 0;
|
||||
$files = scandir($path);
|
||||
$total_files = 0;
|
||||
|
||||
foreach ($files as $t) {
|
||||
if (is_dir(rtrim($path, '/').'/'.$t)) {
|
||||
if (is_dir(rtrim($path, '/') . '/' . $t)) {
|
||||
if ($t <> '.' && $t <> '..') {
|
||||
$size = foldersize(rtrim($path, '/').'/'.$t);
|
||||
$size = foldersize(rtrim($path, '/') . '/' . $t);
|
||||
$total_size += $size;
|
||||
}
|
||||
} else {
|
||||
$size = filesize(rtrim($path, '/').'/'.$t);
|
||||
$size = filesize(rtrim($path, '/') . '/' . $t);
|
||||
$total_size += $size;
|
||||
$total_files++;
|
||||
}
|
||||
@@ -876,28 +876,28 @@ function generate_ap_link($args, $text = null, $type = null)
|
||||
$args = array_merge($args, device_by_id_cache($args['device_id']));
|
||||
}
|
||||
|
||||
$content = '<div class=list-large>'.$args['text'].' - '.fixifName($args['label']).'</div>';
|
||||
$content = '<div class=list-large>' . $args['text'] . ' - ' . fixifName($args['label']) . '</div>';
|
||||
if ($args['ifAlias']) {
|
||||
$content .= display($args['ifAlias']).'<br />';
|
||||
$content .= display($args['ifAlias']) . '<br />';
|
||||
}
|
||||
|
||||
$content .= "<div style=\'width: 850px\'>";
|
||||
$graph_array = array();
|
||||
$graph_array['type'] = $args['graph_type'];
|
||||
$content .= "<div style=\'width: 850px\'>";
|
||||
$graph_array = array();
|
||||
$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>';
|
||||
$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'])) {
|
||||
@@ -916,7 +916,7 @@ function generate_ap_url($ap, $vars = array())
|
||||
function report_this_text($message)
|
||||
{
|
||||
global $config;
|
||||
return $message.'\nPlease report this to the '.$config['project_name'].' developers at '.$config['project_issues'].'\n';
|
||||
return $message . '\nPlease report this to the ' . $config['project_name'] . ' developers at ' . $config['project_issues'] . '\n';
|
||||
}//end report_this_text()
|
||||
|
||||
|
||||
@@ -955,13 +955,13 @@ function include_matching_files($dir, $match = '/\.php$/')
|
||||
|
||||
function generate_pagination($count, $limit, $page, $links = 2)
|
||||
{
|
||||
$end_page = ceil($count / $limit);
|
||||
$start = (($page - $links) > 0) ? ($page - $links) : 1;
|
||||
$end = (($page + $links) < $end_page) ? ($page + $links) : $end_page;
|
||||
$return = '<ul class="pagination">';
|
||||
$end_page = ceil($count / $limit);
|
||||
$start = (($page - $links) > 0) ? ($page - $links) : 1;
|
||||
$end = (($page + $links) < $end_page) ? ($page + $links) : $end_page;
|
||||
$return = '<ul class="pagination">';
|
||||
$link_class = ($page == 1) ? 'disabled' : '';
|
||||
$return .= "<li><a href='' onClick='changePage(1,event);'>«</a></li>";
|
||||
$return .= "<li class='$link_class'><a href='' onClick='changePage($page - 1,event);'><</a></li>";
|
||||
$return .= "<li><a href='' onClick='changePage(1,event);'>«</a></li>";
|
||||
$return .= "<li class='$link_class'><a href='' onClick='changePage($page - 1,event);'><</a></li>";
|
||||
|
||||
if ($start > 1) {
|
||||
$return .= "<li><a href='' onClick='changePage(1,event);'>1</a></li>";
|
||||
@@ -970,7 +970,7 @@ function generate_pagination($count, $limit, $page, $links = 2)
|
||||
|
||||
for ($x = $start; $x <= $end; $x++) {
|
||||
$link_class = ($page == $x) ? 'active' : '';
|
||||
$return .= "<li class='$link_class'><a href='' onClick='changePage($x,event);'>$x </a></li>";
|
||||
$return .= "<li class='$link_class'><a href='' onClick='changePage($x,event);'>$x </a></li>";
|
||||
}
|
||||
|
||||
if ($end < $end_page) {
|
||||
@@ -979,9 +979,9 @@ function generate_pagination($count, $limit, $page, $links = 2)
|
||||
}
|
||||
|
||||
$link_class = ($page == $end_page) ? 'disabled' : '';
|
||||
$return .= "<li class='$link_class'><a href='' onClick='changePage($page + 1,event);'>></a></li>";
|
||||
$return .= "<li class='$link_class'><a href='' onClick='changePage($end_page,event);'>»</a></li>";
|
||||
$return .= '</ul>';
|
||||
$return .= "<li class='$link_class'><a href='' onClick='changePage($page + 1,event);'>></a></li>";
|
||||
$return .= "<li class='$link_class'><a href='' onClick='changePage($end_page,event);'>»</a></li>";
|
||||
$return .= '</ul>';
|
||||
return ($return);
|
||||
}//end generate_pagination()
|
||||
|
||||
@@ -1099,11 +1099,11 @@ function get_config_by_group($group)
|
||||
foreach (dbFetchRows("SELECT * FROM `config` WHERE `config_group` = '?'", array($group)) as $config_item) {
|
||||
$val = $config_item['config_value'];
|
||||
if (filter_var($val, FILTER_VALIDATE_INT)) {
|
||||
$val = (int) $val;
|
||||
$val = (int)$val;
|
||||
} elseif (filter_var($val, FILTER_VALIDATE_FLOAT)) {
|
||||
$val = (float) $val;
|
||||
$val = (float)$val;
|
||||
} elseif (filter_var($val, FILTER_VALIDATE_BOOLEAN)) {
|
||||
$val = (boolean) $val;
|
||||
$val = (boolean)$val;
|
||||
}
|
||||
|
||||
if ($val === true) {
|
||||
@@ -1119,7 +1119,7 @@ function get_config_by_group($group)
|
||||
|
||||
function get_config_like_name($name)
|
||||
{
|
||||
$name = array($name);
|
||||
$name = array($name);
|
||||
$items = array();
|
||||
foreach (dbFetchRows("SELECT * FROM `config` WHERE `config_name` LIKE '%?%'", array($name)) as $config_item) {
|
||||
$items[$config_item['config_id']] = $config_item;
|
||||
@@ -1163,31 +1163,31 @@ function alert_details($details)
|
||||
|
||||
$fault_detail = '';
|
||||
foreach ($details['rule'] as $o => $tmp_alerts) {
|
||||
$fallback = true;
|
||||
$fault_detail .= '#'.($o + 1).': ';
|
||||
$fallback = true;
|
||||
$fault_detail .= '#' . ($o + 1) . ': ';
|
||||
if ($tmp_alerts['bill_id']) {
|
||||
$fault_detail .= '<a href="'.generate_bill_url($tmp_alerts).'">'.$tmp_alerts['bill_name'].'</a>; ';
|
||||
$fallback = false;
|
||||
$fault_detail .= '<a href="' . generate_bill_url($tmp_alerts) . '">' . $tmp_alerts['bill_name'] . '</a>; ';
|
||||
$fallback = false;
|
||||
}
|
||||
|
||||
if ($tmp_alerts['port_id']) {
|
||||
$tmp_alerts = cleanPort($tmp_alerts);
|
||||
$fault_detail .= generate_port_link($tmp_alerts).'; ';
|
||||
$fallback = false;
|
||||
$fault_detail .= generate_port_link($tmp_alerts) . '; ';
|
||||
$fallback = false;
|
||||
}
|
||||
|
||||
if ($tmp_alerts['accesspoint_id']) {
|
||||
$fault_detail .= generate_ap_link($tmp_alerts, $tmp_alerts['name']) . '; ';
|
||||
$fallback = false;
|
||||
$fallback = false;
|
||||
}
|
||||
|
||||
if ($tmp_alerts['type'] && $tmp_alerts['label']) {
|
||||
if ($tmp_alerts['error'] == "") {
|
||||
$fault_detail .= ' '.$tmp_alerts['type'].' - '.$tmp_alerts['label'].'; ';
|
||||
$fault_detail .= ' ' . $tmp_alerts['type'] . ' - ' . $tmp_alerts['label'] . '; ';
|
||||
} else {
|
||||
$fault_detail .= ' '.$tmp_alerts['type'].' - '.$tmp_alerts['label'].' - '.$tmp_alerts['error'].'; ';
|
||||
$fault_detail .= ' ' . $tmp_alerts['type'] . ' - ' . $tmp_alerts['label'] . ' - ' . $tmp_alerts['error'] . '; ';
|
||||
}
|
||||
$fallback = false;
|
||||
$fallback = false;
|
||||
}
|
||||
|
||||
if ($fallback === true) {
|
||||
@@ -1215,9 +1215,9 @@ function dynamic_override_config($type, $name, $device)
|
||||
$checked = '';
|
||||
}
|
||||
if ($type == 'checkbox') {
|
||||
return '<input type="checkbox" id="override_config" name="override_config" data-attrib="'.$name.'" data-device_id="'.$device['device_id'].'" data-size="small" '.$checked.'>';
|
||||
return '<input type="checkbox" id="override_config" name="override_config" data-attrib="' . $name . '" data-device_id="' . $device['device_id'] . '" data-size="small" ' . $checked . '>';
|
||||
} elseif ($type == 'text') {
|
||||
return '<input type="text" id="override_config_text" name="override_config_text" data-attrib="'.$name.'" data-device_id="'.$device['device_id'].'" value="'.$attrib_val.'">';
|
||||
return '<input type="text" id="override_config_text" name="override_config_text" data-attrib="' . $name . '" data-device_id="' . $device['device_id'] . '" value="' . $attrib_val . '">';
|
||||
}
|
||||
}//end dynamic_override_config()
|
||||
|
||||
@@ -1228,15 +1228,15 @@ function generate_dynamic_config_panel($title, $config_groups, $items = array(),
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">
|
||||
<a data-toggle="collapse" data-parent="#accordion" href="#'.$anchor.'"><i class="fa fa-caret-down"></i> '.$title.'</a>
|
||||
<a data-toggle="collapse" data-parent="#accordion" href="#' . $anchor . '"><i class="fa fa-caret-down"></i> ' . $title . '</a>
|
||||
';
|
||||
if (!empty($transport)) {
|
||||
$output .= '<button name="test-alert" id="test-alert" type="button" data-transport="'.$transport.'" class="btn btn-primary btn-xs pull-right">Test transport</button>';
|
||||
$output .= '<button name="test-alert" id="test-alert" type="button" data-transport="' . $transport . '" class="btn btn-primary btn-xs pull-right">Test transport</button>';
|
||||
}
|
||||
$output .= '
|
||||
</h4>
|
||||
</div>
|
||||
<div id="'.$anchor.'" class="panel-collapse collapse">
|
||||
<div id="' . $anchor . '" class="panel-collapse collapse">
|
||||
<div class="panel-body">
|
||||
';
|
||||
|
||||
@@ -1244,30 +1244,30 @@ function generate_dynamic_config_panel($title, $config_groups, $items = array(),
|
||||
foreach ($items as $item) {
|
||||
$output .= '
|
||||
<div class="form-group has-feedback">
|
||||
<label for="'.$item['name'].'"" class="col-sm-4 control-label">'.$item['descr'].' </label>
|
||||
<div data-toggle="tooltip" title="'.$config_groups[$item['name']]['config_descr'].'" class="toolTip fa fa-fw fa-lg fa-question-circle"></div>
|
||||
<label for="' . $item['name'] . '"" class="col-sm-4 control-label">' . $item['descr'] . ' </label>
|
||||
<div data-toggle="tooltip" title="' . $config_groups[$item['name']]['config_descr'] . '" class="toolTip fa fa-fw fa-lg fa-question-circle"></div>
|
||||
<div class="col-sm-4">
|
||||
';
|
||||
if ($item['type'] == 'checkbox') {
|
||||
$output .= '<input id="'.$item['name'].'" type="checkbox" name="global-config-check" '.$config_groups[$item['name']]['config_checked'].' data-on-text="Yes" data-off-text="No" data-size="small" data-config_id="'.$config_groups[$item['name']]['config_id'].'">';
|
||||
$output .= '<input id="' . $item['name'] . '" type="checkbox" name="global-config-check" ' . $config_groups[$item['name']]['config_checked'] . ' data-on-text="Yes" data-off-text="No" data-size="small" data-config_id="' . $config_groups[$item['name']]['config_id'] . '">';
|
||||
} elseif ($item['type'] == 'text') {
|
||||
$output .= '
|
||||
<input id="'.$item['name'].'" class="form-control" type="text" name="global-config-input" value="'.$config_groups[$item['name']]['config_value'].'" data-config_id="'.$config_groups[$item['name']]['config_id'].'">
|
||||
<input id="' . $item['name'] . '" class="form-control" type="text" name="global-config-input" value="' . $config_groups[$item['name']]['config_value'] . '" data-config_id="' . $config_groups[$item['name']]['config_id'] . '">
|
||||
<span class="form-control-feedback"><i class="fa" aria-hidden="true"></i></span>
|
||||
';
|
||||
} elseif ($item['type'] == 'password') {
|
||||
$output .= '
|
||||
<input id="'.$item['name'].'" class="form-control" type="password" name="global-config-input" value="'.$config_groups[$item['name']]['config_value'].'" data-config_id="'.$config_groups[$item['name']]['config_id'].'">
|
||||
<input id="' . $item['name'] . '" class="form-control" type="password" name="global-config-input" value="' . $config_groups[$item['name']]['config_value'] . '" data-config_id="' . $config_groups[$item['name']]['config_id'] . '">
|
||||
<span class="form-control-feedback"><i class="fa" aria-hidden="true"></i></span>
|
||||
';
|
||||
} elseif ($item['type'] == 'numeric') {
|
||||
$output .= '
|
||||
<input id="'.$item['name'].'" class="form-control" onkeypress="return (event.charCode == 8 || event.charCode == 0) ? null : event.charCode >= 48 && event.charCode <= 57" type="text" name="global-config-input" value="'.$config_groups[$item['name']]['config_value'].'" data-config_id="'.$config_groups[$item['name']]['config_id'].'">
|
||||
<input id="' . $item['name'] . '" class="form-control" onkeypress="return (event.charCode == 8 || event.charCode == 0) ? null : event.charCode >= 48 && event.charCode <= 57" type="text" name="global-config-input" value="' . $config_groups[$item['name']]['config_value'] . '" data-config_id="' . $config_groups[$item['name']]['config_id'] . '">
|
||||
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
|
||||
';
|
||||
} elseif ($item['type'] == 'select') {
|
||||
$output .= '
|
||||
<select id="'.$config_groups[$item['name']]['name'].'" class="form-control" name="global-config-select" data-config_id="'.$config_groups[$item['name']]['config_id'].'">
|
||||
<select id="' . $config_groups[$item['name']]['name'] . '" class="form-control" name="global-config-select" data-config_id="' . $config_groups[$item['name']]['config_id'] . '">
|
||||
';
|
||||
if (!empty($item['options'])) {
|
||||
foreach ($item['options'] as $option) {
|
||||
@@ -1279,14 +1279,14 @@ function generate_dynamic_config_panel($title, $config_groups, $items = array(),
|
||||
'description' => $tmp_opt,
|
||||
);
|
||||
}
|
||||
$output .= '<option value="'.$option['value'].'"';
|
||||
$output .= '<option value="' . $option['value'] . '"';
|
||||
if ($option['value'] == $config_groups[$item['name']]['config_value']) {
|
||||
$output .= ' selected';
|
||||
}
|
||||
$output .= '>'.$option['description'].'</option>';
|
||||
$output .= '>' . $option['description'] . '</option>';
|
||||
}
|
||||
}
|
||||
$output .='
|
||||
$output .= '
|
||||
</select>
|
||||
<span class="form-control-feedback"><i class="fa" aria-hidden="true"></i></span>
|
||||
';
|
||||
@@ -1310,7 +1310,7 @@ function generate_dynamic_config_panel($title, $config_groups, $items = array(),
|
||||
|
||||
function get_ripe_api_whois_data_json($ripe_data_param, $ripe_query_param)
|
||||
{
|
||||
$ripe_whois_url = 'https://stat.ripe.net/data/'. $ripe_data_param . '/data.json?resource=' . $ripe_query_param;
|
||||
$ripe_whois_url = 'https://stat.ripe.net/data/' . $ripe_data_param . '/data.json?resource=' . $ripe_query_param;
|
||||
return json_decode(file_get_contents($ripe_whois_url), true);
|
||||
}//end get_ripe_api_whois_data_json()
|
||||
|
||||
@@ -1336,11 +1336,11 @@ function get_ports_from_type($given_types)
|
||||
# entry in config.
|
||||
$search_types = array();
|
||||
foreach ($given_types as $type) {
|
||||
if (isset($config[$type.'_descr']) === true) {
|
||||
if (is_array($config[$type.'_descr']) === true) {
|
||||
$search_types = array_merge($search_types, $config[$type.'_descr']);
|
||||
if (isset($config[$type . '_descr']) === true) {
|
||||
if (is_array($config[$type . '_descr']) === true) {
|
||||
$search_types = array_merge($search_types, $config[$type . '_descr']);
|
||||
} else {
|
||||
$search_types[] = $config[$type.'_descr'];
|
||||
$search_types[] = $config[$type . '_descr'];
|
||||
}
|
||||
} else {
|
||||
$search_types[] = $type;
|
||||
@@ -1356,13 +1356,13 @@ function get_ports_from_type($given_types)
|
||||
|
||||
foreach ($search_types as $type) {
|
||||
if (!empty($type)) {
|
||||
$type = strtr($type, '@', '%');
|
||||
$type_where .= " $or `port_descr_type` LIKE ?";
|
||||
$or = 'OR';
|
||||
$type_param[] = $type;
|
||||
$type = strtr($type, '@', '%');
|
||||
$type_where .= " $or `port_descr_type` LIKE ?";
|
||||
$or = 'OR';
|
||||
$type_param[] = $type;
|
||||
}
|
||||
}
|
||||
$type_where .= ') ';
|
||||
$type_where .= ') ';
|
||||
|
||||
# Run the query with the generated 'where' and necessary parameters, and send it back.
|
||||
$ports = dbFetchRows("SELECT * FROM `ports` as I, `devices` AS D WHERE $type_where AND I.device_id = D.device_id ORDER BY I.ifAlias", $type_param);
|
||||
@@ -1404,12 +1404,12 @@ function search_oxidized_config($search_in_conf_textbox)
|
||||
);
|
||||
$opts = array('http' =>
|
||||
array(
|
||||
'method' => 'POST',
|
||||
'header' => 'Content-type: application/x-www-form-urlencoded',
|
||||
'method' => 'POST',
|
||||
'header' => 'Content-type: application/x-www-form-urlencoded',
|
||||
'content' => $postdata
|
||||
)
|
||||
);
|
||||
$context = stream_context_create($opts);
|
||||
$context = stream_context_create($opts);
|
||||
return json_decode(file_get_contents($oxidized_search_url, false, $context), true);
|
||||
}
|
||||
|
||||
@@ -1518,14 +1518,14 @@ function get_disks($device)
|
||||
*/
|
||||
function get_fail2ban_jails($device_id)
|
||||
{
|
||||
$options=array(
|
||||
$options = array(
|
||||
'filter' => array(
|
||||
'type' => array('=', 'fail2ban'),
|
||||
),
|
||||
);
|
||||
|
||||
$component=new LibreNMS\Component();
|
||||
$f2bc=$component->getComponents($device_id, $options);
|
||||
$component = new LibreNMS\Component();
|
||||
$f2bc = $component->getComponents($device_id, $options);
|
||||
|
||||
if (isset($f2bc[$device_id])) {
|
||||
$id = $component->getFirstComponentID($f2bc, $device_id);
|
||||
@@ -1543,14 +1543,14 @@ function get_fail2ban_jails($device_id)
|
||||
*/
|
||||
function get_postgres_databases($device_id)
|
||||
{
|
||||
$options=array(
|
||||
$options = array(
|
||||
'filter' => array(
|
||||
'type' => array('=', 'postgres'),
|
||||
'type' => array('=', 'postgres'),
|
||||
),
|
||||
);
|
||||
|
||||
$component=new LibreNMS\Component();
|
||||
$pgc=$component->getComponents($device_id, $options);
|
||||
$component = new LibreNMS\Component();
|
||||
$pgc = $component->getComponents($device_id, $options);
|
||||
|
||||
if (isset($pgc[$device_id])) {
|
||||
$id = $component->getFirstComponentID($pgc, $device_id);
|
||||
@@ -1563,14 +1563,14 @@ function get_postgres_databases($device_id)
|
||||
// takes the device array and app_id
|
||||
function get_disks_with_smart($device, $app_id)
|
||||
{
|
||||
$all_disks=get_disks($device['device_id']);
|
||||
$disks=array();
|
||||
$all_disks_int=0;
|
||||
$all_disks = get_disks($device['device_id']);
|
||||
$disks = array();
|
||||
$all_disks_int = 0;
|
||||
while (isset($all_disks[$all_disks_int])) {
|
||||
$disk=$all_disks[$all_disks_int]['diskio_descr'];
|
||||
$disk = $all_disks[$all_disks_int]['diskio_descr'];
|
||||
$rrd_filename = rrd_name($device['hostname'], array('app', 'smart', $app_id, $disk));
|
||||
if (rrdtool_check_rrd_exists($rrd_filename)) {
|
||||
$disks[]=$disk;
|
||||
$disks[] = $disk;
|
||||
}
|
||||
$all_disks_int++;
|
||||
}
|
||||
@@ -1639,3 +1639,21 @@ function generate_fill_select_js($list_type, $selector, $selected = null)
|
||||
});
|
||||
});';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return stacked graphs information
|
||||
*
|
||||
* @param string $transparency value of desired transparency applied to rrdtool options (values 01 - 99)
|
||||
* @return array containing transparency and stacked setup
|
||||
*/
|
||||
|
||||
use LibreNMS\Config;
|
||||
|
||||
function generate_stacked_graphs($transparency = '88')
|
||||
{
|
||||
if (Config::get('webui.graph_stacked') == true) {
|
||||
return array('transparency' => $transparency, 'stacked' => '1');
|
||||
} else {
|
||||
return array('transparency' => '', 'stacked' => '-1');
|
||||
}
|
||||
}
|
||||
|
@@ -43,7 +43,7 @@ $units = 'b';
|
||||
$total_units = 'B';
|
||||
$colours_in = 'greens';
|
||||
$multiplier = '8';
|
||||
$colours_out = 'blues';
|
||||
$colours_out = 'purples';
|
||||
|
||||
// $nototal = 1;
|
||||
$ds_in = 'INOCTETS';
|
||||
|
@@ -1,122 +1,127 @@
|
||||
<?php
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version. Please see LICENSE.txt at the top level of
|
||||
* the source code distribution for details.
|
||||
*
|
||||
* @package LibreNMS
|
||||
* @subpackage graphs
|
||||
* @link http://librenms.org
|
||||
* @copyright 2017 LibreNMS
|
||||
* @author LibreNMS Contributors
|
||||
*/
|
||||
|
||||
// Draw generic bits graph
|
||||
// args: ds_in, ds_out, rrd_filename, bg, legend, from, to, width, height, inverse, previous
|
||||
require 'includes/graphs/common.inc.php';
|
||||
|
||||
$stacked = generate_stacked_graphs();
|
||||
|
||||
if ($rrd_filename) {
|
||||
$rrd_filename_out = $rrd_filename;
|
||||
$rrd_filename_in = $rrd_filename;
|
||||
$rrd_filename_in = $rrd_filename;
|
||||
}
|
||||
|
||||
if ($inverse) {
|
||||
$in = 'out';
|
||||
$in = 'out';
|
||||
$out = 'in';
|
||||
} else {
|
||||
$in = 'in';
|
||||
$in = 'in';
|
||||
$out = 'out';
|
||||
}
|
||||
|
||||
if ($multiplier) {
|
||||
$rrd_options .= ' DEF:p'.$out.'octets='.$rrd_filename_out.':'.$ds_out.':AVERAGE';
|
||||
$rrd_options .= ' DEF:p'.$in.'octets='.$rrd_filename_in.':'.$ds_in.':AVERAGE';
|
||||
$rrd_options .= ' DEF:p'.$out.'octets_max='.$rrd_filename_out.':'.$ds_out.':MAX';
|
||||
$rrd_options .= ' DEF:p'.$in.'octets_max='.$rrd_filename_in.':'.$ds_in.':MAX';
|
||||
$rrd_options .= ' DEF:p' . $out . 'octets=' . $rrd_filename_out . ':' . $ds_out . ':AVERAGE';
|
||||
$rrd_options .= ' DEF:p' . $in . 'octets=' . $rrd_filename_in . ':' . $ds_in . ':AVERAGE';
|
||||
$rrd_options .= ' DEF:p' . $out . 'octets_max=' . $rrd_filename_out . ':' . $ds_out . ':MAX';
|
||||
$rrd_options .= ' DEF:p' . $in . 'octets_max=' . $rrd_filename_in . ':' . $ds_in . ':MAX';
|
||||
$rrd_options .= " CDEF:inoctets=pinoctets,$multiplier,*";
|
||||
$rrd_options .= " CDEF:outoctets=poutoctets,$multiplier,*";
|
||||
$rrd_options .= " CDEF:inoctets_max=pinoctets_max,$multiplier,*";
|
||||
$rrd_options .= " CDEF:outoctets_max=poutoctets_max,$multiplier,*";
|
||||
} else {
|
||||
$rrd_options .= ' DEF:'.$out.'octets='.$rrd_filename_out.':'.$ds_out.':AVERAGE';
|
||||
$rrd_options .= ' DEF:'.$in.'octets='.$rrd_filename_in.':'.$ds_in.':AVERAGE';
|
||||
$rrd_options .= ' DEF:'.$out.'octets_max='.$rrd_filename_out.':'.$ds_out.':MAX';
|
||||
$rrd_options .= ' DEF:'.$in.'octets_max='.$rrd_filename_in.':'.$ds_in.':MAX';
|
||||
$rrd_options .= ' DEF:' . $out . 'octets=' . $rrd_filename_out . ':' . $ds_out . ':AVERAGE';
|
||||
$rrd_options .= ' DEF:' . $in . 'octets=' . $rrd_filename_in . ':' . $ds_in . ':AVERAGE';
|
||||
$rrd_options .= ' DEF:' . $out . 'octets_max=' . $rrd_filename_out . ':' . $ds_out . ':MAX';
|
||||
$rrd_options .= ' DEF:' . $in . 'octets_max=' . $rrd_filename_in . ':' . $ds_in . ':MAX';
|
||||
}
|
||||
|
||||
if ($_GET['previous'] == 'yes') {
|
||||
if ($multiplier) {
|
||||
$rrd_options .= ' DEF:p'.$out.'octetsX='.$rrd_filename_out.':'.$ds_out.':AVERAGE:start='.$prev_from.':end='.$from;
|
||||
$rrd_options .= ' DEF:p'.$in.'octetsX='.$rrd_filename_in.':'.$ds_in.':AVERAGE:start='.$prev_from.':end='.$from;
|
||||
$rrd_options .= ' SHIFT:p'.$out."octetsX:$period";
|
||||
$rrd_options .= ' SHIFT:p'.$in."octetsX:$period";
|
||||
$rrd_options .= ' DEF:p' . $out . 'octetsX=' . $rrd_filename_out . ':' . $ds_out . ':AVERAGE:start=' . $prev_from . ':end=' . $from;
|
||||
$rrd_options .= ' DEF:p' . $in . 'octetsX=' . $rrd_filename_in . ':' . $ds_in . ':AVERAGE:start=' . $prev_from . ':end=' . $from;
|
||||
$rrd_options .= ' SHIFT:p' . $out . "octetsX:$period";
|
||||
$rrd_options .= ' SHIFT:p' . $in . "octetsX:$period";
|
||||
$rrd_options .= " CDEF:inoctetsX=pinoctetsX,$multiplier,*";
|
||||
$rrd_options .= " CDEF:outoctetsX=poutoctetsX,$multiplier,*";
|
||||
} else {
|
||||
$rrd_options .= ' DEF:'.$out.'octetsX='.$rrd_filename_out.':'.$ds_out.':AVERAGE:start='.$prev_from.':end='.$from;
|
||||
$rrd_options .= ' DEF:'.$in.'octetsX='.$rrd_filename_in.':'.$ds_in.':AVERAGE:start='.$prev_from.':end='.$from;
|
||||
$rrd_options .= ' SHIFT:'.$out."octetsX:$period";
|
||||
$rrd_options .= ' SHIFT:'.$in."octetsX:$period";
|
||||
$rrd_options .= ' DEF:' . $out . 'octetsX=' . $rrd_filename_out . ':' . $ds_out . ':AVERAGE:start=' . $prev_from . ':end=' . $from;
|
||||
$rrd_options .= ' DEF:' . $in . 'octetsX=' . $rrd_filename_in . ':' . $ds_in . ':AVERAGE:start=' . $prev_from . ':end=' . $from;
|
||||
$rrd_options .= ' SHIFT:' . $out . "octetsX:$period";
|
||||
$rrd_options .= ' SHIFT:' . $in . "octetsX:$period";
|
||||
}
|
||||
|
||||
$rrd_options .= ' CDEF:octetsX=inoctetsX,outoctetsX,+';
|
||||
$rrd_options .= ' CDEF:doutoctetsX=outoctetsX,-1,*';
|
||||
$rrd_options .= ' CDEF:doutoctetsX=outoctetsX,' . $stacked['stacked'] . ',*';
|
||||
$rrd_options .= ' CDEF:outbitsX=outoctetsX,8,*';
|
||||
// $rrd_options .= " CDEF:outbits_maxX=outoctets_maxX,8,*";
|
||||
// $rrd_options .= " CDEF:doutoctets_maxX=outoctets_maxX,-1,*";
|
||||
$rrd_options .= ' CDEF:doutbitsX=doutoctetsX,8,*';
|
||||
// $rrd_options .= " CDEF:doutbits_maxX=doutoctets_maxX,8,*";
|
||||
$rrd_options .= ' CDEF:inbitsX=inoctetsX,8,*';
|
||||
// $rrd_options .= " CDEF:inbits_maxX=inoctets_maxX,8,*";
|
||||
$rrd_options .= ' VDEF:totinX=inoctetsX,TOTAL';
|
||||
$rrd_options .= ' VDEF:totoutX=outoctetsX,TOTAL';
|
||||
$rrd_options .= ' VDEF:totX=octetsX,TOTAL';
|
||||
}//end if
|
||||
}
|
||||
|
||||
$rrd_options .= ' CDEF:octets=inoctets,outoctets,+';
|
||||
$rrd_options .= ' CDEF:doutoctets=outoctets,-1,*';
|
||||
$rrd_options .= ' CDEF:doutoctets=outoctets,' . $stacked['stacked'] . ',*';
|
||||
$rrd_options .= ' CDEF:outbits=outoctets,8,*';
|
||||
$rrd_options .= ' CDEF:outbits_max=outoctets_max,8,*';
|
||||
$rrd_options .= ' CDEF:doutoctets_max=outoctets_max,-1,*';
|
||||
$rrd_options .= ' CDEF:doutoctets_max=outoctets_max,' . $stacked['stacked'] . ',*';
|
||||
$rrd_options .= ' CDEF:doutbits=doutoctets,8,*';
|
||||
$rrd_options .= ' CDEF:doutbits_max=doutoctets_max,8,*';
|
||||
|
||||
$rrd_options .= ' CDEF:inbits=inoctets,8,*';
|
||||
$rrd_options .= ' CDEF:inbits_max=inoctets_max,8,*';
|
||||
|
||||
if ($config['rrdgraph_real_percentile']) {
|
||||
$rrd_options .= ' CDEF:highbits=inoctets,outoctets,MAX,8,*';
|
||||
$rrd_options .= ' VDEF:percentilehigh=highbits,'.$config['percentile_value'].',PERCENT';
|
||||
$rrd_options .= ' VDEF:percentilehigh=highbits,' . $config['percentile_value'] . ',PERCENT';
|
||||
}
|
||||
|
||||
$rrd_options .= ' VDEF:totin=inoctets,TOTAL';
|
||||
$rrd_options .= ' VDEF:totout=outoctets,TOTAL';
|
||||
$rrd_options .= ' VDEF:tot=octets,TOTAL';
|
||||
|
||||
$rrd_options .= ' CDEF:dpercentile_outn=doutbits,-1,*';
|
||||
$rrd_options .= ' VDEF:dpercentile_outnp=dpercentile_outn,'.$config['percentile_value'].',PERCENT';
|
||||
$rrd_options .= ' CDEF:dpercentile_outnpn=doutbits,doutbits,-,dpercentile_outnp,-1,*,+';
|
||||
$rrd_options .= ' CDEF:dpercentile_outn=doutbits,' . $stacked['stacked'] . ',*';
|
||||
$rrd_options .= ' VDEF:dpercentile_outnp=dpercentile_outn,' . $config['percentile_value'] . ',PERCENT';
|
||||
$rrd_options .= ' CDEF:dpercentile_outnpn=doutbits,doutbits,-,dpercentile_outnp,' . $stacked['stacked'] . ',*,+';
|
||||
$rrd_options .= ' VDEF:dpercentile_out=dpercentile_outnpn,FIRST';
|
||||
|
||||
if ($format == 'octets' || $format == 'bytes') {
|
||||
$rrd_options .= ' VDEF:percentile_in=inoctets,'.$config['percentile_value'].',PERCENT';
|
||||
$rrd_options .= ' VDEF:percentile_out=outoctets,'.$config['percentile_value'].',PERCENT';
|
||||
$units = 'Bps';
|
||||
$rrd_options .= ' VDEF:percentile_in=inoctets,' . $config['percentile_value'] . ',PERCENT';
|
||||
$rrd_options .= ' VDEF:percentile_out=outoctets,' . $config['percentile_value'] . ',PERCENT';
|
||||
$units = 'Bps';
|
||||
$format = 'octets';
|
||||
} else {
|
||||
$rrd_options .= ' VDEF:percentile_in=inbits,'.$config['percentile_value'].',PERCENT';
|
||||
$rrd_options .= ' VDEF:percentile_out=outbits,'.$config['percentile_value'].',PERCENT';
|
||||
$units = 'bps';
|
||||
$rrd_options .= ' VDEF:percentile_in=inbits,' . $config['percentile_value'] . ',PERCENT';
|
||||
$rrd_options .= ' VDEF:percentile_out=outbits,' . $config['percentile_value'] . ',PERCENT';
|
||||
$units = 'bps';
|
||||
$format = 'bits';
|
||||
}
|
||||
|
||||
$rrd_options .= " COMMENT:'bps Now Ave Max ".$config['percentile_value']."th %\\n'";
|
||||
$rrd_options .= " COMMENT:'bps Now Ave Max " . $config['percentile_value'] . "th %\\n'";
|
||||
|
||||
$rrd_options .= ' AREA:in'.$format.'_max#D7FFC7:';
|
||||
$rrd_options .= ' AREA:in'.$format.'#90B040:';
|
||||
$rrd_options .= ' LINE:in'.$format."#608720:'In '";
|
||||
// $rrd_options .= " LINE1.25:in".$format."#006600:'In '";
|
||||
$rrd_options .= ' GPRINT:in'.$format.':LAST:%6.2lf%s';
|
||||
$rrd_options .= ' GPRINT:in'.$format.':AVERAGE:%6.2lf%s';
|
||||
$rrd_options .= ' GPRINT:in'.$format.'_max:MAX:%6.2lf%s';
|
||||
$rrd_options .= ' AREA:in' . $format . '_max#D7FFC7' . $stacked['transparency'] . ':';
|
||||
$rrd_options .= ' AREA:in' . $format . '#90B040' . $stacked['transparency'] . ':';
|
||||
$rrd_options .= ' LINE:in' . $format . "#608720:'In '";
|
||||
$rrd_options .= ' GPRINT:in' . $format . ':LAST:%6.2lf%s';
|
||||
$rrd_options .= ' GPRINT:in' . $format . ':AVERAGE:%6.2lf%s';
|
||||
$rrd_options .= ' GPRINT:in' . $format . '_max:MAX:%6.2lf%s';
|
||||
$rrd_options .= " GPRINT:percentile_in:%6.2lf%s\\n";
|
||||
|
||||
$rrd_options .= ' AREA:dout'.$format.'_max#E0E0FF:';
|
||||
$rrd_options .= ' AREA:dout'.$format.'#8080C0:';
|
||||
$rrd_options .= ' LINE:dout'.$format."#606090:'Out'";
|
||||
// $rrd_options .= " LINE1.25:dout".$format."#000099:Out";
|
||||
$rrd_options .= ' GPRINT:out'.$format.':LAST:%6.2lf%s';
|
||||
$rrd_options .= ' GPRINT:out'.$format.':AVERAGE:%6.2lf%s';
|
||||
$rrd_options .= ' GPRINT:out'.$format.'_max:MAX:%6.2lf%s';
|
||||
$rrd_options .= ' AREA:dout' . $format . '_max#E0E0FF' . $stacked['transparency'] . ':';
|
||||
$rrd_options .= ' AREA:dout' . $format . '#8080C0' . $stacked['transparency'] . ':';
|
||||
$rrd_options .= ' LINE:dout' . $format . "#606090:'Out'";
|
||||
$rrd_options .= ' GPRINT:out' . $format . ':LAST:%6.2lf%s';
|
||||
$rrd_options .= ' GPRINT:out' . $format . ':AVERAGE:%6.2lf%s';
|
||||
$rrd_options .= ' GPRINT:out' . $format . '_max:MAX:%6.2lf%s';
|
||||
$rrd_options .= " GPRINT:percentile_out:%6.2lf%s\\n";
|
||||
|
||||
if ($config['rrdgraph_real_percentile']) {
|
||||
@@ -131,6 +136,8 @@ $rrd_options .= ' LINE1:percentile_in#aa0000';
|
||||
$rrd_options .= ' LINE1:dpercentile_out#aa0000';
|
||||
|
||||
if ($_GET['previous'] == 'yes') {
|
||||
$rrd_options .= ' LINE1.25:in'.$format."X#009900:'Prev In \\\\n'";
|
||||
$rrd_options .= ' LINE1.25:dout'.$format."X#000099:'Prev Out'";
|
||||
$rrd_options .= ' LINE1.25:in' . $format . "X#009900:'Prev In \\\\n'";
|
||||
$rrd_options .= ' LINE1.25:dout' . $format . "X#000099:'Prev Out'";
|
||||
}
|
||||
|
||||
unset($stacked);
|
||||
|
@@ -1,9 +1,22 @@
|
||||
<?php
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version. Please see LICENSE.txt at the top level of
|
||||
* the source code distribution for details.
|
||||
*
|
||||
* @package LibreNMS
|
||||
* @subpackage graphs
|
||||
* @link http://librenms.org
|
||||
* @copyright 2017 LibreNMS
|
||||
* @author LibreNMS Contributors
|
||||
*/
|
||||
|
||||
// Draw generic bits graph
|
||||
// args: ds_in, ds_out, rrd_filename, bg, legend, from, to, width, height, inverse, $percentile
|
||||
require 'includes/graphs/common.inc.php';
|
||||
|
||||
$stacked = generate_stacked_graphs();
|
||||
|
||||
$length = '10';
|
||||
|
||||
if (!isset($percentile)) {
|
||||
@@ -19,15 +32,15 @@ if (!isset($in_text)) {
|
||||
}
|
||||
|
||||
$unit_text = str_pad(truncate($unit_text, $length), $length);
|
||||
$in_text = str_pad(truncate($in_text, $length), $length);
|
||||
$out_text = str_pad(truncate($out_text, $length), $length);
|
||||
$in_text = str_pad(truncate($in_text, $length), $length);
|
||||
$out_text = str_pad(truncate($out_text, $length), $length);
|
||||
|
||||
$rrd_options .= ' DEF:'.$out.'='.$rrd_filename.':'.$ds_out.':AVERAGE';
|
||||
$rrd_options .= ' DEF:'.$in.'='.$rrd_filename.':'.$ds_in.':AVERAGE';
|
||||
$rrd_options .= ' DEF:'.$out.'_max='.$rrd_filename.':'.$ds_out.':MAX';
|
||||
$rrd_options .= ' DEF:'.$in.'_max='.$rrd_filename.':'.$ds_in.':MAX';
|
||||
$rrd_options .= ' CDEF:dout_max=out_max,-1,*';
|
||||
$rrd_options .= ' CDEF:dout=out,-1,*';
|
||||
$rrd_options .= ' DEF:' . $out . '=' . $rrd_filename . ':' . $ds_out . ':AVERAGE';
|
||||
$rrd_options .= ' DEF:' . $in . '=' . $rrd_filename . ':' . $ds_in . ':AVERAGE';
|
||||
$rrd_options .= ' DEF:' . $out . '_max=' . $rrd_filename . ':' . $ds_out . ':MAX';
|
||||
$rrd_options .= ' DEF:' . $in . '_max=' . $rrd_filename . ':' . $ds_in . ':MAX';
|
||||
$rrd_options .= ' CDEF:dout_max=out_max,' . $stacked['stacked'] . ',*';
|
||||
$rrd_options .= ' CDEF:dout=out,' . $stacked['stacked'] . ',*';
|
||||
$rrd_options .= ' CDEF:both=in,out,+';
|
||||
if ($print_total) {
|
||||
$rrd_options .= ' VDEF:totin=in,TOTAL';
|
||||
@@ -36,27 +49,28 @@ if ($print_total) {
|
||||
}
|
||||
|
||||
if ($percentile) {
|
||||
$rrd_options .= ' VDEF:percentile_in=in,'.$percentile.',PERCENT';
|
||||
$rrd_options .= ' VDEF:percentile_out=out,'.$percentile.',PERCENT';
|
||||
$rrd_options .= ' VDEF:dpercentile_out=dout,'.$percentile.',PERCENT';
|
||||
$rrd_options .= ' VDEF:percentile_in=in,' . $percentile . ',PERCENT';
|
||||
$rrd_options .= ' VDEF:percentile_out=out,' . $percentile . ',PERCENT';
|
||||
$rrd_options .= ' VDEF:dpercentile_out=dout,' . $percentile . ',PERCENT';
|
||||
}
|
||||
|
||||
if ($graph_max) {
|
||||
$rrd_options .= ' AREA:in_max#'.$colour_area_in_max.':';
|
||||
$rrd_options .= ' AREA:dout_max#'.$colour_area_out_max.':';
|
||||
$rrd_options .= ' AREA:in_max#' . $colour_area_in_max . $stacked['transparency'] . ':';
|
||||
$rrd_options .= ' AREA:dout_max#' . $colour_area_out_max . $stacked['transparency'] . ':';
|
||||
}
|
||||
|
||||
if ($_GET['previous'] == 'yes') {
|
||||
$rrd_options .= ' DEF:'.$out.'X='.$rrd_filename.':'.$ds_out.':AVERAGE:start='.$prev_from.':end='.$from;
|
||||
$rrd_options .= ' DEF:'.$in.'X='.$rrd_filename.':'.$ds_in.':AVERAGE:start='.$prev_from.':end='.$from;
|
||||
$rrd_options .= ' DEF:'.$out.'_maxX='.$rrd_filename.':'.$ds_out.':MAX:start='.$prev_from.':end='.$from;
|
||||
$rrd_options .= ' DEF:'.$in.'_maxX='.$rrd_filename.':'.$ds_in.':MAX:start='.$prev_from.':end='.$from;
|
||||
$rrd_options .= ' SHIFT:'.$out."X:$period";
|
||||
$rrd_options .= ' SHIFT:'.$in."X:$period";
|
||||
$rrd_options .= ' SHIFT:'.$out."_maxX:$period";
|
||||
$rrd_options .= ' SHIFT:'.$in."_maxX:$period";
|
||||
$rrd_options .= ' CDEF:dout_maxX=out_maxX,-1,*';
|
||||
$rrd_options .= ' CDEF:doutX=outX,-1,*';
|
||||
$rrd_options .= ' DEF:' . $out . 'X=' . $rrd_filename . ':' . $ds_out . ':AVERAGE:start=' . $prev_from . ':end=' . $from;
|
||||
$rrd_options .= ' DEF:' . $in . 'X=' . $rrd_filename . ':' . $ds_in . ':AVERAGE:start=' . $prev_from . ':end=' . $from;
|
||||
$rrd_options .= ' DEF:' . $out . '_maxX=' . $rrd_filename . ':' . $ds_out . ':MAX:start=' . $prev_from . ':end=' . $from;
|
||||
$rrd_options .= ' DEF:' . $in . '_maxX=' . $rrd_filename . ':' . $ds_in . ':MAX:start=' . $prev_from . ':end=' . $from;
|
||||
$rrd_options .= ' SHIFT:' . $out . "X:$period";
|
||||
$rrd_options .= ' SHIFT:' . $in . "X:$period";
|
||||
$rrd_options .= ' SHIFT:' . $out . "_maxX:$period";
|
||||
$rrd_options .= ' SHIFT:' . $in . "_maxX:$period";
|
||||
|
||||
$rrd_options .= ' CDEF:dout_maxX=out_maxX,' . $stacked['stacked'] . ',*';
|
||||
$rrd_options .= ' CDEF:doutX=outX,' . $stacked['stacked'] . ',*';
|
||||
$rrd_options .= ' CDEF:bothX=inX,outX,+';
|
||||
if ($print_total) {
|
||||
$rrd_options .= ' VDEF:totinX=inX,TOTAL';
|
||||
@@ -65,26 +79,26 @@ if ($_GET['previous'] == 'yes') {
|
||||
}
|
||||
|
||||
if ($percentile) {
|
||||
$rrd_options .= ' VDEF:percentile_inX=inX,'.$percentile.',PERCENT';
|
||||
$rrd_options .= ' VDEF:percentile_outX=outX,'.$percentile.',PERCENT';
|
||||
$rrd_options .= ' VDEF:dpercentile_outX=doutX,'.$percentile.',PERCENT';
|
||||
$rrd_options .= ' VDEF:percentile_inX=inX,' . $percentile . ',PERCENT';
|
||||
$rrd_options .= ' VDEF:percentile_outX=outX,' . $percentile . ',PERCENT';
|
||||
$rrd_options .= ' VDEF:dpercentile_outX=doutX,' . $percentile . ',PERCENT';
|
||||
}
|
||||
|
||||
if ($graph_max) {
|
||||
$rrd_options .= ' AREA:in_max#'.$colour_area_in_max.':';
|
||||
$rrd_options .= ' AREA:dout_max#'.$colour_area_out_max.':';
|
||||
$rrd_options .= ' AREA:in_max#' . $colour_area_in_max . ':';
|
||||
$rrd_options .= ' AREA:dout_max#' . $colour_area_out_max . ':';
|
||||
}
|
||||
}//end if
|
||||
|
||||
$rrd_options .= ' AREA:in#'.$colour_area_in.':';
|
||||
$rrd_options .= " COMMENT:'".$unit_text.' Now Ave Max';
|
||||
$rrd_options .= ' AREA:in#' . $colour_area_in . $stacked['transparency'] . ':';
|
||||
$rrd_options .= " COMMENT:'" . $unit_text . ' Now Ave Max';
|
||||
|
||||
if ($percentile) {
|
||||
$rrd_options .= ' '.$percentile.'th %';
|
||||
$rrd_options .= ' ' . $percentile . 'th %';
|
||||
}
|
||||
|
||||
$rrd_options .= "\\n'";
|
||||
$rrd_options .= ' LINE1.25:in#'.$colour_line_in.":'".$in_text."'";
|
||||
$rrd_options .= ' LINE1.25:in#' . $colour_line_in . ":'" . $in_text . "'";
|
||||
$rrd_options .= ' GPRINT:in:LAST:%6.2lf%s';
|
||||
$rrd_options .= ' GPRINT:in:AVERAGE:%6.2lf%s';
|
||||
$rrd_options .= ' GPRINT:in_max:MAX:%6.2lf%s';
|
||||
@@ -94,8 +108,8 @@ if ($percentile) {
|
||||
}
|
||||
|
||||
$rrd_options .= " COMMENT:\\n";
|
||||
$rrd_options .= ' AREA:dout#'.$colour_area_out.':';
|
||||
$rrd_options .= ' LINE1.25:dout#'.$colour_line_out.":'".$out_text."'";
|
||||
$rrd_options .= ' AREA:dout#' . $colour_area_out . $stacked['transparency'] . ':';
|
||||
$rrd_options .= ' LINE1.25:dout#' . $colour_line_out . ":'" . $out_text . "'";
|
||||
$rrd_options .= ' GPRINT:out:LAST:%6.2lf%s';
|
||||
$rrd_options .= ' GPRINT:out:AVERAGE:%6.2lf%s';
|
||||
$rrd_options .= ' GPRINT:out_max:MAX:%6.2lf%s';
|
||||
@@ -118,10 +132,12 @@ if ($percentile) {
|
||||
}
|
||||
|
||||
if ($_GET['previous'] == 'yes') {
|
||||
$rrd_options .= ' LINE1.25:in'.$format."X#666666:'Prev In \\\\n'";
|
||||
$rrd_options .= ' AREA:in'.$format.'X#99999966:';
|
||||
$rrd_options .= ' LINE1.25:dout'.$format."X#666666:'Prev Out'";
|
||||
$rrd_options .= ' AREA:dout'.$format.'X#99999966:';
|
||||
$rrd_options .= ' LINE1.25:in' . $format . "X#666666:'Prev In \\\\n'";
|
||||
$rrd_options .= ' AREA:in' . $format . 'X#99999966' . $stacked['transparency'] . ':';
|
||||
$rrd_options .= ' LINE1.25:dout' . $format . "X#666666:'Prev Out'";
|
||||
$rrd_options .= ' AREA:dout' . $format . 'X#99999966' . $stacked['transparency'] . ':';
|
||||
}
|
||||
|
||||
$rrd_options .= ' HRULE:0#999999';
|
||||
|
||||
unset($stacked);
|
||||
|
@@ -1,52 +1,49 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Outputs a stacked, filled line graph
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version. Please see LICENSE.txt at the top level of
|
||||
* the source code distribution for details.
|
||||
*
|
||||
* Variables:
|
||||
* $rrd_list array required - array of data sets to graph. Each item is an array that contains the following
|
||||
* ds string required - data set name as defined in rrd
|
||||
* filename string required - path to the rrd file as generated by rrd_name()
|
||||
* descr string required - the label for this data set
|
||||
* colour string optional - Defines the colour for this data set (overrides the overall colour set)
|
||||
* invert boolean optional - multiplies values in this data set by -1
|
||||
* $colours string required - colour set as defined in $config['graph_colours']
|
||||
* $print_total boolean optional - Sum all the values and output the last, min, max, and avg in the legend
|
||||
* $simplerrd boolean optional - All data sets reside in the same rrd file
|
||||
*/
|
||||
* @package LibreNMS
|
||||
* @subpackage graphs
|
||||
* @link http://librenms.org
|
||||
* @copyright 2017 LibreNMS
|
||||
* @author LibreNMS Contributors
|
||||
*/
|
||||
|
||||
require 'includes/graphs/common.inc.php';
|
||||
|
||||
$stacked = generate_stacked_graphs();
|
||||
|
||||
if ($width > '500') {
|
||||
$descr_len = 24;
|
||||
} else {
|
||||
$descr_len = 12;
|
||||
# FIXME - Presently overflows graph
|
||||
#$descr_len += round(($width - 250) / 8);
|
||||
$descr_len = 12;
|
||||
}
|
||||
|
||||
if ($nototal) {
|
||||
$descr_len += '2';
|
||||
$unitlen += '2';
|
||||
$unitlen += '2';
|
||||
}
|
||||
|
||||
if ($width > '500') {
|
||||
$rrd_options .= " COMMENT:'".substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5))."Now Min Max Avg\l'";
|
||||
$rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5)) . "Now Min Max Avg\l'";
|
||||
if (!$nototal) {
|
||||
$rrd_options .= " COMMENT:'Total '";
|
||||
}
|
||||
|
||||
$rrd_options .= " COMMENT:'\l'";
|
||||
} else {
|
||||
$rrd_options .= " COMMENT:'".substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5))."Now Min Max Avg\l'";
|
||||
$rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5)) . "Now Min Max Avg\l'";
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
$i = 0;
|
||||
$iter = 0;
|
||||
$ids = array();
|
||||
|
||||
foreach ($rrd_list as $rrd) {
|
||||
// get the color for this data set
|
||||
if (isset($rrd['colour'])) {
|
||||
$colour = $rrd['colour'];
|
||||
} else {
|
||||
@@ -57,50 +54,47 @@ foreach ($rrd_list as $rrd) {
|
||||
$iter++;
|
||||
}
|
||||
|
||||
$ds = $rrd['ds'];
|
||||
$ds = $rrd['ds'];
|
||||
$filename = $rrd['filename'];
|
||||
|
||||
$descr = rrdtool_escape($rrd['descr'], $descr_len);
|
||||
|
||||
$ids[] = ($id = 'ds'.$i);
|
||||
$ids[] = ($id = 'ds' . $i);
|
||||
|
||||
$rrd_options .= ' DEF:'.$id."=$filename:$ds:AVERAGE";
|
||||
$rrd_options .= ' DEF:' . $id . "=$filename:$ds:AVERAGE";
|
||||
|
||||
if ($simple_rrd) {
|
||||
$rrd_options .= ' CDEF:'.$id.'min='.$id.' ';
|
||||
$rrd_options .= ' CDEF:'.$id.'max='.$id.' ';
|
||||
$rrd_options .= ' CDEF:' . $id . 'min=' . $id . ' ';
|
||||
$rrd_options .= ' CDEF:' . $id . 'max=' . $id . ' ';
|
||||
} else {
|
||||
$rrd_options .= ' DEF:'.$id."min=$filename:$ds:MIN";
|
||||
$rrd_options .= ' DEF:'.$id."max=$filename:$ds:MAX";
|
||||
$rrd_options .= ' DEF:' . $id . "min=$filename:$ds:MIN";
|
||||
$rrd_options .= ' DEF:' . $id . "max=$filename:$ds:MAX";
|
||||
}
|
||||
|
||||
if ($rrd['invert']) {
|
||||
$rrd_options .= ' CDEF:'.$id.'i='.$id.',-1,*';
|
||||
$rrd_optionsc .= ' AREA:'.$id.'i#'.$colour.":'$descr'".$cstack;
|
||||
$rrd_optionsc .= ' GPRINT:'.$id.':LAST:%5.1lf%s GPRINT:'.$id.'min:MIN:%5.1lf%s';
|
||||
$rrd_optionsc .= ' GPRINT:'.$id.'max:MAX:%5.1lf%s GPRINT:'.$id.":AVERAGE:'%5.1lf%s\\n'";
|
||||
$cstack = ':STACK';
|
||||
$rrd_options .= ' CDEF:' . $id . 'i=' . $id . ',' . $stacked['stacked'] . ',*';
|
||||
$rrd_optionsc .= ' AREA:' . $id . 'i#' . $colour . $stacked['transparency'] . ":'$descr'" . $cstack;
|
||||
$rrd_optionsc .= ' GPRINT:' . $id . ':LAST:%5.1lf%s GPRINT:' . $id . 'min:MIN:%5.1lf%s';
|
||||
$rrd_optionsc .= ' GPRINT:' . $id . 'max:MAX:%5.1lf%s GPRINT:' . $id . ":AVERAGE:'%5.1lf%s\\n'";
|
||||
$cstack = ':STACK';
|
||||
} else {
|
||||
$rrd_optionsb .= ' AREA:'.$id.'#'.$colour.":'$descr'".$bstack;
|
||||
$rrd_optionsb .= ' GPRINT:'.$id.':LAST:%5.1lf%s GPRINT:'.$id.'min:MIN:%5.1lf%s';
|
||||
$rrd_optionsb .= ' GPRINT:'.$id.'max:MAX:%5.1lf%s GPRINT:'.$id.":AVERAGE:'%5.1lf%s\\n'";
|
||||
$bstack = ':STACK';
|
||||
$rrd_optionsb .= ' AREA:' . $id . '#' . $colour . $stacked['transparency'] . ":'$descr'" . $bstack;
|
||||
$rrd_optionsb .= ' GPRINT:' . $id . ':LAST:%5.1lf%s GPRINT:' . $id . 'min:MIN:%5.1lf%s';
|
||||
$rrd_optionsb .= ' GPRINT:' . $id . 'max:MAX:%5.1lf%s GPRINT:' . $id . ":AVERAGE:'%5.1lf%s\\n'";
|
||||
$bstack = ':STACK';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$i++;
|
||||
}//end foreach
|
||||
}
|
||||
|
||||
if ($print_total) {
|
||||
$tot = $ids;
|
||||
for ($i=1; $i<count($ids); $i++) {
|
||||
for ($i = 1; $i < count($ids); $i++) {
|
||||
$tot[] = '+';
|
||||
}
|
||||
|
||||
$rrd_options .= ' CDEF:tot=' . implode($tot, ',');
|
||||
$rrd_options .= ' COMMENT:" '.rrdtool_escape('Total', $descr_len).'"';
|
||||
$rrd_options .= ' COMMENT:" ' . rrdtool_escape('Total', $descr_len) . '"';
|
||||
$rrd_options .= ' GPRINT:tot:LAST:%5.1lf%s';
|
||||
$rrd_options .= ' GPRINT:tot:MIN:%5.1lf%s';
|
||||
$rrd_options .= ' GPRINT:tot:MAX:%5.1lf%s';
|
||||
@@ -110,3 +104,5 @@ if ($print_total) {
|
||||
$rrd_options .= $rrd_optionsb;
|
||||
$rrd_options .= ' HRULE:0#555555';
|
||||
$rrd_options .= $rrd_optionsc;
|
||||
|
||||
unset($stacked);
|
||||
|
@@ -1,95 +1,108 @@
|
||||
<?php
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version. Please see LICENSE.txt at the top level of
|
||||
* the source code distribution for details.
|
||||
*
|
||||
* @package LibreNMS
|
||||
* @subpackage graphs
|
||||
* @link http://librenms.org
|
||||
* @copyright 2017 LibreNMS
|
||||
* @author LibreNMS Contributors
|
||||
*/
|
||||
|
||||
// Draws aggregate bits graph from multiple RRDs
|
||||
// Variables : colour_[line|area]_[in|out], rrd_filenames
|
||||
require 'includes/graphs/common.inc.php';
|
||||
|
||||
$stacked = generate_stacked_graphs();
|
||||
|
||||
$i = 0;
|
||||
|
||||
foreach ($rrd_filenames as $key => $rrd_filename) {
|
||||
if ($rrd_inverted[$key]) {
|
||||
$in = 'out';
|
||||
$in = 'out';
|
||||
$out = 'in';
|
||||
} else {
|
||||
$in = 'in';
|
||||
$in = 'in';
|
||||
$out = 'out';
|
||||
}
|
||||
|
||||
$rrd_options .= ' DEF:'.$in.'octets'.$i.'='.$rrd_filename.':'.$ds_in.':AVERAGE';
|
||||
$rrd_options .= ' DEF:'.$out.'octets'.$i.'='.$rrd_filename.':'.$ds_out.':AVERAGE';
|
||||
$in_thing .= $seperator.'inoctets'.$i.',UN,0,'.'inoctets'.$i.',IF';
|
||||
$out_thing .= $seperator.'outoctets'.$i.',UN,0,'.'outoctets'.$i.',IF';
|
||||
$pluses .= $plus;
|
||||
$seperator = ',';
|
||||
$plus = ',+';
|
||||
$rrd_options .= ' DEF:' . $in . 'octets' . $i . '=' . $rrd_filename . ':' . $ds_in . ':AVERAGE';
|
||||
$rrd_options .= ' DEF:' . $out . 'octets' . $i . '=' . $rrd_filename . ':' . $ds_out . ':AVERAGE';
|
||||
$in_thing .= $seperator . 'inoctets' . $i . ',UN,0,' . 'inoctets' . $i . ',IF';
|
||||
$out_thing .= $seperator . 'outoctets' . $i . ',UN,0,' . 'outoctets' . $i . ',IF';
|
||||
$pluses .= $plus;
|
||||
$seperator = ',';
|
||||
$plus = ',+';
|
||||
|
||||
if ($_GET['previous']) {
|
||||
$rrd_options .= ' DEF:'.$in.'octets'.$i.'X='.$rrd_filename.':'.$ds_in.':AVERAGE:start='.$prev_from.':end='.$from;
|
||||
$rrd_options .= ' DEF:'.$out.'octets'.$i.'X='.$rrd_filename.':'.$ds_out.':AVERAGE:start='.$prev_from.':end='.$from;
|
||||
$rrd_options .= ' SHIFT:'.$in.'octets'.$i."X:$period";
|
||||
$rrd_options .= ' SHIFT:'.$out.'octets'.$i."X:$period";
|
||||
$in_thingX .= $seperatorX.'inoctets'.$i.'X,UN,0,'.'inoctets'.$i.'X,IF';
|
||||
$out_thingX .= $seperatorX.'outoctets'.$i.'X,UN,0,'.'outoctets'.$i.'X,IF';
|
||||
$plusesX .= $plusX;
|
||||
$seperatorX = ',';
|
||||
$plusX = ',+';
|
||||
$rrd_options .= ' DEF:' . $in . 'octets' . $i . 'X=' . $rrd_filename . ':' . $ds_in . ':AVERAGE:start=' . $prev_from . ':end=' . $from;
|
||||
$rrd_options .= ' DEF:' . $out . 'octets' . $i . 'X=' . $rrd_filename . ':' . $ds_out . ':AVERAGE:start=' . $prev_from . ':end=' . $from;
|
||||
$rrd_options .= ' SHIFT:' . $in . 'octets' . $i . "X:$period";
|
||||
$rrd_options .= ' SHIFT:' . $out . 'octets' . $i . "X:$period";
|
||||
$in_thingX .= $seperatorX . 'inoctets' . $i . 'X,UN,0,' . 'inoctets' . $i . 'X,IF';
|
||||
$out_thingX .= $seperatorX . 'outoctets' . $i . 'X,UN,0,' . 'outoctets' . $i . 'X,IF';
|
||||
$plusesX .= $plusX;
|
||||
$seperatorX = ',';
|
||||
$plusX = ',+';
|
||||
}
|
||||
|
||||
$i++;
|
||||
}//end foreach
|
||||
}
|
||||
|
||||
if ($i) {
|
||||
if ($inverse) {
|
||||
$in = 'out';
|
||||
$in = 'out';
|
||||
$out = 'in';
|
||||
} else {
|
||||
$in = 'in';
|
||||
$in = 'in';
|
||||
$out = 'out';
|
||||
}
|
||||
|
||||
$rrd_options .= ' CDEF:'.$in.'octets='.$in_thing.$pluses;
|
||||
$rrd_options .= ' CDEF:'.$out.'octets='.$out_thing.$pluses;
|
||||
$rrd_options .= ' CDEF:doutoctets=outoctets,-1,*';
|
||||
$rrd_options .= ' CDEF:' . $in . 'octets=' . $in_thing . $pluses;
|
||||
$rrd_options .= ' CDEF:' . $out . 'octets=' . $out_thing . $pluses;
|
||||
$rrd_options .= ' CDEF:doutoctets=outoctets,' . $stacked['stacked'];
|
||||
$rrd_options .= ' CDEF:inbits=inoctets,8,*';
|
||||
$rrd_options .= ' CDEF:outbits=outoctets,8,*';
|
||||
$rrd_options .= ' CDEF:doutbits=doutoctets,8,*';
|
||||
$rrd_options .= ' VDEF:percentile_in=inbits,'.$config['percentile_value'].',PERCENT';
|
||||
$rrd_options .= ' VDEF:percentile_out=outbits,'.$config['percentile_value'].',PERCENT';
|
||||
$rrd_options .= ' CDEF:dpercentile_outn=doutbits,-1,*';
|
||||
$rrd_options .= ' VDEF:dpercentile_outnp=dpercentile_outn,'.$config['percentile_value'].',PERCENT';
|
||||
$rrd_options .= ' VDEF:percentile_in=inbits,' . $config['percentile_value'] . ',PERCENT';
|
||||
$rrd_options .= ' VDEF:percentile_out=outbits,' . $config['percentile_value'] . ',PERCENT';
|
||||
$rrd_options .= ' CDEF:dpercentile_outn=doutbits,' . $stacked['stacked'];
|
||||
$rrd_options .= ' VDEF:dpercentile_outnp=dpercentile_outn,' . $config['percentile_value'] . ',PERCENT';
|
||||
$rrd_options .= ' CDEF:dpercentile_outnpn=doutbits,doutbits,-,dpercentile_outnp,-1,*,+';
|
||||
$rrd_options .= ' VDEF:dpercentile_out=dpercentile_outnpn,FIRST';
|
||||
|
||||
if ($_GET['previous'] == 'yes') {
|
||||
$rrd_options .= ' CDEF:'.$in.'octetsX='.$in_thingX.$pluses;
|
||||
$rrd_options .= ' CDEF:'.$out.'octetsX='.$out_thingX.$pluses;
|
||||
$rrd_options .= ' CDEF:doutoctetsX=outoctetsX,-1,*';
|
||||
$rrd_options .= ' CDEF:' . $in . 'octetsX=' . $in_thingX . $pluses;
|
||||
$rrd_options .= ' CDEF:' . $out . 'octetsX=' . $out_thingX . $pluses;
|
||||
$rrd_options .= ' CDEF:doutoctetsX=outoctetsX,' . $stacked['stacked'] . ',*';
|
||||
$rrd_options .= ' CDEF:inbitsX=inoctetsX,8,*';
|
||||
$rrd_options .= ' CDEF:outbitsX=outoctetsX,8,*';
|
||||
$rrd_options .= ' CDEF:doutbitsX=doutoctetsX,8,*';
|
||||
$rrd_options .= ' VDEF:percentile_inX=inbitsX,'.$config['percentile_value'].',PERCENT';
|
||||
$rrd_options .= ' VDEF:percentile_outX=outbitsX,'.$config['percentile_value'].',PERCENT';
|
||||
$rrd_options .= ' CDEF:dpercentile_outXn=doutbitsX,-1,*';
|
||||
$rrd_options .= ' VDEF:dpercentile_outX=dpercentile_outXn,'.$config['percentile_value'].',PERCENT';
|
||||
$rrd_options .= ' CDEF:dpercentile_outXn=doutbitsX,doutbitsX,-,dpercentile_outX,-1,*,+';
|
||||
$rrd_options .= ' VDEF:percentile_inX=inbitsX,' . $config['percentile_value'] . ',PERCENT';
|
||||
$rrd_options .= ' VDEF:percentile_outX=outbitsX,' . $config['percentile_value'] . ',PERCENT';
|
||||
$rrd_options .= ' CDEF:dpercentile_outXn=doutbitsX,' . $stacked['stacked'] . ',*';
|
||||
$rrd_options .= ' VDEF:dpercentile_outX=dpercentile_outXn,' . $config['percentile_value'] . ',PERCENT';
|
||||
$rrd_options .= ' CDEF:dpercentile_outXn=doutbitsX,doutbitsX,-,dpercentile_outX,' . $stacked['stacked'] . ',*,+';
|
||||
$rrd_options .= ' VDEF:dpercentile_outX=dpercentile_outXn,FIRST';
|
||||
}
|
||||
|
||||
if ($legend == 'no' || $legend == '1') {
|
||||
$rrd_options .= ' AREA:inbits#'.$colour_area_in.':';
|
||||
$rrd_options .= ' LINE1.25:inbits#'.$colour_line_in.':';
|
||||
$rrd_options .= ' AREA:doutbits#'.$colour_area_out.':';
|
||||
$rrd_options .= ' LINE1.25:doutbits#'.$colour_line_out.':';
|
||||
$rrd_options .= ' AREA:inbits#' . $colour_area_in . $stacked['transparency'] . ':';
|
||||
$rrd_options .= ' LINE1.25:inbits#' . $colour_line_in . ':';
|
||||
$rrd_options .= ' AREA:doutbits#' . $colour_area_out . $stacked['transparency'] . ':';
|
||||
$rrd_options .= ' LINE1.25:doutbits#' . $colour_line_out . ':';
|
||||
} else {
|
||||
$rrd_options .= ' AREA:inbits#'.$colour_area_in.':';
|
||||
$rrd_options .= " COMMENT:'bps Now Ave Max ".$config['percentile_value']."th %\\n'";
|
||||
$rrd_options .= ' LINE1.25:inbits#'.$colour_line_in.':In\ ';
|
||||
$rrd_options .= ' AREA:inbits#' . $colour_area_in . $stacked['transparency'] . ':';
|
||||
$rrd_options .= " COMMENT:'bps Now Ave Max " . $config['percentile_value'] . "th %\\n'";
|
||||
$rrd_options .= ' LINE1.25:inbits#' . $colour_line_in . ':In\ ';
|
||||
$rrd_options .= ' GPRINT:inbits:LAST:%6.2lf%s';
|
||||
$rrd_options .= ' GPRINT:inbits:AVERAGE:%6.2lf%s';
|
||||
$rrd_options .= ' GPRINT:inbits:MAX:%6.2lf%s';
|
||||
$rrd_options .= " GPRINT:percentile_in:%6.2lf%s\\\\n";
|
||||
$rrd_options .= ' AREA:doutbits#'.$colour_area_out.':';
|
||||
$rrd_options .= ' LINE1.25:doutbits#'.$colour_line_out.':Out';
|
||||
$rrd_options .= ' AREA:doutbits#' . $colour_area_out . $stacked['transparency'] . ':';
|
||||
$rrd_options .= ' LINE1.25:doutbits#' . $colour_line_out . ':Out';
|
||||
$rrd_options .= ' GPRINT:outbits:LAST:%6.2lf%s';
|
||||
$rrd_options .= ' GPRINT:outbits:AVERAGE:%6.2lf%s';
|
||||
$rrd_options .= ' GPRINT:outbits:MAX:%6.2lf%s';
|
||||
@@ -100,9 +113,9 @@ if ($i) {
|
||||
$rrd_options .= ' LINE1:dpercentile_out#aa0000';
|
||||
|
||||
if ($_GET['previous'] == 'yes') {
|
||||
$rrd_options .= ' AREA:inbitsX#9999966:';
|
||||
$rrd_options .= ' AREA:doutbitsX#99999966:';
|
||||
$rrd_options .= ' AREA:inbitsX#9999966' . $stacked['transparency'] . ':';
|
||||
$rrd_options .= ' AREA:doutbitsX#99999966' . $stacked['transparency'] . ':';
|
||||
}
|
||||
}//end if
|
||||
}
|
||||
|
||||
// $rrd_options .= " HRULE:0#999999";
|
||||
unset($stacked);
|
||||
|
@@ -1,12 +1,27 @@
|
||||
<?php
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version. Please see LICENSE.txt at the top level of
|
||||
* the source code distribution for details.
|
||||
*
|
||||
* @package LibreNMS
|
||||
* @subpackage graphs
|
||||
* @link http://librenms.org
|
||||
* @copyright 2017 LibreNMS
|
||||
* @author LibreNMS Contributors
|
||||
*/
|
||||
|
||||
require 'includes/graphs/common.inc.php';
|
||||
|
||||
$stacked = generate_stacked_graphs();
|
||||
|
||||
$i = 0;
|
||||
if ($width > '500') {
|
||||
$descr_len = 18;
|
||||
} else {
|
||||
$descr_len = 8;
|
||||
$descr_len = 8;
|
||||
$descr_len += round(($width - 260) / 9.5);
|
||||
}
|
||||
|
||||
@@ -14,15 +29,15 @@ $unit_text = 'Bits/sec';
|
||||
|
||||
if (!$noagg || !$nodetails) {
|
||||
if ($width > '500') {
|
||||
$rrd_options .= " COMMENT:'".substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5))." Current Average Maximum '";
|
||||
$rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5)) . " Current Average Maximum '";
|
||||
if (!$nototal) {
|
||||
$rrd_options .= " COMMENT:'Total '";
|
||||
}
|
||||
|
||||
$rrd_options .= " COMMENT:'\l'";
|
||||
} else {
|
||||
$nototal = true;
|
||||
$rrd_options .= " COMMENT:'".substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5))." Now Ave Max\l'";
|
||||
$nototal = true;
|
||||
$rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5)) . " Now Ave Max\l'";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,57 +50,56 @@ foreach ($rrd_list as $rrd) {
|
||||
$iter = 0;
|
||||
}
|
||||
|
||||
$colour_in = $config['graph_colours'][$colours_in][$iter];
|
||||
$colour_in = $config['graph_colours'][$colours_in][$iter];
|
||||
$colour_out = $config['graph_colours'][$colours_out][$iter];
|
||||
|
||||
if (!$nodetails) {
|
||||
if (isset($rrd['descr_in'])) {
|
||||
$descr = rrdtool_escape($rrd['descr_in'], $descr_len).' In';
|
||||
$descr = rrdtool_escape($rrd['descr_in'], $descr_len) . ' In';
|
||||
} else {
|
||||
$descr = rrdtool_escape($rrd['descr'], $descr_len).' In';
|
||||
$descr = rrdtool_escape($rrd['descr'], $descr_len) . ' In';
|
||||
}
|
||||
|
||||
$descr_out = rrdtool_escape($rrd['descr_out'], $descr_len).' Out';
|
||||
$descr_out = rrdtool_escape($rrd['descr_out'], $descr_len) . ' Out';
|
||||
}
|
||||
|
||||
$rrd_options .= ' DEF:'.$in.$i.'='.$rrd['filename'].':'.$ds_in.':AVERAGE ';
|
||||
$rrd_options .= ' DEF:'.$out.$i.'='.$rrd['filename'].':'.$ds_out.':AVERAGE ';
|
||||
$rrd_options .= ' CDEF:inB'.$i.'=in'.$i.",$multiplier,* ";
|
||||
$rrd_options .= ' CDEF:outB'.$i.'=out'.$i.",$multiplier,*";
|
||||
$rrd_options .= ' CDEF:outB'.$i.'_neg=outB'.$i.',-1,*';
|
||||
$rrd_options .= ' CDEF:octets'.$i.'=inB'.$i.',outB'.$i.',+';
|
||||
$rrd_options .= ' DEF:' . $in . $i . '=' . $rrd['filename'] . ':' . $ds_in . ':AVERAGE ';
|
||||
$rrd_options .= ' DEF:' . $out . $i . '=' . $rrd['filename'] . ':' . $ds_out . ':AVERAGE ';
|
||||
$rrd_options .= ' CDEF:inB' . $i . '=in' . $i . ",$multiplier,* ";
|
||||
$rrd_options .= ' CDEF:outB' . $i . '=out' . $i . ",$multiplier,*";
|
||||
$rrd_options .= ' CDEF:outB' . $i . '_neg=outB' . $i . ',' . $stacked['stacked'] . ',*';
|
||||
$rrd_options .= ' CDEF:octets' . $i . '=inB' . $i . ',outB' . $i . ',+';
|
||||
|
||||
if (!$nototal) {
|
||||
$rrd_options .= ' VDEF:totin'.$i.'=inB'.$i.',TOTAL';
|
||||
$rrd_options .= ' VDEF:totout'.$i.'=outB'.$i.',TOTAL';
|
||||
$rrd_options .= ' VDEF:tot'.$i.'=octets'.$i.',TOTAL';
|
||||
$rrd_options .= ' VDEF:totin' . $i . '=inB' . $i . ',TOTAL';
|
||||
$rrd_options .= ' VDEF:totout' . $i . '=outB' . $i . ',TOTAL';
|
||||
$rrd_options .= ' VDEF:tot' . $i . '=octets' . $i . ',TOTAL';
|
||||
}
|
||||
|
||||
if ($i) {
|
||||
$stack = ':STACK';
|
||||
}
|
||||
|
||||
$rrd_options .= ' AREA:inB'.$i.'#'.$colour_in.":'".$descr."'$stack";
|
||||
$rrd_options .= ' AREA:inB' . $i . '#' . $colour_in . $stacked['transparency'] . ":'" . $descr . "'$stack";
|
||||
if (!$nodetails) {
|
||||
$rrd_options .= ' GPRINT:inB'.$i.":LAST:%6.2lf%s$units";
|
||||
$rrd_options .= ' GPRINT:inB'.$i.":AVERAGE:%6.2lf%s$units";
|
||||
$rrd_options .= ' GPRINT:inB'.$i.":MAX:%6.2lf%s$units";
|
||||
$rrd_options .= ' GPRINT:inB' . $i . ":LAST:%6.2lf%s$units";
|
||||
$rrd_options .= ' GPRINT:inB' . $i . ":AVERAGE:%6.2lf%s$units";
|
||||
$rrd_options .= ' GPRINT:inB' . $i . ":MAX:%6.2lf%s$units";
|
||||
if (!$nototal) {
|
||||
$rrd_options .= ' GPRINT:totin'.$i.":%6.2lf%s$total_units";
|
||||
$rrd_options .= ' GPRINT:totin' . $i . ":%6.2lf%s$total_units";
|
||||
}
|
||||
|
||||
$rrd_options .= '\l';
|
||||
}
|
||||
|
||||
$rrd_options .= " 'HRULE:0#".$colour_out.':'.$descr_out."'";
|
||||
$rrd_optionsb .= " 'AREA:outB".$i.'_neg#'.$colour_out.":$stack'";
|
||||
$rrd_options .= " 'HRULE:0#" . $colour_out . ':' . $descr_out . "'";
|
||||
$rrd_optionsb .= " 'AREA:outB" . $i . '_neg#' . $colour_out . $stacked['transparency'] . ":$stack'";
|
||||
|
||||
if (!$nodetails) {
|
||||
$rrd_options .= ' GPRINT:outB'.$i.":LAST:%6.2lf%s$units";
|
||||
$rrd_options .= ' GPRINT:outB'.$i.":AVERAGE:%6.2lf%s$units";
|
||||
$rrd_options .= ' GPRINT:outB'.$i.":MAX:%6.2lf%s$units";
|
||||
$rrd_options .= ' GPRINT:outB' . $i . ":LAST:%6.2lf%s$units";
|
||||
$rrd_options .= ' GPRINT:outB' . $i . ":AVERAGE:%6.2lf%s$units";
|
||||
$rrd_options .= ' GPRINT:outB' . $i . ":MAX:%6.2lf%s$units";
|
||||
if (!$nototal) {
|
||||
$rrd_options .= ' GPRINT:totout'.$i.":%6.2lf%s$total_unit";
|
||||
$rrd_options .= ' GPRINT:totout' . $i . ":%6.2lf%s$total_unit";
|
||||
}
|
||||
|
||||
$rrd_options .= '\l';
|
||||
@@ -94,31 +108,31 @@ foreach ($rrd_list as $rrd) {
|
||||
$rrd_options .= " 'COMMENT:\l'";
|
||||
|
||||
if ($i >= 1) {
|
||||
$aggr_in .= ',';
|
||||
$aggr_in .= ',';
|
||||
$aggr_out .= ',';
|
||||
}
|
||||
|
||||
if ($i > 1) {
|
||||
$aggr_in .= 'ADDNAN,';
|
||||
$aggr_in .= 'ADDNAN,';
|
||||
$aggr_out .= 'ADDNAN,';
|
||||
}
|
||||
|
||||
$aggr_in .= $in.$i;
|
||||
$aggr_out .= $out.$i;
|
||||
$aggr_in .= $in . $i;
|
||||
$aggr_out .= $out . $i;
|
||||
|
||||
$i++;
|
||||
$iter++;
|
||||
}
|
||||
|
||||
if (!$noagg) {
|
||||
$rrd_options .= ' CDEF:aggr'.$in.'bytes='.$aggr_in.',ADDNAN';
|
||||
$rrd_options .= ' CDEF:aggr'.$out.'bytes='.$aggr_out.',ADDNAN';
|
||||
$rrd_options .= ' CDEF:aggrinbits=aggrinbytes,'.$multiplier.',*';
|
||||
$rrd_options .= ' CDEF:aggroutbits=aggroutbytes,'.$multiplier.',*';
|
||||
$rrd_options .= ' CDEF:aggr' . $in . 'bytes=' . $aggr_in . ',ADDNAN';
|
||||
$rrd_options .= ' CDEF:aggr' . $out . 'bytes=' . $aggr_out . ',ADDNAN';
|
||||
$rrd_options .= ' CDEF:aggrinbits=aggrinbytes,' . $multiplier . ',*';
|
||||
$rrd_options .= ' CDEF:aggroutbits=aggroutbytes,' . $multiplier . ',*';
|
||||
$rrd_options .= ' VDEF:totalin=aggrinbytes,TOTAL';
|
||||
$rrd_options .= ' VDEF:totalout=aggroutbytes,TOTAL';
|
||||
$rrd_options .= " COMMENT:' \\\\n'";
|
||||
$rrd_options .= " COMMENT:'".substr(str_pad('Aggregate In', ($descr_len + 5)), 0, ($descr_len + 5))."'";
|
||||
$rrd_options .= " COMMENT:'" . substr(str_pad('Aggregate In', ($descr_len + 5)), 0, ($descr_len + 5)) . "'";
|
||||
$rrd_options .= " GPRINT:aggrinbits:LAST:%6.2lf%s$units";
|
||||
$rrd_options .= " GPRINT:aggrinbits:AVERAGE:%6.2lf%s$units";
|
||||
$rrd_options .= " GPRINT:aggrinbits:MAX:%6.2lf%s$units";
|
||||
@@ -127,7 +141,7 @@ if (!$noagg) {
|
||||
}
|
||||
|
||||
$rrd_options .= "\\\\n";
|
||||
$rrd_options .= " COMMENT:'".substr(str_pad('Aggregate Out', ($descr_len + 5)), 0, ($descr_len + 5))."'";
|
||||
$rrd_options .= " COMMENT:'" . substr(str_pad('Aggregate Out', ($descr_len + 5)), 0, ($descr_len + 5)) . "'";
|
||||
$rrd_options .= " GPRINT:aggroutbits:LAST:%6.2lf%s$units";
|
||||
$rrd_options .= " GPRINT:aggroutbits:AVERAGE:%6.2lf%s$units";
|
||||
$rrd_options .= " GPRINT:aggroutbits:MAX:%6.2lf%s$units";
|
||||
@@ -144,3 +158,5 @@ if ($custom_graph) {
|
||||
|
||||
$rrd_options .= $rrd_optionsb;
|
||||
$rrd_options .= ' HRULE:0#999999';
|
||||
|
||||
unset($stacked);
|
||||
|
@@ -1,14 +1,27 @@
|
||||
<?php
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version. Please see LICENSE.txt at the top level of
|
||||
* the source code distribution for details.
|
||||
*
|
||||
* @package LibreNMS
|
||||
* @subpackage graphs
|
||||
* @link http://librenms.org
|
||||
* @copyright 2017 LibreNMS
|
||||
* @author LibreNMS Contributors
|
||||
*/
|
||||
|
||||
// Draws aggregate bits graph from multiple RRDs
|
||||
// Variables : colour_[line|area]_[in|out], rrd_filenames
|
||||
require 'includes/graphs/common.inc.php';
|
||||
|
||||
$stacked = generate_stacked_graphs();
|
||||
|
||||
if ($format == 'octets' || $format == 'bytes') {
|
||||
$units = 'Bps';
|
||||
$units = 'Bps';
|
||||
$format = 'octets';
|
||||
} else {
|
||||
$units = 'bps';
|
||||
$units = 'bps';
|
||||
$format = 'bits';
|
||||
}
|
||||
|
||||
@@ -16,91 +29,87 @@ $i = 0;
|
||||
|
||||
foreach ($rrd_filenames as $key => $rrd_filename) {
|
||||
if ($rrd_inverted[$key]) {
|
||||
$in = 'out';
|
||||
$in = 'out';
|
||||
$out = 'in';
|
||||
} else {
|
||||
$in = 'in';
|
||||
$in = 'in';
|
||||
$out = 'out';
|
||||
}
|
||||
|
||||
$rrd_options .= ' DEF:'.$in.'octets'.$i.'='.$rrd_filename.':'.$ds_in.':AVERAGE';
|
||||
$rrd_options .= ' DEF:'.$out.'octets'.$i.'='.$rrd_filename.':'.$ds_out.':AVERAGE';
|
||||
$in_thing .= $seperator.'inoctets'.$i.',UN,0,'.'inoctets'.$i.',IF';
|
||||
$out_thing .= $seperator.'outoctets'.$i.',UN,0,'.'outoctets'.$i.',IF';
|
||||
$pluses .= $plus;
|
||||
$seperator = ',';
|
||||
$plus = ',+';
|
||||
$rrd_options .= ' DEF:' . $in . 'octets' . $i . '=' . $rrd_filename . ':' . $ds_in . ':AVERAGE';
|
||||
$rrd_options .= ' DEF:' . $out . 'octets' . $i . '=' . $rrd_filename . ':' . $ds_out . ':AVERAGE';
|
||||
$in_thing .= $seperator . 'inoctets' . $i . ',UN,0,' . 'inoctets' . $i . ',IF';
|
||||
$out_thing .= $seperator . 'outoctets' . $i . ',UN,0,' . 'outoctets' . $i . ',IF';
|
||||
$pluses .= $plus;
|
||||
$seperator = ',';
|
||||
$plus = ',+';
|
||||
|
||||
if ($_GET['previous']) {
|
||||
$rrd_options .= ' DEF:'.$in.'octets'.$i.'X='.$rrd_filename.':'.$ds_in.':AVERAGE:start='.$prev_from.':end='.$from;
|
||||
$rrd_options .= ' DEF:'.$out.'octets'.$i.'X='.$rrd_filename.':'.$ds_out.':AVERAGE:start='.$prev_from.':end='.$from;
|
||||
$rrd_options .= ' SHIFT:'.$in.'octets'.$i."X:$period";
|
||||
$rrd_options .= ' SHIFT:'.$out.'octets'.$i."X:$period";
|
||||
$in_thingX .= $seperatorX.'inoctets'.$i.'X,UN,0,'.'inoctets'.$i.'X,IF';
|
||||
$out_thingX .= $seperatorX.'outoctets'.$i.'X,UN,0,'.'outoctets'.$i.'X,IF';
|
||||
$plusesX .= $plusX;
|
||||
$seperatorX = ',';
|
||||
$plusX = ',+';
|
||||
$rrd_options .= ' DEF:' . $in . 'octets' . $i . 'X=' . $rrd_filename . ':' . $ds_in . ':AVERAGE:start=' . $prev_from . ':end=' . $from;
|
||||
$rrd_options .= ' DEF:' . $out . 'octets' . $i . 'X=' . $rrd_filename . ':' . $ds_out . ':AVERAGE:start=' . $prev_from . ':end=' . $from;
|
||||
$rrd_options .= ' SHIFT:' . $in . 'octets' . $i . "X:$period";
|
||||
$rrd_options .= ' SHIFT:' . $out . 'octets' . $i . "X:$period";
|
||||
$in_thingX .= $seperatorX . 'inoctets' . $i . 'X,UN,0,' . 'inoctets' . $i . 'X,IF';
|
||||
$out_thingX .= $seperatorX . 'outoctets' . $i . 'X,UN,0,' . 'outoctets' . $i . 'X,IF';
|
||||
$plusesX .= $plusX;
|
||||
$seperatorX = ',';
|
||||
$plusX = ',+';
|
||||
}
|
||||
|
||||
$i++;
|
||||
}//end foreach
|
||||
}
|
||||
|
||||
if ($i) {
|
||||
if ($inverse) {
|
||||
$in = 'out';
|
||||
$in = 'out';
|
||||
$out = 'in';
|
||||
} else {
|
||||
$in = 'in';
|
||||
$in = 'in';
|
||||
$out = 'out';
|
||||
}
|
||||
|
||||
$rrd_options .= ' CDEF:'.$in.'octets='.$in_thing.$pluses;
|
||||
$rrd_options .= ' CDEF:'.$out.'octets='.$out_thing.$pluses;
|
||||
$rrd_options .= ' CDEF:doutoctets=outoctets,-1,*';
|
||||
$rrd_options .= ' CDEF:' . $in . 'octets=' . $in_thing . $pluses;
|
||||
$rrd_options .= ' CDEF:' . $out . 'octets=' . $out_thing . $pluses;
|
||||
$rrd_options .= ' CDEF:doutoctets=outoctets,' . $stacked['stacked'] . ',*';
|
||||
$rrd_options .= ' CDEF:inbits=inoctets,8,*';
|
||||
$rrd_options .= ' CDEF:outbits=outoctets,8,*';
|
||||
$rrd_options .= ' CDEF:doutbits=doutoctets,8,*';
|
||||
$rrd_options .= ' VDEF:percentile_in=inbits,'.$config['percentile_value'].',PERCENT';
|
||||
$rrd_options .= ' VDEF:percentile_out=outbits,'.$config['percentile_value'].',PERCENT';
|
||||
$rrd_options .= ' CDEF:dpercentile_outn=doutbits,-1,*';
|
||||
$rrd_options .= ' VDEF:dpercentile_outp=dpercentile_outn,'.$config['percentile_value'].',PERCENT';
|
||||
$rrd_options .= ' CDEF:dpercentile_outpn=doutbits,doutbits,-,dpercentile_outp,-1,*,+';
|
||||
$rrd_options .= ' VDEF:percentile_in=inbits,' . $config['percentile_value'] . ',PERCENT';
|
||||
$rrd_options .= ' VDEF:percentile_out=outbits,' . $config['percentile_value'] . ',PERCENT';
|
||||
$rrd_options .= ' CDEF:dpercentile_outn=doutbits,' . $stacked['stacked'] . ',*';
|
||||
$rrd_options .= ' VDEF:dpercentile_outp=dpercentile_outn,' . $config['percentile_value'] . ',PERCENT';
|
||||
$rrd_options .= ' CDEF:dpercentile_outpn=doutbits,doutbits,-,dpercentile_outp,' . $stacked['stacked'] . ',*,+';
|
||||
$rrd_options .= ' VDEF:dpercentile_out=dpercentile_outpn,FIRST';
|
||||
|
||||
if ($_GET['previous'] == 'yes') {
|
||||
$rrd_options .= ' CDEF:'.$in.'octetsX='.$in_thingX.$pluses;
|
||||
$rrd_options .= ' CDEF:'.$out.'octetsX='.$out_thingX.$pluses;
|
||||
$rrd_options .= ' CDEF:doutoctetsX=outoctetsX,-1,*';
|
||||
$rrd_options .= ' CDEF:' . $in . 'octetsX=' . $in_thingX . $pluses;
|
||||
$rrd_options .= ' CDEF:' . $out . 'octetsX=' . $out_thingX . $pluses;
|
||||
$rrd_options .= ' CDEF:doutoctetsX=outoctetsX,' . $stacked['stacked'] . ',*';
|
||||
$rrd_options .= ' CDEF:inbitsX=inoctetsX,8,*';
|
||||
$rrd_options .= ' CDEF:outbitsX=outoctetsX,8,*';
|
||||
$rrd_options .= ' CDEF:doutbitsX=doutoctetsX,8,*';
|
||||
$rrd_options .= ' VDEF:percentile_inX=inbitsX,'.$config['percentile_value'].',PERCENT';
|
||||
$rrd_options .= ' VDEF:percentile_outX=outbitsX,'.$config['percentile_value'].',PERCENT';
|
||||
$rrd_options .= ' CDEF:dpercentile_outXn=doutbitsX,-1,*';
|
||||
$rrd_options .= ' VDEF:dpercentile_outX=dpercentile_outXn,'.$config['percentile_value'].',PERCENT';
|
||||
$rrd_options .= ' CDEF:dpercentile_outXn=doutbitsX,doutbitsX,-,dpercentile_outX,-1,*,+';
|
||||
$rrd_options .= ' VDEF:percentile_inX=inbitsX,' . $config['percentile_value'] . ',PERCENT';
|
||||
$rrd_options .= ' VDEF:percentile_outX=outbitsX,' . $config['percentile_value'] . ',PERCENT';
|
||||
$rrd_options .= ' CDEF:dpercentile_outXn=doutbitsX,' . $stacked['stacked'] . ',*';
|
||||
$rrd_options .= ' VDEF:dpercentile_outX=dpercentile_outXn,' . $config['percentile_value'] . ',PERCENT';
|
||||
$rrd_options .= ' CDEF:dpercentile_outXn=doutbitsX,doutbitsX,-,dpercentile_outX,' . $stacked['stacked'] . ',*,+';
|
||||
$rrd_options .= ' VDEF:dpercentile_outX=dpercentile_outXn,FIRST';
|
||||
}
|
||||
|
||||
if ($legend == 'no' || $legend == '1') {
|
||||
$rrd_options .= ' AREA:in'.$format.'#'.$colour_area_in.':';
|
||||
// $rrd_options .= " LINE1.25:in".$format."#".$colour_line_in.":";
|
||||
$rrd_options .= ' AREA:dout'.$format.'#'.$colour_area_out.':';
|
||||
// $rrd_options .= " LINE1.25:dout".$format."#".$colour_line_out.":";
|
||||
$rrd_options .= ' AREA:in' . $format . '#' . $colour_area_in . $stacked['transparency'] . ':';
|
||||
$rrd_options .= ' AREA:dout' . $format . '#' . $colour_area_out . $stacked['transparency'] . ':';
|
||||
} else {
|
||||
$rrd_options .= " COMMENT:'bps Now Ave Max ".$config['percentile_value']."th %\\n'";
|
||||
$rrd_options .= ' AREA:in'.$format.'#'.$colour_area_in.':In ';
|
||||
// $rrd_options .= " LINE1.25:in".$format."#".$colour_line_in.":In\ ";
|
||||
$rrd_options .= ' GPRINT:in'.$format.':LAST:%6.2lf%s';
|
||||
$rrd_options .= ' GPRINT:in'.$format.':AVERAGE:%6.2lf%s';
|
||||
$rrd_options .= ' GPRINT:in'.$format.':MAX:%6.2lf%s';
|
||||
$rrd_options .= " COMMENT:'bps Now Ave Max " . $config['percentile_value'] . "th %\\n'";
|
||||
$rrd_options .= ' AREA:in' . $format . '#' . $colour_area_in . $stacked['transparency'] . ':In ';
|
||||
$rrd_options .= ' GPRINT:in' . $format . ':LAST:%6.2lf%s';
|
||||
$rrd_options .= ' GPRINT:in' . $format . ':AVERAGE:%6.2lf%s';
|
||||
$rrd_options .= ' GPRINT:in' . $format . ':MAX:%6.2lf%s';
|
||||
$rrd_options .= " GPRINT:percentile_in:%6.2lf%s\\n";
|
||||
$rrd_options .= ' AREA:dout'.$format.'#'.$colour_area_out.':Out';
|
||||
// $rrd_options .= " LINE1.25:dout".$format."#".$colour_line_out.":Out";
|
||||
$rrd_options .= ' GPRINT:out'.$format.':LAST:%6.2lf%s';
|
||||
$rrd_options .= ' GPRINT:out'.$format.':AVERAGE:%6.2lf%s';
|
||||
$rrd_options .= ' GPRINT:out'.$format.':MAX:%6.2lf%s';
|
||||
$rrd_options .= ' AREA:dout' . $format . '#' . $colour_area_out . $stacked['transparency'] . ':Out';
|
||||
$rrd_options .= ' GPRINT:out' . $format . ':LAST:%6.2lf%s';
|
||||
$rrd_options .= ' GPRINT:out' . $format . ':AVERAGE:%6.2lf%s';
|
||||
$rrd_options .= ' GPRINT:out' . $format . ':MAX:%6.2lf%s';
|
||||
$rrd_options .= " GPRINT:percentile_out:%6.2lf%s\\n";
|
||||
}
|
||||
|
||||
@@ -108,11 +117,11 @@ if ($i) {
|
||||
$rrd_options .= ' LINE1:dpercentile_out#aa0000';
|
||||
|
||||
if ($_GET['previous'] == 'yes') {
|
||||
$rrd_options .= ' AREA:in'.$format.'X#99999999:';
|
||||
$rrd_options .= ' AREA:dout'.$format.'X#99999999:';
|
||||
$rrd_options .= ' LINE1:in'.$format.'X#666666:';
|
||||
$rrd_options .= ' LINE1:dout'.$format.'X#666666:';
|
||||
$rrd_options .= ' AREA:in' . $format . 'X#99999999' . $stacked['transparency'] . ':';
|
||||
$rrd_options .= ' AREA:dout' . $format . 'X#99999999' . $stacked['transparency'] . ':';
|
||||
$rrd_options .= ' LINE1:in' . $format . 'X#666666:';
|
||||
$rrd_options .= ' LINE1:dout' . $format . 'X#666666:';
|
||||
}
|
||||
}//end if
|
||||
}
|
||||
|
||||
// $rrd_options .= " HRULE:0#999999";
|
||||
unset($stacked);
|
||||
|
@@ -1,26 +1,41 @@
|
||||
<?php
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version. Please see LICENSE.txt at the top level of
|
||||
* the source code distribution for details.
|
||||
*
|
||||
* @package LibreNMS
|
||||
* @subpackage graphs
|
||||
* @link http://librenms.org
|
||||
* @copyright 2017 LibreNMS
|
||||
* @author LibreNMS Contributors
|
||||
*/
|
||||
|
||||
require 'includes/graphs/common.inc.php';
|
||||
|
||||
$stacked = generate_stacked_graphs();
|
||||
|
||||
$i = 0;
|
||||
if ($width > '500') {
|
||||
$descr_len = 18;
|
||||
} else {
|
||||
$descr_len = 8;
|
||||
$descr_len = 8;
|
||||
$descr_len += round(($width - 260) / 9.5);
|
||||
}
|
||||
|
||||
$unit_text = 'Bits/sec';
|
||||
|
||||
if ($width > '500') {
|
||||
$rrd_options .= " COMMENT:'".substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5))." Current Average Maximum '";
|
||||
$rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5)) . " Current Average Maximum '";
|
||||
if (!$nototal) {
|
||||
$rrd_options .= " COMMENT:'Total '";
|
||||
}
|
||||
|
||||
$rrd_options .= " COMMENT:'\l'";
|
||||
} else {
|
||||
$rrd_options .= " COMMENT:'".substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5))." Now Ave Max\l'";
|
||||
$rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5)) . " Now Ave Max\l'";
|
||||
}
|
||||
|
||||
if (!isset($multiplier)) {
|
||||
@@ -32,90 +47,85 @@ foreach ($rrd_list as $rrd) {
|
||||
$iter = 0;
|
||||
}
|
||||
|
||||
$colour_in = $config['graph_colours'][$colours_in][$iter];
|
||||
$colour_in = $config['graph_colours'][$colours_in][$iter];
|
||||
$colour_out = $config['graph_colours'][$colours_out][$iter];
|
||||
|
||||
if (isset($rrd['descr_in'])) {
|
||||
$descr = rrdtool_escape($rrd['descr_in'], $descr_len).' In';
|
||||
$descr = rrdtool_escape($rrd['descr_in'], $descr_len) . ' In';
|
||||
} else {
|
||||
$descr = rrdtool_escape($rrd['descr'], $descr_len).' In';
|
||||
$descr = rrdtool_escape($rrd['descr'], $descr_len) . ' In';
|
||||
}
|
||||
|
||||
$descr_out = rrdtool_escape($rrd['descr_out'], $descr_len).' Out';
|
||||
$descr_out = rrdtool_escape($rrd['descr_out'], $descr_len) . ' Out';
|
||||
|
||||
$rrd_options .= ' DEF:'.$in.$i.'='.$rrd['filename'].':'.$ds_in.':AVERAGE ';
|
||||
$rrd_options .= ' DEF:'.$out.$i.'='.$rrd['filename'].':'.$ds_out.':AVERAGE ';
|
||||
$rrd_options .= ' CDEF:inB'.$i.'=in'.$i.",$multiplier,* ";
|
||||
$rrd_options .= ' CDEF:outB'.$i.'=out'.$i.",$multiplier,*";
|
||||
$rrd_options .= ' CDEF:outB'.$i.'_neg=outB'.$i.',-1,*';
|
||||
$rrd_options .= ' CDEF:octets'.$i.'=inB'.$i.',outB'.$i.',+';
|
||||
$rrd_options .= ' DEF:' . $in . $i . '=' . $rrd['filename'] . ':' . $ds_in . ':AVERAGE ';
|
||||
$rrd_options .= ' DEF:' . $out . $i . '=' . $rrd['filename'] . ':' . $ds_out . ':AVERAGE ';
|
||||
$rrd_options .= ' CDEF:inB' . $i . '=in' . $i . ",$multiplier,* ";
|
||||
$rrd_options .= ' CDEF:outB' . $i . '=out' . $i . ",$multiplier,*";
|
||||
$rrd_options .= ' CDEF:outB' . $i . '_neg=outB' . $i . ',' . $stacked['stacked'] . ',*';
|
||||
$rrd_options .= ' CDEF:octets' . $i . '=inB' . $i . ',outB' . $i . ',+';
|
||||
|
||||
if (!$args['nototal']) {
|
||||
$in_thing .= $seperator.$in.$i.',UN,0,'.$in.$i.',IF';
|
||||
$out_thing .= $seperator.$out.$i.',UN,0,'.$out.$i.',IF';
|
||||
$pluses .= $plus;
|
||||
$seperator = ',';
|
||||
$plus = ',+';
|
||||
$in_thing .= $seperator . $in . $i . ',UN,0,' . $in . $i . ',IF';
|
||||
$out_thing .= $seperator . $out . $i . ',UN,0,' . $out . $i . ',IF';
|
||||
$pluses .= $plus;
|
||||
$seperator = ',';
|
||||
$plus = ',+';
|
||||
|
||||
$rrd_options .= ' VDEF:totin'.$i.'=inB'.$i.',TOTAL';
|
||||
$rrd_options .= ' VDEF:totout'.$i.'=outB'.$i.',TOTAL';
|
||||
$rrd_options .= ' VDEF:tot'.$i.'=octets'.$i.',TOTAL';
|
||||
$rrd_options .= ' VDEF:totin' . $i . '=inB' . $i . ',TOTAL';
|
||||
$rrd_options .= ' VDEF:totout' . $i . '=outB' . $i . ',TOTAL';
|
||||
$rrd_options .= ' VDEF:tot' . $i . '=octets' . $i . ',TOTAL';
|
||||
}
|
||||
|
||||
if ($i) {
|
||||
$stack = ':STACK';
|
||||
}
|
||||
|
||||
$rrd_options .= ' AREA:inB'.$i.'#'.$colour_in.":'".$descr."'$stack";
|
||||
$rrd_options .= ' GPRINT:inB'.$i.":LAST:%6.2lf%s$units";
|
||||
$rrd_options .= ' GPRINT:inB'.$i.":AVERAGE:%6.2lf%s$units";
|
||||
$rrd_options .= ' GPRINT:inB'.$i.":MAX:%6.2lf%s$units\l";
|
||||
$rrd_options .= ' AREA:inB' . $i . '#' . $colour_in . $stacked['transparency'] . ":'" . $descr . "'$stack";
|
||||
$rrd_options .= ' GPRINT:inB' . $i . ":LAST:%6.2lf%s$units";
|
||||
$rrd_options .= ' GPRINT:inB' . $i . ":AVERAGE:%6.2lf%s$units";
|
||||
$rrd_options .= ' GPRINT:inB' . $i . ":MAX:%6.2lf%s$units\l";
|
||||
|
||||
if (!$nototal) {
|
||||
$rrd_options .= ' GPRINT:totin'.$i.":%6.2lf%s$total_units";
|
||||
$rrd_options .= ' GPRINT:totin' . $i . ":%6.2lf%s$total_units";
|
||||
}
|
||||
|
||||
$rrd_options .= " 'HRULE:0#".$colour_out.':'.$descr_out."'";
|
||||
$rrd_optionsb .= " 'AREA:outB".$i.'_neg#'.$colour_out.":$stack'";
|
||||
$rrd_options .= ' GPRINT:outB'.$i.":LAST:%6.2lf%s$units";
|
||||
$rrd_options .= ' GPRINT:outB'.$i.":AVERAGE:%6.2lf%s$units";
|
||||
$rrd_options .= ' GPRINT:outB'.$i.":MAX:%6.2lf%s$units\l";
|
||||
$rrd_options .= " 'HRULE:0#" . $colour_out . ':' . $descr_out . "'";
|
||||
$rrd_optionsb .= " 'AREA:outB" . $i . '_neg#' . $colour_out . $stacked['transparency'] . ":$stack'";
|
||||
$rrd_options .= ' GPRINT:outB' . $i . ":LAST:%6.2lf%s$units";
|
||||
$rrd_options .= ' GPRINT:outB' . $i . ":AVERAGE:%6.2lf%s$units";
|
||||
$rrd_options .= ' GPRINT:outB' . $i . ":MAX:%6.2lf%s$units\l";
|
||||
|
||||
if (!$nototal) {
|
||||
$rrd_options .= ' GPRINT:totout'.$i.":%6.2lf%s$total_units";
|
||||
$rrd_options .= ' GPRINT:totout' . $i . ":%6.2lf%s$total_units";
|
||||
}
|
||||
|
||||
$rrd_options .= " 'COMMENT:\l'";
|
||||
$i++;
|
||||
$iter++;
|
||||
}//end foreach
|
||||
}
|
||||
|
||||
if ($custom_graph) {
|
||||
$rrd_options .= $custom_graph;
|
||||
}
|
||||
|
||||
if (!$nototal) {
|
||||
$rrd_options .= ' CDEF:'.$in.'octets='.$in_thing.$pluses;
|
||||
$rrd_options .= ' CDEF:'.$out.'octets='.$out_thing.$pluses;
|
||||
$rrd_options .= ' CDEF:' . $in . 'octets=' . $in_thing . $pluses;
|
||||
$rrd_options .= ' CDEF:' . $out . 'octets=' . $out_thing . $pluses;
|
||||
$rrd_options .= ' CDEF:octets=inoctets,outoctets,+';
|
||||
$rrd_options .= ' CDEF:doutoctets=outoctets,-1,*';
|
||||
$rrd_options .= ' CDEF:doutoctets=outoctets,' . $stacked['stacked'] . ',*';
|
||||
$rrd_options .= ' CDEF:inbits=inoctets,8,*';
|
||||
$rrd_options .= ' CDEF:outbits=outoctets,8,*';
|
||||
$rrd_options .= ' CDEF:doutbits=doutoctets,8,*';
|
||||
|
||||
$rrd_options .= ' VDEF:percentile_in=inbits,'.$config['percentile_value'].',PERCENT';
|
||||
$rrd_options .= ' VDEF:percentile_out=outbits,'.$config['percentile_value'].',PERCENT';
|
||||
$rrd_options .= ' CDEF:dpercentile_outn=doutbits,-1,* VDEF:dpercentile_outnp=dpercentile_outn,'.$config['percentile_value'].',PERCENT CDEF:dpercentile_outnpn=doutbits,doutbits,-,dpercentile_outnp,-1,*,+ VDEF:dpercentile_out=dpercentile_outnpn,FIRST';
|
||||
|
||||
$rrd_options .= ' VDEF:percentile_in=inbits,' . $config['percentile_value'] . ',PERCENT';
|
||||
$rrd_options .= ' VDEF:percentile_out=outbits,' . $config['percentile_value'] . ',PERCENT';
|
||||
$rrd_options .= ' CDEF:dpercentile_outn=doutbits,' . $stacked['stacked'] . ',* VDEF:dpercentile_outnp=dpercentile_outn,' . $config['percentile_value'] . ',PERCENT CDEF:dpercentile_outnpn=doutbits,doutbits,-,dpercentile_outnp,' . $stacked['stacked'] . ',*,+ VDEF:dpercentile_out=dpercentile_outnpn,FIRST';
|
||||
$rrd_options .= ' VDEF:totin=inoctets,TOTAL';
|
||||
$rrd_options .= ' VDEF:totout=outoctets,TOTAL';
|
||||
$rrd_options .= ' VDEF:tot=octets,TOTAL';
|
||||
|
||||
// $rrd_options .= " AREA:totin#" . $colour_in . ":'" . $descr . "'$stack";
|
||||
// $rrd_options .= " GPRINT:totin:LAST:%6.2lf%s$units";
|
||||
// $rrd_options .= " GPRINT:totin:AVERAGE:%6.2lf%s$units";
|
||||
// $rrd_options .= " GPRINT:totin:MAX:%6.2lf%s$units\l";
|
||||
}//end if
|
||||
}
|
||||
|
||||
$rrd_options .= $rrd_optionsb;
|
||||
$rrd_options .= ' HRULE:0#999999';
|
||||
|
||||
unset($stacked);
|
||||
|
@@ -1,34 +1,32 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Outputs a graph with multiple overlaid lines
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version. Please see LICENSE.txt at the top level of
|
||||
* the source code distribution for details.
|
||||
*
|
||||
* Variables:
|
||||
* $rrd_list array required - array of data sets to graph. Each item is an array that contains the following
|
||||
* ds string required - data set name as defined in rrd
|
||||
* filename string required - path to the rrd file as generated by rrd_name()
|
||||
* descr string required - the label for this data set
|
||||
* colour string optional - Defines the colour for this data set (overrides the overall colour set)
|
||||
* area boolean optional - Colors in the area of the data set with 20% opacity (unless areacolor is set)
|
||||
* areacolor string optional - Sets the area color manually
|
||||
* invert boolean optional - multiplies values in this data set by -1
|
||||
* $colours string required - colour set as defined in $config['graph_colours']
|
||||
* $print_total boolean optional - Sum all the values and output the last, min, max, and avg in the legend
|
||||
* $simplerrd boolean optional - All data sets reside in the same rrd file
|
||||
*/
|
||||
* @package LibreNMS
|
||||
* @subpackage graphs
|
||||
* @link http://librenms.org
|
||||
* @copyright 2017 LibreNMS
|
||||
* @author LibreNMS Contributors
|
||||
*/
|
||||
|
||||
require 'includes/graphs/common.inc.php';
|
||||
|
||||
$stacked = generate_stacked_graphs();
|
||||
|
||||
$descr_len = 12;
|
||||
|
||||
if ($nototal) {
|
||||
$descr_len += '2';
|
||||
$unitlen += '2';
|
||||
$unitlen += '2';
|
||||
}
|
||||
|
||||
$rrd_options .= " COMMENT:'".rrdtool_escape($unit_text, $descr_len)." Now Min Max Avg\l'";
|
||||
$rrd_options .= " COMMENT:'" . rrdtool_escape($unit_text, $descr_len) . " Now Min Max Avg\l'";
|
||||
|
||||
$i = 0;
|
||||
$i = 0;
|
||||
$iter = 0;
|
||||
|
||||
foreach ($rrd_list as $rrd) {
|
||||
@@ -44,44 +42,47 @@ foreach ($rrd_list as $rrd) {
|
||||
}
|
||||
|
||||
if (!empty($rrd['area']) && empty($rrd['areacolour'])) {
|
||||
$rrd['areacolour'] = $colour."20";
|
||||
$rrd['areacolour'] = $colour . "20";
|
||||
}
|
||||
|
||||
$ds = $rrd['ds'];
|
||||
$ds = $rrd['ds'];
|
||||
$filename = $rrd['filename'];
|
||||
|
||||
$descr = rrdtool_escape($rrd['descr'], $descr_len);
|
||||
|
||||
$id = 'ds'.$i;
|
||||
$id = 'ds' . $i;
|
||||
|
||||
$rrd_options .= ' DEF:'.$id."=$filename:$ds:AVERAGE";
|
||||
$rrd_options .= ' DEF:' . $id . "=$filename:$ds:AVERAGE";
|
||||
|
||||
if ($simple_rrd) {
|
||||
$rrd_options .= ' CDEF:'.$id.'min='.$id.' ';
|
||||
$rrd_options .= ' CDEF:'.$id.'max='.$id.' ';
|
||||
$rrd_options .= ' CDEF:' . $id . 'min=' . $id . ' ';
|
||||
$rrd_options .= ' CDEF:' . $id . 'max=' . $id . ' ';
|
||||
} else {
|
||||
$rrd_options .= ' DEF:'.$id."min=$filename:$ds:MIN";
|
||||
$rrd_options .= ' DEF:'.$id."max=$filename:$ds:MAX";
|
||||
$rrd_options .= ' DEF:' . $id . "min=$filename:$ds:MIN";
|
||||
$rrd_options .= ' DEF:' . $id . "max=$filename:$ds:MAX";
|
||||
}
|
||||
|
||||
if ($rrd['invert']) {
|
||||
$rrd_options .= ' CDEF:'.$id.'i='.$id.',-1,*';
|
||||
$rrd_optionsb .= ' LINE1.25:'.$id.'i#'.$colour.":'$descr'";
|
||||
$rrd_options .= ' CDEF:' . $id . 'i=' . $id . ',' . $stacked['stacked'] . ',*';
|
||||
|
||||
$rrd_optionsb .= ' LINE1.25:' . $id . 'i#' . $colour . ":'$descr'";
|
||||
if (!empty($rrd['areacolour'])) {
|
||||
$rrd_optionsb .= ' AREA:'.$id.'i#'.$rrd['areacolour'];
|
||||
$rrd_optionsb .= ' AREA:' . $id . 'i#' . $rrd['areacolour'] . $stacked['transparency'];
|
||||
}
|
||||
} else {
|
||||
$rrd_optionsb .= ' LINE1.25:'.$id.'#'.$colour.":'$descr'";
|
||||
$rrd_optionsb .= ' LINE1.25:' . $id . '#' . $colour . ":'$descr'";
|
||||
if (!empty($rrd['areacolour'])) {
|
||||
$rrd_optionsb .= ' AREA:'.$id.'#'.$rrd['areacolour'];
|
||||
$rrd_optionsb .= ' AREA:' . $id . '#' . $rrd['areacolour'] . $stacked['transparency'];
|
||||
}
|
||||
}
|
||||
|
||||
$rrd_optionsb .= ' GPRINT:'.$id.':LAST:%5.2lf%s'.$units.' GPRINT:'.$id.'min:MIN:%5.2lf%s'.$units;
|
||||
$rrd_optionsb .= ' GPRINT:'.$id.'max:MAX:%5.2lf%s'.$units.' GPRINT:'.$id.":AVERAGE:'%5.2lf%s$units\\n'";
|
||||
$rrd_optionsb .= ' GPRINT:' . $id . ':LAST:%5.2lf%s' . $units . ' GPRINT:' . $id . 'min:MIN:%5.2lf%s' . $units;
|
||||
$rrd_optionsb .= ' GPRINT:' . $id . 'max:MAX:%5.2lf%s' . $units . ' GPRINT:' . $id . ":AVERAGE:'%5.2lf%s$units\\n'";
|
||||
|
||||
$i++;
|
||||
}//end foreach
|
||||
}
|
||||
|
||||
$rrd_options .= $rrd_optionsb;
|
||||
$rrd_options .= ' HRULE:0#555555';
|
||||
|
||||
unset($stacked);
|
||||
|
@@ -1,19 +1,33 @@
|
||||
<?php
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version. Please see LICENSE.txt at the top level of
|
||||
* the source code distribution for details.
|
||||
*
|
||||
* @package LibreNMS
|
||||
* @subpackage graphs
|
||||
* @link http://librenms.org
|
||||
* @copyright 2017 LibreNMS
|
||||
* @author LibreNMS Contributors
|
||||
*/
|
||||
|
||||
require 'includes/graphs/common.inc.php';
|
||||
|
||||
$stacked = generate_stacked_graphs();
|
||||
|
||||
$units_descr = substr(str_pad($units_descr, 18), 0, 18);
|
||||
|
||||
if ($format == 'octets' || $format == 'bytes') {
|
||||
$units = 'Bps';
|
||||
$units = 'Bps';
|
||||
$format = 'bits';
|
||||
// FIXME bits? or bytes?
|
||||
} else {
|
||||
$units = 'bps';
|
||||
$units = 'bps';
|
||||
$format = 'bits';
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
$i = 0;
|
||||
$rrd_options .= " COMMENT:'$units_descr Now Avg Max'";
|
||||
if (!$nototal) {
|
||||
$rrd_options .= " COMMENT:'Total'";
|
||||
@@ -26,7 +40,7 @@ foreach ($rrd_list as $rrd) {
|
||||
$iter = 0;
|
||||
}
|
||||
|
||||
$colour_in = $config['graph_colours'][$colours_in][$iter];
|
||||
$colour_in = $config['graph_colours'][$colours_in][$iter];
|
||||
$colour_out = $config['graph_colours'][$colours_out][$iter];
|
||||
|
||||
if ($rrd['colour_area_in']) {
|
||||
@@ -37,60 +51,60 @@ foreach ($rrd_list as $rrd) {
|
||||
$colour_out = $rrd['colour_area_out'];
|
||||
}
|
||||
|
||||
$rrd_options .= ' DEF:inB'.$i.'='.$rrd['filename'].':'.$rrd['ds_in'].':AVERAGE ';
|
||||
$rrd_options .= ' DEF:outB'.$i.'='.$rrd['filename'].':'.$rrd['ds_out'].':AVERAGE ';
|
||||
$rrd_options .= ' CDEF:octets'.$i.'=inB'.$i.',outB'.$i.',+';
|
||||
$rrd_options .= ' CDEF:inbits'.$i.'=inB'.$i.",$multiplier,* ";
|
||||
$rrd_options .= ' CDEF:outbits'.$i.'=outB'.$i.",$multiplier,*";
|
||||
$rrd_options .= ' CDEF:outbits'.$i.'_neg=outbits'.$i.',-1,*';
|
||||
$rrd_options .= ' CDEF:bits'.$i.'=inbits'.$i.',outbits'.$i.',+';
|
||||
$rrd_options .= ' DEF:inB' . $i . '=' . $rrd['filename'] . ':' . $rrd['ds_in'] . ':AVERAGE ';
|
||||
$rrd_options .= ' DEF:outB' . $i . '=' . $rrd['filename'] . ':' . $rrd['ds_out'] . ':AVERAGE ';
|
||||
$rrd_options .= ' CDEF:octets' . $i . '=inB' . $i . ',outB' . $i . ',+';
|
||||
$rrd_options .= ' CDEF:inbits' . $i . '=inB' . $i . ",$multiplier,* ";
|
||||
$rrd_options .= ' CDEF:outbits' . $i . '=outB' . $i . ",$multiplier,*";
|
||||
$rrd_options .= ' CDEF:outbits' . $i . '_neg=outbits' . $i . ',' . $stacked['stacked'] . ',*';
|
||||
$rrd_options .= ' CDEF:bits' . $i . '=inbits' . $i . ',outbits' . $i . ',+';
|
||||
|
||||
if ($_GET['previous']) {
|
||||
$rrd_options .= ' DEF:inB'.$i.'X='.$rrd['filename'].':'.$ds_in.':AVERAGE:start='.$prev_from.':end='.$from;
|
||||
$rrd_options .= ' DEF:outB'.$i.'X='.$rrd['filename'].':'.$ds_out.':AVERAGE:start='.$prev_from.':end='.$from;
|
||||
$rrd_options .= ' SHIFT:inB'.$i."X:$period";
|
||||
$rrd_options .= ' SHIFT:outB'.$i."X:$period";
|
||||
$in_thingX .= $seperatorX.'inB'.$i.'X,UN,0,'.'inB'.$i.'X,IF';
|
||||
$out_thingX .= $seperatorX.'outB'.$i.'X,UN,0,'.'outB'.$i.'X,IF';
|
||||
$plusesX .= $plusX;
|
||||
$seperatorX = ',';
|
||||
$plusX = ',+';
|
||||
$rrd_options .= ' DEF:inB' . $i . 'X=' . $rrd['filename'] . ':' . $ds_in . ':AVERAGE:start=' . $prev_from . ':end=' . $from;
|
||||
$rrd_options .= ' DEF:outB' . $i . 'X=' . $rrd['filename'] . ':' . $ds_out . ':AVERAGE:start=' . $prev_from . ':end=' . $from;
|
||||
$rrd_options .= ' SHIFT:inB' . $i . "X:$period";
|
||||
$rrd_options .= ' SHIFT:outB' . $i . "X:$period";
|
||||
$in_thingX .= $seperatorX . 'inB' . $i . 'X,UN,0,' . 'inB' . $i . 'X,IF';
|
||||
$out_thingX .= $seperatorX . 'outB' . $i . 'X,UN,0,' . 'outB' . $i . 'X,IF';
|
||||
$plusesX .= $plusX;
|
||||
$seperatorX = ',';
|
||||
$plusX = ',+';
|
||||
}
|
||||
|
||||
if (!$args['nototal']) {
|
||||
$in_thing .= $seperator.'inB'.$i.',UN,0,'.'inB'.$i.',IF';
|
||||
$out_thing .= $seperator.'outB'.$i.',UN,0,'.'outB'.$i.',IF';
|
||||
$pluses .= $plus;
|
||||
$seperator = ',';
|
||||
$plus = ',+';
|
||||
$in_thing .= $seperator . 'inB' . $i . ',UN,0,' . 'inB' . $i . ',IF';
|
||||
$out_thing .= $seperator . 'outB' . $i . ',UN,0,' . 'outB' . $i . ',IF';
|
||||
$pluses .= $plus;
|
||||
$seperator = ',';
|
||||
$plus = ',+';
|
||||
|
||||
$rrd_options .= ' VDEF:totinB'.$i.'=inB'.$i.',TOTAL';
|
||||
$rrd_options .= ' VDEF:totoutB'.$i.'=outB'.$i.',TOTAL';
|
||||
$rrd_options .= ' VDEF:tot'.$i.'=octets'.$i.',TOTAL';
|
||||
$rrd_options .= ' VDEF:totinB' . $i . '=inB' . $i . ',TOTAL';
|
||||
$rrd_options .= ' VDEF:totoutB' . $i . '=outB' . $i . ',TOTAL';
|
||||
$rrd_options .= ' VDEF:tot' . $i . '=octets' . $i . ',TOTAL';
|
||||
}
|
||||
|
||||
if ($i) {
|
||||
$stack = ':STACK';
|
||||
}
|
||||
|
||||
$rrd_options .= ' AREA:inbits'.$i.'#'.$colour_in.":'".rrdtool_escape($rrd['descr'], 9)."In '$stack";
|
||||
$rrd_options .= ' GPRINT:inbits'.$i.':LAST:%6.2lf%s';
|
||||
$rrd_options .= ' GPRINT:inbits'.$i.':AVERAGE:%6.2lf%s';
|
||||
$rrd_options .= ' GPRINT:inbits'.$i.':MAX:%6.2lf%s';
|
||||
$rrd_options .= ' AREA:inbits' . $i . '#' . $colour_in . $stacked['transparency'] . ":'" . rrdtool_escape($rrd['descr'], 9) . "In '$stack";
|
||||
$rrd_options .= ' GPRINT:inbits' . $i . ':LAST:%6.2lf%s';
|
||||
$rrd_options .= ' GPRINT:inbits' . $i . ':AVERAGE:%6.2lf%s';
|
||||
$rrd_options .= ' GPRINT:inbits' . $i . ':MAX:%6.2lf%s';
|
||||
|
||||
if (!$nototal) {
|
||||
$rrd_options .= ' GPRINT:totinB'.$i.":%6.2lf%s$total_units";
|
||||
$rrd_options .= ' GPRINT:totinB' . $i . ":%6.2lf%s$total_units";
|
||||
}
|
||||
|
||||
$rrd_options .= " COMMENT:'\\n'";
|
||||
$rrd_optionsb .= ' AREA:outbits'.$i.'_neg#'.$colour_out.":$stack";
|
||||
$rrd_options .= ' HRULE:999999999999999#'.$colour_out.":'".str_pad('', 10)."Out'";
|
||||
$rrd_options .= ' GPRINT:outbits'.$i.':LAST:%6.2lf%s';
|
||||
$rrd_options .= ' GPRINT:outbits'.$i.':AVERAGE:%6.2lf%s';
|
||||
$rrd_options .= ' GPRINT:outbits'.$i.':MAX:%6.2lf%s';
|
||||
$rrd_options .= " COMMENT:'\\n'";
|
||||
$rrd_optionsb .= ' AREA:outbits' . $i . '_neg#' . $colour_out . $stacked['transparency'] . ":$stack";
|
||||
$rrd_options .= ' HRULE:999999999999999#' . $colour_out . ":'" . str_pad('', 10) . "Out'";
|
||||
$rrd_options .= ' GPRINT:outbits' . $i . ':LAST:%6.2lf%s';
|
||||
$rrd_options .= ' GPRINT:outbits' . $i . ':AVERAGE:%6.2lf%s';
|
||||
$rrd_options .= ' GPRINT:outbits' . $i . ':MAX:%6.2lf%s';
|
||||
|
||||
if (!$nototal) {
|
||||
$rrd_options .= ' GPRINT:totoutB'.$i.":%6.2lf%s$total_units";
|
||||
$rrd_options .= ' GPRINT:totoutB' . $i . ":%6.2lf%s$total_units";
|
||||
}
|
||||
|
||||
$rrd_options .= " COMMENT:'\\n'";
|
||||
@@ -100,43 +114,43 @@ foreach ($rrd_list as $rrd) {
|
||||
|
||||
|
||||
if ($_GET['previous'] == 'yes') {
|
||||
$rrd_options .= ' CDEF:inBX='.$in_thingX.$plusesX;
|
||||
$rrd_options .= ' CDEF:outBX='.$out_thingX.$plusesX;
|
||||
$rrd_options .= ' CDEF:inBX=' . $in_thingX . $plusesX;
|
||||
$rrd_options .= ' CDEF:outBX=' . $out_thingX . $plusesX;
|
||||
$rrd_options .= ' CDEF:octetsX=inBX,outBX,+';
|
||||
$rrd_options .= ' CDEF:doutBX=outBX,-1,*';
|
||||
$rrd_options .= ' CDEF:doutBX=outBX,' . $stacked['stacked'] . ',*';
|
||||
$rrd_options .= ' CDEF:inbitsX=inBX,8,*';
|
||||
$rrd_options .= ' CDEF:outbitsX=outBX,8,*';
|
||||
$rrd_options .= ' CDEF:bitsX=inbitsX,outbitsX,+';
|
||||
$rrd_options .= ' CDEF:doutbitsX=doutBX,8,*';
|
||||
$rrd_options .= ' VDEF:percentile_inX=inbitsX,'.$config['percentile_value'].',PERCENT';
|
||||
$rrd_options .= ' VDEF:percentile_outX=outbitsX,'.$config['percentile_value'].',PERCENT';
|
||||
$rrd_options .= ' CDEF:dpercentile_outXn=doutbitsX,-1,*';
|
||||
$rrd_options .= ' VDEF:dpercentile_outX=dpercentile_outXn,'.$config['percentile_value'].',PERCENT';
|
||||
$rrd_options .= ' CDEF:dpercentile_outXn=doutbitsX,doutbitsX,-,dpercentile_outX,-1,*,+';
|
||||
$rrd_options .= ' VDEF:percentile_inX=inbitsX,' . $config['percentile_value'] . ',PERCENT';
|
||||
$rrd_options .= ' VDEF:percentile_outX=outbitsX,' . $config['percentile_value'] . ',PERCENT';
|
||||
$rrd_options .= ' CDEF:dpercentile_outXn=doutbitsX,' . $stacked['stacked'] . ',*';
|
||||
$rrd_options .= ' VDEF:dpercentile_outX=dpercentile_outXn,' . $config['percentile_value'] . ',PERCENT';
|
||||
$rrd_options .= ' CDEF:dpercentile_outXn=doutbitsX,doutbitsX,-,dpercentile_outX,' . $stacked['stacked'] . ',*,+';
|
||||
$rrd_options .= ' VDEF:dpercentile_outX=dpercentile_outXn,FIRST';
|
||||
}
|
||||
|
||||
if ($_GET['previous'] == 'yes') {
|
||||
$rrd_options .= ' AREA:in'.$format.'X#99999999:';
|
||||
$rrd_optionsb .= ' AREA:dout'.$format.'X#99999999:';
|
||||
$rrd_options .= ' LINE1.25:in'.$format.'X#666666:';
|
||||
$rrd_optionsb .= ' LINE1.25:dout'.$format.'X#666666:';
|
||||
$rrd_options .= ' AREA:in' . $format . 'X#99999999' . $stacked['transparency'] . ':';
|
||||
$rrd_optionsb .= ' AREA:dout' . $format . 'X#99999999' . $transparency . ':';
|
||||
$rrd_options .= ' LINE1.25:in' . $format . 'X#666666:';
|
||||
$rrd_optionsb .= ' LINE1.25:dout' . $format . 'X#666666:';
|
||||
}
|
||||
|
||||
if (!$args['nototal']) {
|
||||
$rrd_options .= ' CDEF:inB='.$in_thing.$pluses;
|
||||
$rrd_options .= ' CDEF:outB='.$out_thing.$pluses;
|
||||
$rrd_options .= ' CDEF:inB=' . $in_thing . $pluses;
|
||||
$rrd_options .= ' CDEF:outB=' . $out_thing . $pluses;
|
||||
$rrd_options .= ' CDEF:octets=inB,outB,+';
|
||||
$rrd_options .= ' CDEF:doutB=outB,-1,*';
|
||||
$rrd_options .= ' CDEF:doutB=outB,' . $stacked['stacked'] . ',*';
|
||||
$rrd_options .= ' CDEF:inbits=inB,8,*';
|
||||
$rrd_options .= ' CDEF:outbits=outB,8,*';
|
||||
$rrd_options .= ' CDEF:bits=inbits,outbits,+';
|
||||
$rrd_options .= ' CDEF:doutbits=doutB,8,*';
|
||||
$rrd_options .= ' VDEF:percentile_in=inbits,'.$config['percentile_value'].',PERCENT';
|
||||
$rrd_options .= ' VDEF:percentile_out=outbits,'.$config['percentile_value'].',PERCENT';
|
||||
$rrd_options .= ' CDEF:dpercentile_outn=doutbits,-1,*';
|
||||
$rrd_options .= ' VDEF:dpercentile_outnp=dpercentile_outn,'.$config['percentile_value'].',PERCENT';
|
||||
$rrd_options .= ' CDEF:dpercentile_outnpn=doutbits,doutbits,-,dpercentile_outnp,-1,*,+';
|
||||
$rrd_options .= ' VDEF:percentile_in=inbits,' . $config['percentile_value'] . ',PERCENT';
|
||||
$rrd_options .= ' VDEF:percentile_out=outbits,' . $config['percentile_value'] . ',PERCENT';
|
||||
$rrd_options .= ' CDEF:dpercentile_outn=doutbits,' . $stacked['stacked'] . ',*';
|
||||
$rrd_options .= ' VDEF:dpercentile_outnp=dpercentile_outn,' . $config['percentile_value'] . ',PERCENT';
|
||||
$rrd_options .= ' CDEF:dpercentile_outnpn=doutbits,doutbits,-,dpercentile_outnp,' . $stacked['stacked'] . ',*,+';
|
||||
$rrd_options .= ' VDEF:dpercentile_out=dpercentile_outnpn,FIRST';
|
||||
$rrd_options .= ' VDEF:totin=inB,TOTAL';
|
||||
$rrd_options .= ' VDEF:avein=inbits,AVERAGE';
|
||||
@@ -146,21 +160,21 @@ if (!$args['nototal']) {
|
||||
|
||||
$rrd_options .= " COMMENT:' \\n'";
|
||||
|
||||
$rrd_options .= " HRULE:999999999999999#FFFFFF:'".str_pad('Total', 10)."In '";
|
||||
$rrd_options .= " HRULE:999999999999999#FFFFFF:'" . str_pad('Total', 10) . "In '";
|
||||
$rrd_options .= ' GPRINT:inbits:LAST:%6.2lf%s';
|
||||
$rrd_options .= ' GPRINT:inbits:AVERAGE:%6.2lf%s';
|
||||
$rrd_options .= ' GPRINT:inbits:MAX:%6.2lf%s';
|
||||
$rrd_options .= " GPRINT:totin:%6.2lf%s$total_units";
|
||||
$rrd_options .= " COMMENT:'\\n'";
|
||||
|
||||
$rrd_options .= " HRULE:999999999999990#FFFFFF:'".str_pad('', 10)."Out'";
|
||||
$rrd_options .= " HRULE:999999999999990#FFFFFF:'" . str_pad('', 10) . "Out'";
|
||||
$rrd_options .= ' GPRINT:outbits:LAST:%6.2lf%s';
|
||||
$rrd_options .= ' GPRINT:outbits:AVERAGE:%6.2lf%s';
|
||||
$rrd_options .= ' GPRINT:outbits:MAX:%6.2lf%s';
|
||||
$rrd_options .= " GPRINT:totout:%6.2lf%s$total_units";
|
||||
$rrd_options .= " COMMENT:'\\n'";
|
||||
|
||||
$rrd_options .= " HRULE:999999999999990#FFFFFF:'".str_pad('', 10)."Agg'";
|
||||
$rrd_options .= " HRULE:999999999999990#FFFFFF:'" . str_pad('', 10) . "Agg'";
|
||||
$rrd_options .= ' GPRINT:bits:LAST:%6.2lf%s';
|
||||
$rrd_options .= ' GPRINT:bits:AVERAGE:%6.2lf%s';
|
||||
$rrd_options .= ' GPRINT:bits:MAX:%6.2lf%s';
|
||||
|
@@ -24,6 +24,10 @@ $graph_conf = array(
|
||||
'svg' => 'svg',
|
||||
),
|
||||
),
|
||||
array('name' => 'webui.graph_stacked',
|
||||
'descr' => 'Use stacked graphs',
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
);
|
||||
|
||||
$availability_map_conf = array(
|
||||
|
@@ -0,0 +1 @@
|
||||
INSERT INTO `config` (`config_name`, `config_value`, `config_default`, `config_descr`, `config_group`, `config_group_order`, `config_sub_group`, `config_sub_group_order`, `config_hidden`, `config_disabled`) VALUES('webui.graph_stacked', 'false', 'false', 'Display stacked graphs instead of inverted graphs', 'webui', 0, 'graph', 0, '0', '0');
|
||||
|
Reference in New Issue
Block a user