diff --git a/html/.htaccess b/html/.htaccess index 24978ad47e..560897103f 100644 --- a/html/.htaccess +++ b/html/.htaccess @@ -30,6 +30,7 @@ RewriteRule ^vrf/(.+)/(.+)/(.+)/ ?page=vrf&id=$1&opta=$2&optb=$3 RewriteRule ^vrf/(.+)/(.+)/ ?page=vrf&id=$1&opta=$2 RewriteRule ^vrf/(.+)/ ?page=vrf&id=$1 +RewriteRule ^device/([0-9]+)/([a-z]+)/(.+)/(.+)/(.+)/(.+)/ ?page=device&id=$1§ion=$2&opta=$3&optb=$4&optc=$5&optd=$6 RewriteRule ^device/([0-9]+)/([a-z]+)/(.+)/(.+)/(.+)/ ?page=device&id=$1§ion=$2&opta=$3&optb=$4&optc=$5 RewriteRule ^device/([0-9]+)/([a-z]+)/(.+)/(.+)/ ?page=device&id=$1§ion=$2&opta=$3&optb=$4 RewriteRule ^device/([0-9]+)/([a-z]+)/(.+)/ ?page=device&id=$1§ion=$2&opta=$3 diff --git a/html/graph.php b/html/graph.php index 09a8c4c10d..b22f7098e0 100644 --- a/html/graph.php +++ b/html/graph.php @@ -96,7 +96,11 @@ if($_GET['debug']) { case 'mac_acc_int': $graph = graph_mac_acc_interface ($_GET['if'], $graphfile, $from, $to, $width, $height, $title, $vertical); break; + case 'mac_acc_pkts': + $graph = graph_mac_pkts ($_GET['id'], $graphfile, $from, $to, $width, $height, $title, $vertical); + break; case 'mac_acc': + case 'mac_acc_bits': $graph = graph_mac_acc ($_GET['id'], $graphfile, $from, $to, $width, $height, $title, $vertical); break; case 'device_bits': diff --git a/html/pages/device/interface.inc.php b/html/pages/device/interface.inc.php index 32b7ea1d5b..115ea30a8e 100644 --- a/html/pages/device/interface.inc.php +++ b/html/pages/device/interface.inc.php @@ -42,14 +42,45 @@ $interface = mysql_fetch_array($interface_query); $broke = yes; } -if( !$broke) -{ } - echo("
"); +echo(" +
+ + + + + + +
+
+ +Graphs | +ARP Table"); + + if(mysql_result(mysql_query("SELECT count(*) FROM mac_accounting WHERE interface_id = '".$interface['interface_id']."'"),0)){ + + echo(" | Mac Accounting : + Bits + (Mini) | + Packets + (Mini)"); + } + +echo("
+
+ + + + + + +
+"); + if($_GET['optb']) { -include("pages/device/".mres($_GET['optb']).".php"); +include("pages/device/port/".mres($_GET['optb']).".php"); } else { diff --git a/html/pages/device/macaccounting.php b/html/pages/device/port/macaccounting.php similarity index 86% rename from html/pages/device/macaccounting.php rename to html/pages/device/port/macaccounting.php index 7064c3d69c..0a7ec37679 100644 --- a/html/pages/device/macaccounting.php +++ b/html/pages/device/port/macaccounting.php @@ -1,11 +1,5 @@ -Full | -Compact -
"); - - $hostname = $device['hostname']; $hostid = $device['interface_id']; $ifname = $interface['ifDescr']; @@ -24,20 +18,19 @@ echo("
"); while($acc = mysql_fetch_array($query)) { + if(!is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } + $addy = mysql_fetch_array(mysql_query("SELECT * FROM ipv4_mac where mac_address = '".$acc['mac']."'")); $name = gethostbyaddr($addy['ipv4_address']); if($name == $addy['ipv4_address']) { unset ($name); } - if($bg == "#ffffff") { $bg = "#e5e5e5"; } else { $bg="#ffffff"; } if(mysql_result(mysql_query("SELECT count(*) FROM bgpPeers WHERE device_id = '".$acc['device_id']."' AND bgpPeerIdentifier = '".$addy['ipv4_address']."'"),0)) { $peer_query = mysql_query("SELECT * FROM bgpPeers WHERE device_id = '".$acc['device_id']."' AND bgpPeerIdentifier = '".$addy['ipv4_address']."'"); @@ -50,7 +43,13 @@ echo("
".$name." - ".$addy['ipv4_address']." - ".$asn."
\ - \ + \ ', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" > - + ".$name."
"); } else { - echo("
"); + echo("
"); echo(" @@ -83,9 +82,6 @@ echo("
$remote_host
"); - + echo(""); if ($mac_acc['interface_id'] == $interface['interface_id']) { - echo(""); + $style = "onmouseover=\"return overlib('', LEFT".$config['overlib_defaults'].", WIDTH, 500);\" onmouseout=\"return nd();\""; + echo(""); } else { echo(""); } diff --git a/includes/graphing.php b/includes/graphing.php index 7ba673a0f6..8751b6acb2 100644 --- a/includes/graphing.php +++ b/includes/graphing.php @@ -571,54 +571,6 @@ function graph_mac_acc ($id, $graph, $from, $to, $width, $height) { } -function graph_mac_acc_old ($id, $graph, $from, $to, $width, $height) { - global $config; - $imgfile = $config['install_dir'] . "/graphs/" . "$graph"; - $query = mysql_query("SELECT * FROM `mac_accounting` AS M, `interfaces` AS I, `devices` AS D WHERE M.ma_id = '".$id."' AND I.interface_id = M.interface_id AND I.device_id = D.device_id"); - $acc = mysql_fetch_array($query); - $database = $config['rrd_dir'] . "/" . $acc['hostname'] . "/mac-accounting/" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd"; - $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"; } - $period = $to - $from; - $options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height "; - if($height < "99") { $options .= " --only-graph"; } - if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; } - $options .= " DEF:inoctets=$database:IN:AVERAGE"; - $options .= " DEF:outoctets=$database:OUT:AVERAGE"; - $options .= " CDEF:octets=inoctets,outoctets,+"; - $options .= " CDEF:doutoctets=outoctets,-1,*"; - $options .= " CDEF:inbits=inoctets,8,*"; - $options .= " CDEF:outbits=outoctets,8,*"; - $options .= " CDEF:doutbits=doutoctets,8,*"; - $options .= " VDEF:totin=inoctets,TOTAL"; - $options .= " VDEF:totout=outoctets,TOTAL"; - $options .= " VDEF:tot=octets,TOTAL"; - $options .= " VDEF:95thin=inbits,95,PERCENT"; - $options .= " VDEF:95thout=outbits,95,PERCENT"; - $options .= " VDEF:d95thout=doutbits,5,PERCENT"; - $options .= " AREA:inbits#CDEB8B:"; - $options .= " COMMENT:BPS\ \ \ \ Current\ \ \ Average\ \ \ \ \ \ Max\ \ \ 95th\ %\\\\n"; - $options .= " LINE1.25:inbits#006600:In\ "; - $options .= " GPRINT:inbits:LAST:%6.2lf%s"; - $options .= " GPRINT:inbits:AVERAGE:%6.2lf%s"; - $options .= " GPRINT:inbits:MAX:%6.2lf%s"; - $options .= " GPRINT:95thin:%6.2lf%s\\\\n"; - $options .= " AREA:doutbits#C3D9FF:"; - $options .= " LINE1.25:doutbits#000099:Out"; - $options .= " GPRINT:outbits:LAST:%6.2lf%s"; - $options .= " GPRINT:outbits:AVERAGE:%6.2lf%s"; - $options .= " GPRINT:outbits:MAX:%6.2lf%s"; - $options .= " GPRINT:95thout:%6.2lf%s\\\\n"; - $options .= " GPRINT:tot:Total\ %6.2lf%s"; - $options .= " GPRINT:totin:\(In\ %6.2lf%s"; - $options .= " GPRINT:totout:Out\ %6.2lf%s\)\\\\l"; - $options .= " LINE1:95thin#aa0000"; - $options .= " LINE1:d95thout#aa0000"; - $thing = shell_exec($config['rrdtool'] . " graph $imgfile $options"); - return $imgfile; -} - function graph_mac_acc_interface ($interface, $graph, $from, $to, $width, $height) { global $config, $installdir; $imgfile = $config['install_dir'] . "/graphs/" . "$graph"; @@ -762,6 +714,35 @@ function pktsgraph ($rrd, $graph, $from, $to, $width, $height) { return $imgfile; } +function graph_mac_pkts ($id, $graph, $from, $to, $width, $height) { + global $config, $installdir; + $imgfile = $config['install_dir'] . "/graphs/" . "$graph"; + $query = mysql_query("SELECT * FROM `mac_accounting` AS M, `interfaces` AS I, `devices` AS D WHERE M.ma_id = '".$id."' AND I.interface_id = M.interface_id AND I.device_id = D.device_id"); + $acc = mysql_fetch_array($query); + $database = $config['rrd_dir'] ."/". $acc['hostname'] . "/mac-accounting/" . $acc['ifIndex'] . "-" . $acc['mac'] . "-pkts.rrd"; + $imgfile = $config['install_dir'] . "/graphs/" . "$graph"; + $options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height "; + $options .= $config['rrdgraph_def_text']; + if($height < "99") { $options .= " --only-graph"; unset ($legend); } + if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; } + $options .= " DEF:in=$database:IN:AVERAGE"; + $options .= " DEF:out=$database:OUT:AVERAGE"; + $options .= " CDEF:dout=out,-1,*"; + $options .= " AREA:in#aa66aa:"; + $options .= " COMMENT:Packets\ \ \ \ Current\ \ \ \ \ Average\ \ \ \ \ \ Maximum\\\\n"; + $options .= " LINE1.25:in#330033:In\ \ "; + $options .= " GPRINT:in:LAST:%6.2lf%spps"; + $options .= " GPRINT:in:AVERAGE:%6.2lf%spps"; + $options .= " GPRINT:in:MAX:%6.2lf%spps\\\\n"; + $options .= " AREA:dout#FFDD88:"; + $options .= " LINE1.25:dout#FF6600:Out\ "; + $options .= " GPRINT:out:LAST:%6.2lf%spps"; + $options .= " GPRINT:out:AVERAGE:%6.2lf%spps"; + $options .= " GPRINT:out:MAX:%6.2lf%spps\\\\n"; + $thing = shell_exec($config['rrdtool'] . " graph $imgfile $options"); + return $imgfile; +} + function errorgraph ($rrd, $graph, $from, $to, $width, $height) { global $config, $installdir; $database = $config['rrd_dir'] . "/" . $rrd; diff --git a/poll-mac_accounting.php b/poll-mac_accounting.php index 5e2b332b45..8870651039 100755 --- a/poll-mac_accounting.php +++ b/poll-mac_accounting.php @@ -21,22 +21,35 @@ $snmp_cmd = $config['snmpget'] . " -m CISCO-IP-STAT-MIB -O Uqnv -" . $acc['snmpver'] . " -c " . $acc['community'] . " " . $acc['hostname']; $snmp_cmd .= " cipMacSwitchedBytes.". $acc['ifIndex'] .".input." . $oid; $snmp_cmd .= " cipMacSwitchedBytes.". $acc['ifIndex'] .".output." . $oid; + $snmp_cmd .= " cipMacSwitchedPkts.". $acc['ifIndex'] .".input." . $oid; + $snmp_cmd .= " cipMacSwitchedPkts.". $acc['ifIndex'] .".output." . $oid; $snmp_output = trim(shell_exec($snmp_cmd)); $snmp_output = preg_replace("[a-zA-Z\ ]", "", $snmp_output); - list($in,$out) = explode("\n", $snmp_output); + list($in,$out,$pktin,$pktout) = explode("\n", $snmp_output); $acc_rrd = $config['rrd_dir'] . "/" . $acc['hostname'] . "/mac-accounting"; - if(!is_dir($acc_rrd)) { mkdir($acc_rrd); echo("Created directory : $acc_rrd\n"); } - $old_rrdfile = $acc_rrd . "/" . $acc['ifIndex'] . "-" . $acc['ip'] . ".rrd"; $rrdfile = $acc_rrd . "/" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd"; - if(is_file($old_rrdfile) && !is_file($rrdfile)) { rename($old_rrdfile, $rrdfile); echo("Moved $old_rrdfile -> $rrdfile \n"); }; + $pkts_rrdfile = $acc_rrd . "/" . $acc['ifIndex'] . "-" . $acc['mac'] . "-pkts.rrd"; + if(!is_file($pkts_rrdfile)) { + $woo = shell_exec($config['rrdtool'] ." create $pkts_rrdfile \ + DS:IN:COUNTER:600:0:12500000000 \ + DS:OUT:COUNTER:600:0:12500000000 \ + RRA:AVERAGE:0.5:1:600 \ + RRA:AVERAGE:0.5:6:700 \ + RRA:AVERAGE:0.5:24:775 \ + RRA:AVERAGE:0.5:288:797 \ + RRA:MAX:0.5:1:600 \ + RRA:MAX:0.5:6:700 \ + RRA:MAX:0.5:24:775 \ + RRA:MAX:0.5:288:797"); + } if(!is_file($rrdfile)) { $woo = shell_exec($config['rrdtool'] ." create $rrdfile \ @@ -55,10 +68,19 @@ $woo = "N:".($in+0).":".($out+0); $ret = rrdtool_update("$rrdfile", $woo); - $rates = interface_rates ($rrdfile); - mysql_query("UPDATE `mac_accounting` SET bps_in = '" . $rates['in'] . "', bps_out = '" . $rates['out'] . "' WHERE ma_id= '" . $acc['ma_id'] . "'"); + $woo = "N:".($pktin+0).":".($pktout+0); + $ret = rrdtool_update("$pkts_rrdfile", $woo); - echo(formatRates($rates['in']) . " in " . formatRates($rates['out']) . " out \n"); + $rates = interface_rates ($rrdfile); + + $pkt_rates = interface_rates ($pkts_rrdfile); + + $pkt_rate['in'] = round($pkt_rate['in'] / 8); + $pkt_rate['out'] = round($pkt_rate['out'] / 8); + + mysql_query("UPDATE `mac_accounting` SET bps_in = '" . $rates['in'] . "', bps_out = '" . $rates['out'] . "', pps_in = '" . $pkt_rates['in'] . "', pps_out = '" . $pkt_rates['out'] . "' WHERE ma_id= '" . $acc['ma_id'] . "'"); + + echo(formatRates($rates['in']) . " (" . $pkt_rates['in'] . "pps) in " . formatRates($rates['out']) . " (" . $pkt_rates['out'] . "pps) out \n"); } ?>
$remote_port".truncate($remote_host, 24, "")."$remote_port".formatRates($mac_acc['bps_out'])."".formatRates($mac_acc['bps_in'])."".formatRates($mac_acc['bps_out'])."".formatRates($mac_acc['bps_in'])."