diff --git a/html/graph.php b/html/graph.php index 7fc9ccb44..650a19afa 100644 --- a/html/graph.php +++ b/html/graph.php @@ -64,6 +64,7 @@ if($_GET['debug']) { $graph = graph_netscreen_memory ($hostname . "/netscreen-memory.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical); break; case 'multi_bits': + if($_GET['if']) { $_GET['interfaces'] = $_GET['if']; } $graph = graph_multi_bits ($_GET['interfaces'], $graphfile, $from, $to, $width, $height, $title, $vertical, $inverse, $legend); break; case 'adsl_rate': diff --git a/html/pages/iftype.php b/html/pages/iftype.php index 81d4d37a6..787a89760 100644 --- a/html/pages/iftype.php +++ b/html/pages/iftype.php @@ -3,7 +3,26 @@ if($bg == "#ffffff") { $bg = "#e5e5e5"; } else { $bg="#ffffff"; } echo(""); if($_GET['type']) { + $type = $_GET['type']; + $sql = "select * from interfaces as I, devices as D WHERE `ifAlias` like '$type: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; + $query = mysql_query($sql); + while($interface = mysql_fetch_array($query)) { + $if_list .= $seperator . $interface['interface_id']; + $seperator = ","; + } + unset($seperator); + + echo(" + "); + + echo(""); + + $sql = "select * from interfaces as I, devices as D WHERE `ifAlias` like '$type: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; $query = mysql_query($sql); while($interface = mysql_fetch_array($query)) { diff --git a/includes/discovery/ipv6-addresses.php b/includes/discovery/ipv6-addresses.php index effb987d6..1715cb71d 100644 --- a/includes/discovery/ipv6-addresses.php +++ b/includes/discovery/ipv6-addresses.php @@ -53,7 +53,8 @@ if($ipv6interfaces){ echo("+"); } else { echo("."); } $full_address = "$ipv6_address/$ipv6_prefixlen"; - $valid_v6[$full_address] = 1; + $valid = $full_address . "-" . $interface_id; + $valid_v6[$valid] = 1; } } } @@ -63,7 +64,9 @@ $sql = "SELECT * FROM ipv6_addresses AS A, interfaces AS I WHERE I.device_id = $data = mysql_query($sql); while($row = mysql_fetch_array($data)) { $full_address = $row['ipv6_address'] . "/" . $row['ipv6_prefixlen']; - if(!$valid_v6[$full_address]) { + $interface_id = $row['interface_id']; + $valid = $full_address . "-" . $interface_id; + if(!$valid_v6[$valid]) { echo("-"); $query = @mysql_query("DELETE FROM `ipv6_addresses` WHERE `ipv6_address_id` = '".$row['ipv6_address_id']."'"); if(!mysql_result(mysql_query("SELECT count(*) FROM ipv6_addresses WHERE ipv6_network_id = '".$row['ipv6_network_id']."'"),0)) { diff --git a/includes/functions.php b/includes/functions.php index 86e9b395d..9802d1ac1 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -23,6 +23,31 @@ require('collectd/functions.php'); require('collectd/definitions.php'); +function mac_clean_to_readable($mac){ + + $r = substr($mac, 0, 2); + $r .= ":".substr($mac, 2, 2); + $r .= ":".substr($mac, 4, 2); + $r .= ":".substr($mac, 6, 2); + $r .= ":".substr($mac, 8, 2); + $r .= ":".substr($mac, 10, 2); + + return($r); +} + +function zeropad($num) +{ + return (strlen($num) == 1) ? '0'.$num : $num; +} + +function zeropad_lineno($num, $length) +{ + while (strlen($num) < $length) + $num = '0'.$num; + + return $num; +} + function only_alphanumeric( $string ) { return preg_replace('/[^a-zA-Z0-9]/', '', $string); diff --git a/includes/graphing.php b/includes/graphing.php index 7962b1222..408b256c1 100644 --- a/includes/graphing.php +++ b/includes/graphing.php @@ -273,7 +273,7 @@ function graph_mac_acc ($id, $graph, $from, $to, $width, $height) { $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['peer_ip'] . ".rrd"; + $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 "; if($height < "33") { $options .= " --only-graph"; } $period = $to - $from; diff --git a/poll-mac_accounting.php b/poll-mac_accounting.php index 4dac6fd31..db8459e5c 100755 --- a/poll-mac_accounting.php +++ b/poll-mac_accounting.php @@ -7,18 +7,36 @@ $mac_accounting_query = mysql_query("SELECT * FROM `mac_accounting` as A, `interfaces` AS I, `devices` AS D where A.interface_id = I.interface_id AND I.device_id = D.device_id AND D.status = '1'"); while ($acc = mysql_fetch_array($mac_accounting_query)) { - echo("Polling :" . $acc['peer_ip']. " " . $acc['ifDescr']. " " . $acc['hostname'] . " "); + echo("Polling :" . $acc['ip']. " " . $acc['ifDescr']. " " . $acc['mac'] . " " . $acc['hostname'] . " "); + + $mac = $acc['mac']; + + $oid = hexdec(substr($mac, 0, 2)); + $oid .= ".".hexdec(substr($mac, 2, 2)); + $oid .= ".".hexdec(substr($mac, 4, 2)); + $oid .= ".".hexdec(substr($mac, 6, 2)); + $oid .= ".".hexdec(substr($mac, 8, 2)); + $oid .= ".".hexdec(substr($mac, 10, 2)); $snmp_cmd = $config['snmpget'] . " -m CISCO-IP-STAT-MIB -O Uqnv -" . $acc['snmpver'] . " -c " . $acc['community'] . " " . $acc['hostname']; - $snmp_cmd .= " " . $acc['in_oid'] . " " . $acc['out_oid']; + $snmp_cmd .= " cipMacSwitchedBytes.". $acc['ifIndex'] .".input." . $oid; + $snmp_cmd .= " cipMacSwitchedBytes.". $acc['ifIndex'] .".output." . $oid; - $snmp_output = trim(`$snmp_cmd`); + $snmp_output = trim(shell_exec($snmp_cmd)); + + $snmp_output = preg_replace("[a-zA-Z\ ]", "", $snmp_output); list($in,$out) = 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"); } - $rrdfile = $acc_rrd . "/" . $acc['ifIndex'] . "-" . $acc['peer_ip'] . ".rrd"; + + $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"); }; + if(!is_file($rrdfile)) { $woo = shell_exec($config['rrdtool'] ." create $rrdfile \ @@ -34,7 +52,7 @@ RRA:MAX:0.5:288:797"); } - $woo = "N:$in:$out"; + $woo = "N:".($in+0).":".($out+0); $ret = rrdtool_update("$rrdfile", $woo); $rates = interface_rates ($rrdfile); diff --git a/process-syslog.php b/process-syslog.php index ec9b86db4..2d19569ef 100755 --- a/process-syslog.php +++ b/process-syslog.php @@ -8,6 +8,9 @@ mysql_query("DELETE FROM `syslog` WHERE `processed` = '0' AND `msg` LIKE '%last mysql_query("DELETE FROM `syslog` WHERE `processed` = '0' AND `msg` LIKE '%Connection from UDP: [%]:%'"); mysql_query("DELETE FROM `syslog` WHERE `processed` = '0' AND `msg` LIKE '%Traceback%'"); mysql_query("DELETE FROM `syslog` WHERE `processed` = '0' AND `msg` LIKE '%PM-3-INVALID_BRIDGE_PORT%'"); +mysql_query("DELETE FROM `syslog` WHERE `processed` = '0' AND `msg` LIKE '%RHWatchdog%'"); +mysql_query("DELETE FROM `syslog` WHERE `processed` = '0' AND `msg` LIKE '%Hardware Monitoring%'"); +
Total Graph for interfaces of type : ".$type."
"); + $graph_type = "multi_bits"; + $interface['interface_id'] = $if_list; + include("includes/print-interface-graphs.php"); + echo("