add mac accounting improvements and fixes to graph display page

git-svn-id: http://www.observium.org/svn/observer/trunk@471 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2009-09-22 12:02:54 +00:00
parent 128a26a4f1
commit 661d0935a3
9 changed files with 134 additions and 77 deletions
-41
View File
@@ -571,47 +571,6 @@ function graph_mac_acc ($id, $graph, $from, $to, $width, $height) {
}
function graph_mac_acc_interface ($interface, $graph, $from, $to, $width, $height) {
global $config, $installdir;
$imgfile = $config['install_dir'] . "/graphs/" . "$graph";
$options = "--alt-autoscale-max -E --start $from --end " . ($to - 150) . " --width $width --height $height ";
$options .= $config['rrdgraph_def_text'];
if($height < "99") { $options .= " --only-graph"; }
$hostname = gethostbyid($device);
$query = mysql_query("SELECT * FROM `mac_accounting` AS M, `interfaces` AS I, `devices` AS D WHERE M.interface_id = '$interface' AND I.interface_id = M.interface_id AND I.device_id = D.device_id");
if($width <= "300") { $options .= "--font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
$pluses = "";
$options .= " COMMENT:' In Out\\\\n'";
while($acc = mysql_fetch_array($query)) {
$this_rrd = $config['rrd_dir'] . "/" . $acc['hostname'] . "/mac-accounting/" . $acc['ifIndex'] . "-" . $acc['peer_ip'] . ".rrd";
if(is_file($this_rrd)) {
$this_id = str_replace(".", "", $acc['peer_ip']);
if($iter=="1") {$colour="CC0000";} elseif($iter=="2") {$colour="008C00";} elseif($iter=="3") {$colour="4096EE";
} elseif($iter=="4") {$colour="73880A";} elseif($iter=="5") {$colour="D01F3C";} elseif($iter=="6") {$colour="36393D";
} elseif($iter=="7") {$colour="FF0084"; unset($iter); } else {$colour="C600C6";}
$descr = str_pad($acc['peer_desc'], 36);
$descr = substr($descr,0,36);
$options .= " DEF:in".$this_id."=$this_rrd:IN:AVERAGE ";
$options .= " DEF:out".$this_id."temp=$this_rrd:OUT:AVERAGE ";
$options .= " CDEF:out".$this_id."=out".$this_id."temp,-1,* ";
$options .= " CDEF:octets".$this_id."=in".$this_id.",out".$this_id."temp,+";
$options .= " VDEF:totin".$this_id."=in".$this_id.",TOTAL";
$options .= " VDEF:totout".$this_id."=out".$this_id."temp,TOTAL";
$options .= " VDEF:tot".$this_id."=octets".$this_id.",TOTAL";
$options .= " LINE1.25:in".$this_id."#" . $colour . ":'" . $descr . "'";
$options .= " LINE1.25:out".$this_id."#" . $colour . "::";
$options .= " GPRINT:in".$this_id.":LAST:%6.2lf%sbps";
$options .= " GPRINT:totin".$this_id.":\(%6.2lf%sB\)";
$options .= " GPRINT:out".$this_id."temp:LAST:%6.2lf%sbps";
$options .= " GPRINT:totout".$this_id.":\(%6.2lf%sB\)\\\\n";
$iter++;
}
}
#echo($config['rrdtool'] . " graph $imgfile $options");
$thing = shell_exec($config['rrdtool'] . " graph $imgfile $options");
return $imgfile;
}
function graph_bits ($rrd, $graph, $from, $to, $width, $height, $title, $vertical, $inverse = '0', $legend = '1') {
global $config;
$database = $config['rrd_dir'] . "/" . $rrd;
-1
View File
@@ -1,6 +1,5 @@
<?php
function formatMac($mac) {
$mac = preg_replace("/(..)(..)(..)(..)(..)(..)/", "\\1:\\2:\\3:\\4:\\5:\\6", $mac);
return $mac;