fixes to cdp! (now works with CatOS)

git-svn-id: http://www.observium.org/svn/observer/trunk@535 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2009-11-28 10:38:02 +00:00
parent 2221cde433
commit 71afb5cbee
4 changed files with 17 additions and 10 deletions

View File

@@ -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

View File

@@ -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')
{

View File

@@ -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']) {

View File

@@ -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'];