more code cleanup (last commit for now)

git-svn-id: http://www.observium.org/svn/observer/trunk@2520 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans
2011-09-20 14:37:54 +00:00
parent f87ed09e1b
commit 9a1bee1458
71 changed files with 296 additions and 293 deletions

View File

@@ -27,7 +27,7 @@ function makeTextBlock($text, $fontfile, $fontsize, $width) {
$currentLine = 0;
foreach ($words as $word) {
$lineSize = imagettfbbox($fontsize, 0, $fontfile, $lines[$currentLine] . ' ' . $word);
if($lineSize[2] - $lineSize[0] < $width) {
if ($lineSize[2] - $lineSize[0] < $width) {
$lines[$currentLine] .= ' ' . $word;
} else {
$currentLine++;
@@ -47,6 +47,7 @@ function makeTextBlock($text, $fontfile, $fontsize, $width) {
*/
function error($code, $code_msg, $title, $msg) {
global $config;
header(sprintf("HTTP/1.0 %d %s", $code, $code_msg));
header("Pragma: no-cache");
header("Expires: Mon, 01 Jan 2008 00:00:00 CET");
@@ -197,9 +198,9 @@ if (isset($MetaGraphDefs[$type])) {
if(isset($rrd_cmd))
{
if($config['rrdcached']) { $rrd_cmd .= " --daemon ".$config['rrdcached'] . " "; }
if($_GET['from']) { $from = mres($_GET['from']); }
if($_GET['to']) { $to = mres($_GET['to']); }
if ($config['rrdcached']) { $rrd_cmd .= " --daemon ".$config['rrdcached'] . " "; }
if ($_GET['from']) { $from = mres($_GET['from']); }
if ($_GET['to']) { $to = mres($_GET['to']); }
$rrd_cmd .= " -s " . $from . " -e " . $to;
}

View File

@@ -23,7 +23,7 @@ foreach($stats as $stat => $colour)
$rrd_list[$i]['filename'] = $rrd_filename;
$rrd_list[$i]['descr'] = str_replace("icmp", "", $stat);
$rrd_list[$i]['rra'] = $stat;
if(strpos($stat, "Out") !== FALSE)
if (strpos($stat, "Out") !== FALSE)
{
$rrd_list[$i]['invert'] = TRUE;
}

View File

@@ -23,7 +23,7 @@ foreach($stats as $stat => $array)
$rrd_list[$i]['filename'] = $rrd_filename;
$rrd_list[$i]['descr'] = str_replace("icmp", "", $stat);
$rrd_list[$i]['rra'] = $stat;
if(strpos($stat, "Out") !== FALSE)
if (strpos($stat, "Out") !== FALSE)
{
$rrd_list[$i]['invert'] = TRUE;
}

View File

@@ -20,7 +20,7 @@ foreach($stats as $stat => $array)
$rrd_list[$i]['filename'] = $rrd_filename;
$rrd_list[$i]['descr'] = str_replace("ip", "", $stat);
$rrd_list[$i]['rra'] = $stat;
if(strpos($stat, "Out") !== FALSE)
if (strpos($stat, "Out") !== FALSE)
{
$rrd_list[$i]['invert'] = TRUE;
}

View File

@@ -20,7 +20,7 @@ foreach($stats as $stat)
$rrd_list[$i]['filename'] = $rrd_filename;
$rrd_list[$i]['descr'] = str_replace("snmp", "", $stat);
$rrd_list[$i]['rra'] = $stat;
if(strpos($stat, "Out") !== FALSE)
if (strpos($stat, "Out") !== FALSE)
{
$rrd_list[$i]['invert'] = TRUE;
}

View File

@@ -15,7 +15,7 @@ foreach($stats as $stat)
$rrd_list[$i]['filename'] = $rrd_filename;
$rrd_list[$i]['descr'] = str_replace("snmp", "", $stat);
$rrd_list[$i]['rra'] = $stat;
if(strpos($stat, "Out") !== FALSE)
if (strpos($stat, "Out") !== FALSE)
{
$rrd_list[$i]['invert'] = TRUE;
}

View File

@@ -14,7 +14,7 @@ foreach($stats as $stat)
$rrd_list[$i]['filename'] = $rrd_filename;
$rrd_list[$i]['descr'] = str_replace("tcp", "", $stat);
$rrd_list[$i]['rra'] = $stat;
if(strpos($stat, "Out") !== FALSE || strpos($stat, "Retrans") !== FALSE || strpos($stat, "Attempt") !== FALSE)
if (strpos($stat, "Out") !== FALSE || strpos($stat, "Retrans") !== FALSE || strpos($stat, "Attempt") !== FALSE)
{
$rrd_list[$i]['invert'] = TRUE;
}

View File

@@ -14,7 +14,7 @@ foreach($stats as $stat)
$rrd_list[$i]['filename'] = $rrd_filename;
$rrd_list[$i]['descr'] = str_replace("udp", "", $stat);
$rrd_list[$i]['rra'] = $stat;
if(strpos($stat, "Out") !== FALSE || strpos($stat, "Retrans") !== FALSE || strpos($stat, "Attempt") !== FALSE)
if (strpos($stat, "Out") !== FALSE || strpos($stat, "Retrans") !== FALSE || strpos($stat, "Attempt") !== FALSE)
{
$rrd_list[$i]['invert'] = TRUE;
}

View File

@@ -38,8 +38,8 @@ $rrd_options .= " CDEF:inbits=inoctets,8,*";
$rrd_options .= " CDEF:inbits_max=inoctets_max,8,*";
if ($config['rrdgraph_real_95th']) {
$rrd_options .= " CDEF:highbits=inoctets,outoctets,MAX,8,*";
$rrd_options .= " VDEF:95thhigh=highbits,95,PERCENT";
$rrd_options .= " CDEF:highbits=inoctets,outoctets,MAX,8,*";
$rrd_options .= " VDEF:95thhigh=highbits,95,PERCENT";
}
$rrd_options .= " VDEF:totin=inoctets,TOTAL";
@@ -67,8 +67,8 @@ $rrd_options .= " GPRINT:outbits_max:MAX:%6.2lf%s";
$rrd_options .= " GPRINT:95thout:%6.2lf%s\\\\n";
if ($config['rrdgraph_real_95th']) {
$rrd_options .= " HRULE:95thhigh#FF0000:\"Highest\"";
$rrd_options .= " GPRINT:95thhigh:\"%30.2lf%s\\n\"";
$rrd_options .= " HRULE:95thhigh#FF0000:\"Highest\"";
$rrd_options .= " GPRINT:95thhigh:\"%30.2lf%s\\n\"";
}
$rrd_options .= " GPRINT:tot:'Total %6.2lf%s'";

View File

@@ -27,7 +27,7 @@ foreach ($rrd_list as $rrd)
$rrd_options .= " DEF:".$id."=$filename:$rra:AVERAGE";
if(!$basicrrd)
if (!$basicrrd)
{
$rrd_options .= " DEF:".$id."min=$filename:$rra:MIN";
$rrd_options .= " DEF:".$id."max=$filename:$rra:MAX";
@@ -45,7 +45,7 @@ foreach ($rrd_list as $rrd)
}
if(!$basicrrd)
if (!$basicrrd)
{
$rrd_optionsb .= " GPRINT:".$id.":LAST:%5.2lf%s GPRINT:".$id."min:MIN:%5.2lf%s";
$rrd_optionsb .= " GPRINT:".$id."max:MAX:%5.2lf%s GPRINT:".$id.":AVERAGE:'%5.2lf%s\\n'";

View File

@@ -48,7 +48,7 @@ foreach ($rrd_list as $i => $rrd)
}
## Are our text values related to te multiplier/divisor or not?
if(isset($text_orig) && $text_orig)
if (isset($text_orig) && $text_orig)
{
$t_defname = $rrd['rra'];
} else {

View File

@@ -5,7 +5,7 @@ if (is_numeric($id))
$acc = dbFetchRow("SELECT * FROM `mac_accounting` AS M, `ports` AS I, `devices` AS D WHERE M.ma_id = ? AND I.interface_id = M.interface_id AND I.device_id = D.device_id", array($id));
if($debug) {
if ($debug) {
echo("<pre>");
print_r($acc);
echo("</pre>");
@@ -14,13 +14,13 @@ if (is_numeric($id))
if (is_array($acc))
{
if($auth || port_permitted($acc['interface_id']))
if ($auth || port_permitted($acc['interface_id']))
{
if($debug) { echo($config['rrd_dir'] . "/" . $acc['hostname'] . "/" . safename("cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd")); }
if ($debug) { echo($config['rrd_dir'] . "/" . $acc['hostname'] . "/" . safename("cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd")); }
if(is_file($config['rrd_dir'] . "/" . $acc['hostname'] . "/" . safename("cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd")))
if (is_file($config['rrd_dir'] . "/" . $acc['hostname'] . "/" . safename("cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd")))
{
if($debug) { echo("exists"); }
if ($debug) { echo("exists"); }
$rrd_filename = $config['rrd_dir'] . "/" . $acc['hostname'] . "/" . safename("cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd");
$port = get_port_by_id($acc['interface_id']);
$device = device_by_id_cache($port['device_id']);