diff --git a/discovery.php b/discovery.php index 28391594d2..99edfa3f7d 100755 --- a/discovery.php +++ b/discovery.php @@ -95,7 +95,7 @@ while ($device = mysql_fetch_array($device_query)) { include("includes/discovery/cisco-processors.php"); include("includes/discovery/cemp-mib.php"); include("includes/discovery/cmp-mib.php"); - include("includes/discovery/cisco-cdp.inc.php"); + include("includes/discovery/cdp-lldp.inc.php"); if ($device['type'] == "unknown") { $device['type'] = 'network'; }; } @@ -103,6 +103,7 @@ while ($device = mysql_fetch_array($device_query)) { if ($device['os'] == "procurve" || $device['os'] == "powerconnect") { include("includes/discovery/q-bridge-mib.php"); + include("includes/discovery/cdp-lldp.inc.php"); if ($device['type'] == "unknown") { $device['type'] = 'network'; }; } diff --git a/includes/discovery/cdp-lldp.inc.php b/includes/discovery/cdp-lldp.inc.php new file mode 100755 index 0000000000..cb6a06c388 --- /dev/null +++ b/includes/discovery/cdp-lldp.inc.php @@ -0,0 +1,159 @@ + $dst_host $dst_if)"); + } else { + echo(".."); + } + } else { + + } + } +} + + +$sql = "SELECT * FROM `links` AS L, `interfaces` AS I, `devices` AS D WHERE L.src_if = I.interface_id AND I.device_id = D.device_id AND D.device_id = '".$device['device_id']."'"; +$query = mysql_query($sql); + +while ($test_link = mysql_fetch_array($query)) { + unset($exists); + $i = 0; + while ($i < count($link_exists) && !$exists) { + $this_link = $test_link['src_if'] . ",". $test_link['dst_if']; + if ($link_exists[$i] == $this_link) { $exists = 1; } + $i++; + } + if(!$exists) { + echo("-"); + mysql_query("DELETE FROM `links` WHERE `src_if` = '".$test_link['src_if']."' AND `dst_if` = '".$test_link['dst_if']."'"); + if($debug) { echo($link_exists[$i] . " REMOVED \n"); } + } else { + if($debug) { echo($link_exists[$i] . " VALID \n"); } + } +} + +echo("\n"); + +?> diff --git a/includes/discovery/cisco-cdp.inc.php b/includes/discovery/cisco-cdp.inc.php deleted file mode 100755 index 5900e900ed..0000000000 --- a/includes/discovery/cisco-cdp.inc.php +++ /dev/null @@ -1,97 +0,0 @@ - $dst_host $dst_if)"); - } else { - echo(".."); - } - } else { - - } - } -} - -$sql = "SELECT * FROM `links` AS L, `interfaces` AS I, `devices` AS D WHERE L.src_if = I.interface_id AND I.device_id = D.device_id AND D.device_id = '".$device['device_id']."'"; -$query = mysql_query($sql); - -while ($test_link = mysql_fetch_array($query)) { - unset($exists); - $i = 0; - while ($i < count($link_exists) && !$exists) { - $this_link = $test_link['src_if'] . ",". $test_link['dst_if']; - if ($link_exists[$i] == $this_link) { $exists = 1; } - $i++; - } - if(!$exists) { - echo("-"); - mysql_query("DELETE FROM `links` WHERE `src_if` = '".$test_link['src_if']."' AND `dst_if` = '".$test_link['dst_if']."'"); - if($debug) { echo($link_exists[$i] . " REMOVED \n"); } - } else { - if($debug) { echo($link_exists[$i] . " VALID \n"); } - } -} - -echo("\n"); - -?> diff --git a/includes/functions-poller.inc.php b/includes/functions-poller.inc.php index bed68a58a7..fe1428634c 100644 --- a/includes/functions-poller.inc.php +++ b/includes/functions-poller.inc.php @@ -62,7 +62,7 @@ function snmpwalk_cache_oid($poll_oid, $device, $array, $mib = 0) { list($oid,$value) = explode("=", $entry); $oid = trim($oid); $value = trim($value); list($oid, $index) = explode(".", $oid); - if (!strstr($this_value, "at this OID") && $oid && $index) { + if (!strstr($this_value, "at this OID") && isset($oid) && isset($index)) { $array[$device_id][$index][$oid] = $value; } } @@ -81,13 +81,32 @@ function snmpwalk_cache_twopart_oid($oid, $device, $array, $mib = 0) { list($oid,$value) = explode("=", $entry); $oid = trim($oid); $value = trim($value); list($oid, $first, $second) = explode(".", $oid); - if (!strstr($this_value, "at this OID") && $oid && $first && $second) { + if (!strstr($this_value, "at this OID") && isset($oid) && isset($first) && isset($second)) { $array[$device_id][$first][$second][$oid] = $value; } } return $array; } +function snmpwalk_cache_threepart_oid($oid, $device, $array, $mib = 0) { + global $config; + $cmd = $config['snmpbulkwalk'] . " -O Qs -" . $device['snmpver'] . " -c " . $device['community'] . " " . + $device['hostname'].":".$device['port'] . " "; + if($mib) { $cmd .= "-m $mib "; } + $cmd .= $oid; + $data = trim(shell_exec($cmd)); + $device_id = $device['device_id']; + foreach(explode("\n", $data) as $entry) { + list($oid,$value) = explode("=", $entry); + $oid = trim($oid); $value = trim($value); + list($oid, $first, $second, $third) = explode(".", $oid); + if (!strstr($this_value, "at this OID") && isset($oid) && isset($first) && isset($second) && isset($third)) { + $array[$device_id][$first][$second][$third][$oid] = $value; + } + } + return $array; +} + function snmp_cache_slotport_oid($oid, $device, $array, $mib = 0) { global $config; $cmd = $config['snmpbulkwalk'] . " -O Qs -" . $device['snmpver'] . " -c " . $device['community'] . " " .