diff --git a/html/pages/customers.php b/html/pages/customers.php
index bd97428be..30985d393 100644
--- a/html/pages/customers.php
+++ b/html/pages/customers.php
@@ -1,14 +1,27 @@
");
+ echo("
+
+ |
+ Customer |
+ Device |
+ Interface |
+ Speed |
+ Circuit |
+ Notes |
+
+ ");
+
+ $customers = 1;
while($interface = mysql_fetch_array($query)) {
$device = &$interface;
@@ -16,26 +29,21 @@
$ifname = fixifname($device['ifDescr']);
- $interface['ifAlias'] = str_replace("Cust: ", "", $interface['ifAlias']);
- $interface['ifAlias'] = str_replace("[PNI]", "Private", $interface['ifAlias']);
-
$ifclass = ifclass($interface['ifOperStatus'], $interface['ifAdminStatus']);
-
- $displayifalias = $device['ifAlias'];
- $device['ifAlias'] = str_replace(" [","|",$device['ifAlias']);
- $device['ifAlias'] = str_replace("] (","|",$device['ifAlias']);
- $device['ifAlias'] = str_replace(" (","||",$device['ifAlias']);
- $device['ifAlias'] = str_replace("]","|",$device['ifAlias']);
- $device['ifAlias'] = str_replace(")","|",$device['ifAlias']);
- list($device['ifAlias'],$class,$notes) = explode("|", $device['ifAlias']);
- $useifalias = $device['ifAlias'];
- $used = '1';
- if ($device['ifAlias'] == $previfalias) { unset($useifalias );
- } elseif ($previfalias) {
- echo(" |
");
- if($bg == "#ffffff") { $bg = "#e5e5e5"; } else { $bg="#ffffff"; }
+
+ list(,$customer) = preg_split("/[\:\[\]\{\}\(\)]/", $interface['ifAlias']);
+ list(,$circuit) = preg_split("/[\{\}]/", $interface['ifAlias']);
+ list(,$notes) = preg_split("/[\(\)]/", $interface['ifAlias']);
+ list(,$speed) = preg_split("/[\[\]]/", $interface['ifAlias']);
+
+
+ if ($customer == $prev_customer) {
+ unset($customer);
+ } else {
+ if(is_integer($customers/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; }
+ $customers++;
+ $prev_customer = $customer;
}
- $previfalias = $device['ifAlias'];
if($device['os'] == "IOS") {
@@ -46,12 +54,13 @@
}
echo("
-
+
|
- $useifalias |
- " . generatedevicelink($device) . " |
+ $customer |
+ " . generatedevicelink($device) . " |
" . generateiflink($interface, makeshortif($interface['ifDescr'])) . " |
- $vlan |
+ $speed |
+ $circuit |
$notes |
");
diff --git a/includes/discovery/cisco-mac-accounting.php b/includes/discovery/cisco-mac-accounting.php
new file mode 100755
index 000000000..ee5b52b15
--- /dev/null
+++ b/includes/discovery/cisco-mac-accounting.php
@@ -0,0 +1,76 @@
+
+
+ unset ($mac_table);
+
+ $ipNetToMedia_data = shell_exec($config['snmpbulkwalk'] . " -m IP-MIB -Oq -".$device['snmpver']." -c ".$config['community']." ".$device['hostname']." ipNetToMediaPhysAddress");
+ $ipNetToMedia_data = str_replace("ipNetToMediaPhysAddress.", "", trim($ipNetToMedia_data));
+ $ipNetToMedia_data = str_replace("IP-MIB::", "", trim($ipNetToMedia_data));
+ foreach(explode("\n", $ipNetToMedia_data) as $data) {
+ list($oid, $mac) = explode(" ", $data);
+ list($if, $first, $second, $third, $fourth) = explode(".", $oid);
+ list($m_a, $m_b, $m_c, $m_d, $m_e, $m_f) = explode(":", $mac);
+ $interface = mysql_fetch_array(mysql_query("SELECT * FROM interfaces WHERE device_id = '".$device['device_id']."' AND ifIndex = '".$if."'"));
+ $ip = $first .".". $second .".". $third .".". $fourth;
+ $m_a = zeropad($m_a);
+ $m_b = zeropad($m_b);
+ $m_c = zeropad($m_c);
+ $m_d = zeropad($m_d);
+ $m_e = zeropad($m_e);
+ $m_f = zeropad($m_f);
+ $md_a = hexdec($m_a);
+ $md_b = hexdec($m_b);
+ $md_c = hexdec($m_c);
+ $md_d = hexdec($m_d);
+ $md_e = hexdec($m_e);
+ $md_f = hexdec($m_f);
+ $mac = "$m_a:$m_b:$m_c:$m_d:$m_e:$m_f";
+ $mac_table[$if][$mac]['ip'] = $ip;
+ $mac_table[$if][$mac]['ciscomac'] = "$m_a$m_b.$m_c$m_d.$m_e$m_f";
+ $clean_mac = $m_a . $m_b . $m_c . $m_d . $m_e . $m_f;
+ $mac_table[$if][$mac]['cleanmac'] = $clean_mac;
+ if(mysql_result(mysql_query("SELECT COUNT(*) from ipv4_mac WHERE interface_id = '".$interface['interface_id']."' AND ipv4_address = '$ip'"),0)) {
+ $sql = "UPDATE `ipv4_mac` SET `mac_address` = '$clean_mac' WHERE interface_id = '".$interface['interface_id']."' AND ipv4_address = '$ip'";
+ mysql_query($sql);
+ } else {
+ #echo("Add MAC $mac\n");
+ mysql_query("INSERT INTO `ipv4_mac` (interface_id, mac_address, ipv4_address) VALUES ('".$interface['interface_id']."','$clean_mac','$ip')");
+ }
+ }
+
+ $datas = shell_exec($config['snmpbulkwalk'] . " -m CISCO-IP-STAT-MIB -Oqn -".$device['snmpver']." -c ".$config['community']." ".$device['hostname']." cipMacSwitchedBytes");
+ $datas = trim($datas);
+ foreach(explode("\n", $datas) as $data) {
+ list($oid) = explode(" ", $data);
+ $oid = str_replace(".1.3.6.1.4.1.9.9.84.1.2.1.1.4.", "", $oid);
+ list($if, $direction, $a_a, $a_b, $a_c, $a_d, $a_e, $a_f) = explode(".", $oid);
+ $oid = "$a_a.$a_b.$a_c.$a_d.$a_e.$a_f";
+ unset($interface);
+ $interface = mysql_fetch_array(mysql_query("SELECT * FROM interfaces WHERE device_id = '".$device['device_id']."' AND ifIndex = '".$if."'"));
+ $ah_a = zeropad(dechex($a_a));
+ $ah_b = zeropad(dechex($a_b));
+ $ah_c = zeropad(dechex($a_c));
+ $ah_d = zeropad(dechex($a_d));
+ $ah_e = zeropad(dechex($a_e));
+ $ah_f = zeropad(dechex($a_f));
+ $mac = "$ah_a:$ah_b:$ah_c:$ah_d:$ah_e:$ah_f";
+ $mac_cisco = "$ah_a$ah_b.$ah_c$ah_d.$ah_e$ah_f";
+ $mac_cisco = $mac_table[$if][$mac]['ciscomac'];
+ $clean_mac = $mac_table[$if][$mac]['cleanmac'];
+ $ip = $mac_table[$if][$mac]['ip'];
+ if($ip && $interface) {
+ $new_mac = str_replace(":", "", $mac);
+ echo($interface['ifDescr'] . " ($if) -> $mac ($oid) -> $ip -> $name");
+ if(mysql_result(mysql_query("SELECT COUNT(*) from mac_accounting WHERE interface_id = '".$interface['interface_id']."' AND mac = '$clean_mac'"),0)) {
+ #$sql = "UPDATE `mac_accounting` SET `mac` = '$clean_mac' WHERE interface_id = '".$interface['interface_id']."' AND `mac` = '$clean_mac'";
+ #mysql_query($sql);
+ #if(mysql_affected_rows()) { echo(" UPDATED!"); }
+ #echo($sql);
+ } else {
+ #echo(" Not Exists!");
+ mysql_query("INSERT INTO `mac_accounting` (interface_id, mac) VALUES ('".$interface['interface_id']."','$clean_mac')");
+ }
+ echo("\n");
+ }
+ }
+
+?>