Improve the formating of some graphs (#5507)

This commit is contained in:
David Bell
2017-01-24 09:53:38 +00:00
committed by Neil Lathwood
parent 998750ddd9
commit 755860fec5
6 changed files with 8 additions and 46 deletions

View File

@@ -19,7 +19,7 @@ require 'includes/graphs/common.inc.php';
$rrd_filename = rrd_name($device['hostname'], 'ping-perf');
$rrd_options .= ' DEF:ping='.$rrd_filename.':ping:AVERAGE';
$rrd_options .= " 'COMMENT:Seconds Current Minimum Maximum Average\\n'";
$rrd_options .= " 'COMMENT:Seconds Cur Min Max Avg\\n'";
$rrd_options .= ' LINE1.25:ping#36393D:Ping';
$rrd_options .= ' GPRINT:ping:LAST:%6.2lf GPRINT:ping:AVERAGE:%6.2lf';
$rrd_options .= " GPRINT:ping:MAX:%6.2lf 'GPRINT:ping:AVERAGE:%6.2lf\\n'";

View File

@@ -19,7 +19,7 @@ require 'includes/graphs/common.inc.php';
$rrd_filename = rrd_name($device['hostname'], 'poller-perf');
$rrd_options .= ' DEF:poller='.$rrd_filename.':poller:AVERAGE';
$rrd_options .= " 'COMMENT:Seconds Current Minimum Maximum Average\\n'";
$rrd_options .= " 'COMMENT:Seconds Cur Min Max Avg\\n'";
$rrd_options .= ' LINE1.25:poller#36393D:Poller';
$rrd_options .= ' GPRINT:poller:LAST:%6.2lf GPRINT:poller:MIN:%6.2lf';
$rrd_options .= " GPRINT:poller:MAX:%6.2lf 'GPRINT:poller:AVERAGE:%6.2lf\\n'";

View File

@@ -2,15 +2,9 @@
require 'includes/graphs/common.inc.php';
if ($_GET['width'] > '300') {
$descr_len = '40';
} else {
$descr_len = '22';
}
$rrd_options .= ' -E ';
$iter = '1';
$rrd_options .= " COMMENT:'".str_pad($unit_long, $descr_len)." Cur Min Max\\n'";
$rrd_options .= " COMMENT:'$unit_long Cur Min Max\\n'";
foreach (dbFetchRows('SELECT * FROM `sensors` WHERE `sensor_class` = ? AND `device_id` = ? ORDER BY `sensor_index`', array($class, $device['device_id'])) as $sensor) {
// FIXME generic colour function
@@ -46,7 +40,7 @@ foreach (dbFetchRows('SELECT * FROM `sensors` WHERE `sensor_class` = ? AND `devi
break;
}//end switch
$sensor['sensor_descr_fixed'] = substr(str_pad($sensor['sensor_descr'], $descr_len), 0, $descr_len);
$sensor['sensor_descr_fixed'] = rrdtool_escape($sensor['sensor_descr'], 12);
$rrd_file = get_sensor_rrd($device, $sensor);
$rrd_options .= ' DEF:sensor'.$sensor['sensor_id']."=$rrd_file:sensor:AVERAGE ";
$rrd_options .= ' LINE1:sensor'.$sensor['sensor_id'].'#'.$colour.":'".str_replace(':', '\:', str_replace('\*', '*', $sensor['sensor_descr_fixed']))."'";

View File

@@ -19,28 +19,14 @@
require 'includes/graphs/common.inc.php';
if ($width > '500') {
$descr_len = 24;
} else {
$descr_len = 12;
$descr_len += round(($width - 250) / 8);
}
$descr_len = 12;
if ($nototal) {
$descr_len += '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'";
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:'".rrdtool_escape($unit_text, $descr_len)." Now Min Max Avg\l'";
$i = 0;
$iter = 0;

View File

@@ -2,31 +2,14 @@
require 'includes/graphs/common.inc.php';
if ($width > '500') {
$descr_len = 24;
// FIXME may even be more imo?
} else {
$descr_len = 12;
$descr_len += round(($width - 250) / 8);
}
$descr_len = 12;
if ($nototal) {
$descr_len += '2';
$unitlen += '2';
}
$unit_text = str_pad(truncate($unit_text, $unitlen), $unitlen);
if ($width > '500') {
$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:'".rrdtool_escape($unit_text, $descr_len)." Now Min Max Avg\l'";
$unitlen = '10';
if ($nototal) {

View File

@@ -275,7 +275,6 @@ function rrdtool_escape($string, $length = null)
{
$result = shorten_interface_type($string);
$result = str_replace("'", '', $result); # remove quotes
$result = str_replace('%', '%%', $result); # double percent signs
if (is_numeric($length)) {
$extra = substr_count($string, ':', 0, $length);
$result = substr(str_pad($result, $length), 0, ($length + $extra));