diff --git a/generate-map.sh b/generate-map.sh index 2b5788b87c..26b62a4d48 100755 --- a/generate-map.sh +++ b/generate-map.sh @@ -1,4 +1,4 @@ #!/bin/bash -./map.php > map.dot && unflatten -l5 -f map.dot | dot -Tpng -o html/network-big.png && convert -resize 400x500 html/network-big.png html/network.png +./map.php > map.dot && unflatten -l5 -f map.dot | fdp -Tpng -o html/network-big.png && convert -resize 400x500 html/network-big.png html/network.png ./map.php > map.dot && unflatten -l5 -f map.dot | dot -Tpng -o html/network-screen-big.png && convert -resize 900x2000 html/network-screen-big.png html/network-screen.png diff --git a/includes/discovery/cisco-cdp.inc.php b/includes/discovery/cisco-cdp.inc.php index 5d8b135431..f2bb8f02c8 100755 --- a/includes/discovery/cisco-cdp.inc.php +++ b/includes/discovery/cisco-cdp.inc.php @@ -7,7 +7,6 @@ echo("CISCO-CDP-MIB: "); unset($cdp_array); $cdp_array = snmpwalk_cache_twopart_oid("cdpCache", $device, $cdp_array, "CISCO-CDP-MIB"); $cdp_array = $cdp_array[$device[device_id]]; - if($cdp_array) { unset($cdp_links); foreach( array_keys($cdp_array) as $key) { @@ -15,12 +14,16 @@ if($cdp_array) { $cdp_if_array = $cdp_array[$key]; foreach( array_keys($cdp_if_array) as $entry_key) { $cdp_entry_array = $cdp_if_array[$entry_key]; - if($device['hostname'] && $interface['ifDescr'] && $cdp_entry_array['cdpCacheDeviceId'] && $cdp_entry_array['cdpCacheDevicePort']){ - $cdp_links .= $device['hostname'] . "," . $interface['ifDescr'] . "," . $cdp_entry_array['cdpCacheDeviceId'] . "," . $cdp_entry_array['cdpCacheDevicePort'] . "\n"; + if($device['hostname'] && $interface['ifIndex'] && $cdp_entry_array['cdpCacheDeviceId'] && $cdp_entry_array['cdpCacheDevicePort']){ + if(strpos($cdp_entry_array['cdpCacheDeviceId'], ")")) { list(,$cdp_entry_array['cdpCacheDeviceId']) = explode("(", $cdp_entry_array['cdpCacheDeviceId']); echo($cdp_entry_array['cdpCacheDeviceId']); + list($cdp_entry_array['cdpCacheDeviceId'],) = explode(")", $cdp_entry_array['cdpCacheDeviceId']); echo($cdp_entry_array['cdpCacheDeviceId']); } + + $cdp_links .= $device['hostname'] . "," . $interface['ifIndex'] . "," . $cdp_entry_array['cdpCacheDeviceId'] . "," . $cdp_entry_array['cdpCacheDevicePort'] . "\n"; } } } } +echo("$cdp_links"); if($cdp_links) { foreach ( explode("\n" ,$cdp_links) as $link ) { if ($link == "") { break; } @@ -43,13 +46,17 @@ if($cdp_links) { echo("!($dst_host)"); } + $dst_if_id = @mysql_result(mysql_query("SELECT I.interface_id FROM `interfaces` AS I, `devices` AS D WHERE `ifDescr` = '$dst_if' AND sysName = '$dst_host' AND D.device_id = I.device_id"), 0); + if(!$dst_if_id) { + $dst_if_id = @mysql_result(mysql_query("SELECT I.interface_id FROM `interfaces` AS I, `devices` AS D WHERE `ifName` = '$dst_if' AND sysName = '$dst_host' AND D.device_id = I.device_id"), 0); + } + if ( mysql_result(mysql_query("SELECT COUNT(*) FROM `devices` WHERE `sysName` = '$dst_host'"), 0) == '1' && mysql_result(mysql_query("SELECT COUNT(*) FROM `devices` WHERE `hostname` = '$src_host'"), 0) == '1' && - mysql_result(mysql_query("SELECT COUNT(*) FROM `interfaces` AS I, `devices` AS D WHERE `ifDescr` = '$dst_if' AND sysName = '$dst_host' AND D.device_id = I.device_id"), 0) == '1' && - mysql_result(mysql_query("SELECT COUNT(*) FROM `interfaces` AS I, `devices` AS D WHERE `ifDescr` = '$src_if' AND hostname = '$src_host' AND D.device_id = I.device_id"), 0) == '1') + $dst_if_id && + mysql_result(mysql_query("SELECT COUNT(*) FROM `interfaces` AS I, `devices` AS D WHERE `ifIndex` = '$src_if' AND hostname = '$src_host' AND D.device_id = I.device_id"), 0) == '1') { - $dst_if_id = mysql_result(mysql_query("SELECT I.interface_id FROM `interfaces` AS I, `devices` AS D WHERE `ifDescr` = '$dst_if' AND sysName = '$dst_host' AND D.device_id = I.device_id"), 0); - $src_if_id = mysql_result(mysql_query("SELECT I.interface_id FROM `interfaces` AS I, `devices` AS D WHERE `ifDescr` = '$src_if' AND hostname = '$src_host' AND D.device_id = I.device_id"), 0); + $src_if_id = mysql_result(mysql_query("SELECT I.interface_id FROM `interfaces` AS I, `devices` AS D WHERE `ifIndex` = '$src_if' AND hostname = '$src_host' AND D.device_id = I.device_id"), 0); $linkalive[] = $src_if_id . "," . $dst_if_id; if ( mysql_result(mysql_query("SELECT COUNT(*) FROM `links` WHERE `dst_if` = '$dst_if_id' AND `src_if` = '$src_if_id'"),0) == '0') { diff --git a/includes/discovery/interfaces.php b/includes/discovery/interfaces.php index 21ab260238..bc0444544b 100755 --- a/includes/discovery/interfaces.php +++ b/includes/discovery/interfaces.php @@ -31,7 +31,7 @@ $if = trim(strtolower($ifDescr)); $nullintf = 0; foreach($config['bad_if'] as $bi) { if (strstr($if, $bi)) { $nullintf = 1; } } - if($device['os'] == "CatOS" && strstr($if, "vlan") ) { $nullintf = 1; } + if($device['os'] == "catos" && strstr($if, "vlan") ) { $nullintf = 1; } $ifDescr = fixifName($ifDescr); if (preg_match('/serial[0-9]:/', $if)) { $nullintf = 1; } if(!$config['allow_ng']) { diff --git a/map.php b/map.php index 6b4d27f382..e4b0c1efd5 100755 --- a/map.php +++ b/map.php @@ -24,7 +24,7 @@ while($loc_data = mysql_fetch_array($loc_result)) { style=filled; color=lightgrey;\n\n"); - $dev_sql = "SELECT * FROM devices WHERE location = '" . $loc_data['location'] . "' and `os` LIKE '%ios%' and disabled = 0"; + $dev_sql = "SELECT * FROM devices WHERE location = '" . $loc_data['location'] . "' and (`os` LIKE '%ios%' OR `os` LIKE '%catos%') AND disabled = 0"; $dev_result = mysql_query($dev_sql); while($dev_data = mysql_fetch_array($dev_result)) { $device_id = $dev_data['device_id'];