Commit version 24.12.13800

This commit is contained in:
2025-01-06 17:35:06 -05:00
parent b7f6a79c2c
commit 55d9218816
6133 changed files with 4239740 additions and 1374287 deletions

View File

@ -4,69 +4,74 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage graphs
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage graphs
* @copyright (C) Adam Armstrong
*
*/
// Here we scale the number of numerical columns shown to make sure we keep the text.
if ($width > 600) {
$data_show = array('lst', 'avg', 'min', 'max', 'tot');
$data_show = ['lst', 'avg', 'min', 'max', 'tot'];
} elseif ($width > 400) {
$data_show = array('lst', 'avg', 'max', 'tot');
$data_show = ['lst', 'avg', 'max', 'tot'];
} elseif ($width > 300) {
$data_show = array('lst', 'avg', 'max', 'tot');
$data_show = ['lst', 'avg', 'max', 'tot'];
} else {
$data_show = array('lst', 'avg', 'max');
$data_show = ['lst', 'avg', 'max'];
}
// Drop total from view if requested not to show
if ($args['nototal'] || $nototal)
{
if (($key = array_search('tot', $data_show)) !== FALSE)
{
unset($data_show[$key]);
}
if ($args['nototal'] || $nototal) {
if (($key = array_search('tot', $data_show)) !== FALSE) {
unset($data_show[$key]);
}
}
// Here we scale the length of the description to make sure we keep the numbers
$data_len = safe_count($data_show) * 8;
if ($width > 600) {
$descr_len = 40;
$descr_len = 40;
} elseif ($width > 300) {
$descr_len = floor(($width + 42) / 8) - $data_len;
$descr_len = floor(($width + 42) / 8) - $data_len;
} else {
$descr_len = floor(($width + 42) / 7) - $data_len;
$descr_len = floor(($width + 42) / 7) - $data_len;
}
// Build the legend headers using the length values previously calculated
if (!isset($unit_text))
{
if ($format == "octets" || $format == "bytes")
{
$units = "Bps";
$format = "bytes";
$unit_text = "Bytes/s";
} else {
$units = "bps";
$format = "bits";
$unit_text = "Bits/s";
}
if (!isset($unit_text)) {
if ($format == "octets" || $format == "bytes") {
$units = "Bps";
$format = "bytes";
$unit_text = "Bytes/s";
} else {
$units = "bps";
$format = "bits";
$unit_text = "Bits/s";
}
}
if ($legend != 'no')
{
$rrd_options .= " COMMENT:'".rrdtool_escape($unit_text, $descr_len)."'";
if (in_array("lst", $data_show)) { $rrd_options .= " COMMENT:' Now'"; }
if (in_array("avg", $data_show)) { $rrd_options .= " COMMENT:' Avg'"; }
if (in_array("min", $data_show)) { $rrd_options .= " COMMENT:' Min'"; }
if (in_array("max", $data_show)) { $rrd_options .= " COMMENT:' Max'"; }
if (in_array("tot", $data_show)) { $rrd_options .= " COMMENT:' Total'"; }
$rrd_options .= " COMMENT:'\\l'";
if ($legend != 'no') {
$rrd_options .= " COMMENT:'" . rrdtool_escape($unit_text, $descr_len) . "'";
if (in_array("lst", $data_show)) {
$rrd_options .= " COMMENT:' Now'";
}
if (in_array("avg", $data_show)) {
$rrd_options .= " COMMENT:' Avg'";
}
if (in_array("min", $data_show)) {
$rrd_options .= " COMMENT:' Min'";
}
if (in_array("max", $data_show)) {
$rrd_options .= " COMMENT:' Max'";
}
if (in_array("tot", $data_show)) {
$rrd_options .= " COMMENT:' Total'";
}
$rrd_options .= " COMMENT:'\\l'";
$graph_return['legend_lines']++;
$graph_return['legend_lines']++;
}