mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
introducing rrdtool_escape, more to come
git-svn-id: http://www.observium.org/svn/observer/trunk@3229 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -34,7 +34,7 @@ foreach ($rrd_list as $rrd)
|
|||||||
$ds = $rrd['ds'];
|
$ds = $rrd['ds'];
|
||||||
$filename = $rrd['filename'];
|
$filename = $rrd['filename'];
|
||||||
|
|
||||||
$descr = str_replace(":", "\:", substr(str_pad($rrd['descr'], $descr_len),0,$descr_len));
|
$descr = rrdtool_escape($rrd['descr'], $descr_len);
|
||||||
|
|
||||||
$id = "ds".$i;
|
$id = "ds".$i;
|
||||||
|
|
||||||
|
@@ -34,12 +34,12 @@ foreach ($rrd_list as $rrd)
|
|||||||
|
|
||||||
if (isset($rrd['descr_in']))
|
if (isset($rrd['descr_in']))
|
||||||
{
|
{
|
||||||
$descr = str_replace(":", "\:", substr(str_pad($rrd['descr_in'], $descr_len),0,$descr_len)) . " In";
|
$descr = rrdtool_escape($rrd['descr_in'], $descr_len) . " In";
|
||||||
} else {
|
} else {
|
||||||
$descr = str_replace(":", "\:", substr(str_pad($rrd['descr'], $descr_len),0,$descr_len)) . " In";
|
$descr = rrdtool_escape($rrd['descr'], $descr_len) . " In";
|
||||||
}
|
}
|
||||||
$descr_out = str_replace(":", "\:", substr(str_pad($rrd['descr_out'], $descr_len),0,$descr_len)). " Out";
|
$descr_out = rrdtool_escape($rrd['descr_out'], $descr_len) . " Out";
|
||||||
$descr = str_replace("'", "", $descr);
|
$descr = str_replace("'", "", $descr); # FIXME does this mean ' should be filtered in rrdtool_escape? probably...
|
||||||
$descr_out = str_replace("'", "", $descr_out);
|
$descr_out = str_replace("'", "", $descr_out);
|
||||||
|
|
||||||
$rrd_options .= " DEF:".$in.$i."=".$rrd['filename'].":".$ds_in.":AVERAGE ";
|
$rrd_options .= " DEF:".$in.$i."=".$rrd['filename'].":".$ds_in.":AVERAGE ";
|
||||||
|
@@ -34,13 +34,12 @@ foreach ($rrd_list as $rrd)
|
|||||||
|
|
||||||
if (isset($rrd['descr_in']))
|
if (isset($rrd['descr_in']))
|
||||||
{
|
{
|
||||||
$descr = str_replace(":", "\:", substr(str_pad($rrd['descr_in'], $descr_len),0,$descr_len)) . " In";
|
$descr = rrdtool_escape($rrd['descr_in'], $descr_len) . " In";
|
||||||
} else {
|
} else {
|
||||||
$descr = str_replace(":", "\:", substr(str_pad($rrd['descr'], $descr_len),0,$descr_len)) . " In";
|
$descr = rrdtool_escape($rrd['descr'], $descr_len) . " In";
|
||||||
}
|
}
|
||||||
$descr_out = str_replace(":", "\:", substr(str_pad($rrd['descr_out'], $descr_len),0,$descr_len)). " Out";
|
$descr_out = rrdtool_escape($rrd['descr_out'], $descr_len) . " Out";
|
||||||
|
$descr = str_replace("'", "", $descr); # FIXME does this mean ' should be filtered in rrdtool_escape? probably...
|
||||||
$descr = str_replace("'", "", $descr);
|
|
||||||
$descr_out = str_replace("'", "", $descr_out);
|
$descr_out = str_replace("'", "", $descr_out);
|
||||||
|
|
||||||
$rrd_options .= " DEF:".$in.$i."=".$rrd['filename'].":".$ds_in.":AVERAGE ";
|
$rrd_options .= " DEF:".$in.$i."=".$rrd['filename'].":".$ds_in.":AVERAGE ";
|
||||||
|
@@ -34,7 +34,7 @@ foreach ($rrd_list as $rrd)
|
|||||||
$ds = $rrd['ds'];
|
$ds = $rrd['ds'];
|
||||||
$filename = $rrd['filename'];
|
$filename = $rrd['filename'];
|
||||||
|
|
||||||
$descr = str_replace(":", "\:", substr(str_pad($rrd['descr'], $descr_len),0,$descr_len));
|
$descr = rrdtool_escape($rrd['descr'], $descr_len);
|
||||||
|
|
||||||
$id = "ds".$i;
|
$id = "ds".$i;
|
||||||
|
|
||||||
|
@@ -7,7 +7,7 @@ $units_descr = substr(str_pad($units_descr, 18),0,18);
|
|||||||
if($format == "octets" || $format == "bytes")
|
if($format == "octets" || $format == "bytes")
|
||||||
{
|
{
|
||||||
$units = "Bps";
|
$units = "Bps";
|
||||||
$format = "bits";
|
$format = "bits"; # FIXME bits? or bytes?
|
||||||
} else {
|
} else {
|
||||||
$units = "bps";
|
$units = "bps";
|
||||||
$format = "bits";
|
$format = "bits";
|
||||||
@@ -64,7 +64,7 @@ foreach ($rrd_list as $rrd)
|
|||||||
|
|
||||||
if ($i) { $stack="STACK"; }
|
if ($i) { $stack="STACK"; }
|
||||||
|
|
||||||
$rrd_options .= " AREA:inbits".$i."#" . $colour_in . ":'" . substr(str_pad($rrd['descr'], 10),0,10) . "In ':$stack";
|
$rrd_options .= " AREA:inbits".$i."#" . $colour_in . ":'" . rrdtool_escape($rrd['descr'], 10) . "In ':$stack";
|
||||||
$rrd_options .= " GPRINT:inbits".$i.":LAST:%6.2lf%s";
|
$rrd_options .= " GPRINT:inbits".$i.":LAST:%6.2lf%s";
|
||||||
$rrd_options .= " GPRINT:inbits".$i.":AVERAGE:%6.2lf%s";
|
$rrd_options .= " GPRINT:inbits".$i.":AVERAGE:%6.2lf%s";
|
||||||
$rrd_options .= " GPRINT:inbits".$i.":MAX:%6.2lf%s";
|
$rrd_options .= " GPRINT:inbits".$i.":MAX:%6.2lf%s";
|
||||||
|
@@ -4,9 +4,9 @@ include("includes/graphs/common.inc.php");
|
|||||||
|
|
||||||
if($width > "500")
|
if($width > "500")
|
||||||
{
|
{
|
||||||
$descr_len=24;
|
$descr_len = 24; # FIXME may even be more imo?
|
||||||
} else {
|
} else {
|
||||||
$descr_len=12;
|
$descr_len = 12;
|
||||||
$descr_len += round(($width - 250) / 8);
|
$descr_len += round(($width - 250) / 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ foreach ($rrd_list as $i => $rrd)
|
|||||||
$colour_iter++;
|
$colour_iter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$descr = str_replace(":", "\:", substr(str_pad($rrd['descr'], $descr_len),0,$descr_len));
|
$descr = rrdtool_escape($rrd['descr'], $descr_len);
|
||||||
|
|
||||||
$rrd_options .= " DEF:".$rrd['ds'].$i."=".$rrd['filename'].":".$rrd['ds'].":AVERAGE ";
|
$rrd_options .= " DEF:".$rrd['ds'].$i."=".$rrd['filename'].":".$rrd['ds'].":AVERAGE ";
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ foreach ($rrd_list as $i => $rrd)
|
|||||||
$rrd_options .= " GPRINT:".$t_defname.$i.":LAST:%5.2lf%s GPRINT:".$t_defname.$i."min:MIN:%5.2lf%s";
|
$rrd_options .= " GPRINT:".$t_defname.$i.":LAST:%5.2lf%s GPRINT:".$t_defname.$i."min:MIN:%5.2lf%s";
|
||||||
$rrd_options .= " GPRINT:".$t_defname.$i."max:MAX:%5.2lf%s GPRINT:".$t_defname.$i.":AVERAGE:'%5.2lf%s\\n'";
|
$rrd_options .= " GPRINT:".$t_defname.$i."max:MAX:%5.2lf%s GPRINT:".$t_defname.$i.":AVERAGE:'%5.2lf%s\\n'";
|
||||||
|
|
||||||
if (!$nototal) { $rrd_options .= " GPRINT:tot".$rrd['ds'].$i.":%6.2lf%s".str_replace("%", "%%", $total_units).""; }
|
if (!$nototal) { $rrd_options .= " GPRINT:tot".$rrd['ds'].$i.":%6.2lf%s".rrdtool_escape($total_units).""; }
|
||||||
|
|
||||||
$rrd_options .= " COMMENT:'\\n'";
|
$rrd_options .= " COMMENT:'\\n'";
|
||||||
}
|
}
|
||||||
|
@@ -224,4 +224,19 @@ function rrdtool_lastupdate($filename, $options)
|
|||||||
return rrdtool("lastupdate", $filename, $options);
|
return rrdtool("lastupdate", $filename, $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function rrdtool_escape($string, $maxlength = NULL)
|
||||||
|
{
|
||||||
|
$result = str_replace(':','\:',$string);
|
||||||
|
$result = str_replace('%','%%',$result);
|
||||||
|
|
||||||
|
if ($maxlength != NULL)
|
||||||
|
{
|
||||||
|
return substr(str_pad($result, $maxlength),0,$maxlength+(strlen($result)-strlen($string)));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
Reference in New Issue
Block a user