diff --git a/html/pages/device.inc.php b/html/pages/device.inc.php index cf28d8128..d907903ee 100644 --- a/html/pages/device.inc.php +++ b/html/pages/device.inc.php @@ -217,6 +217,17 @@ if (device_permitted($vars['device']) || $check_device == $vars['device']) '); } + $device_pw_count = @dbFetchCell("SELECT COUNT(*) FROM `pseudowires` WHERE `device_id` = ?", array($device['device_id'])); + if ($device_routing_count) + { + echo('
  • + + Pseudowires + +
  • '); + } + + if ($_SESSION['userlevel'] >= "5" && dbFetchCell("SELECT COUNT(*) FROM links AS L, ports AS I WHERE I.device_id = '".$device['device_id']."' AND I.interface_id = L.local_interface_id")) { $discovery_links = TRUE; diff --git a/html/pages/device/pseudowires.inc.php b/html/pages/device/pseudowires.inc.php new file mode 100644 index 000000000..13a6e575d --- /dev/null +++ b/html/pages/device/pseudowires.inc.php @@ -0,0 +1,97 @@ + 'pseudowires'); + +print_optionbar_start(); + +echo('Pseudowires » '); + +if ($vars['view'] == "detail") { echo(''); } +echo(generate_link("Details",$link_array,array('view'=> 'detail'))); +if ($vars['view'] == "detail") { echo(''); } + +echo(" | "); + +if ($vars['view'] == "minigraphs") { echo(''); } +echo(generate_link("Mini Graphs",$link_array,array('view' => "minigraphs"))); +if ($vars['view'] == "minigraphs") { echo(''); } + +print_optionbar_end(); + +echo(""); + +foreach (dbFetchRows("SELECT * FROM pseudowires AS P, ports AS I WHERE P.interface_id = I.interface_id AND I.device_id = ? ORDER BY I.ifDescr", array($device['device_id'])) as $pw_a) +{ + $i = 0; + while ($i < count($linkdone)) + { + $thislink = $pw_a['device_id'] . $pw_a['interface_id']; + if ($linkdone[$i] == $thislink) { $skip = "yes"; } + $i++; + } + + $pw_b = dbFetchRow("SELECT * from `devices` AS D, `ports` AS I, `pseudowires` AS P WHERE D.device_id = ? AND D.device_id = I.device_id + AND P.cpwVcID = ? AND P.interface_id = I.interface_id", array($pw_a['peer_device_id'], $pw_a['cpwVcID'])); + + if (!port_permitted($pw_a['interface_id'])) { $skip = "yes"; } + if (!port_permitted($pw_b['interface_id'])) { $skip = "yes"; } + + if ($skip) + { + unset($skip); + } else { + if ($bg == "ffffff") { $bg = "e5e5e5"; } else { $bg="ffffff"; } + echo(" + + "); + echo(""); + + if ($vars['view'] == "minigraphs") + { + echo(""); + } + + $linkdone[] = $pw_b['device_id'] . $pw_b['interface_id']; + } +} + +echo("
    ".$pw_a['cpwVcID']."".generate_port_link($pw_a)." ".generate_device_link($pw_b)."".generate_port_link($pw_b)."
    ".$pw_a['ifAlias']."".$pw_b['ifAlias']."
    "); + + if ($pw_a) + { + $pw_a['width'] = "150"; + $pw_a['height'] = "30"; + $pw_a['from'] = $day; + $pw_a['to'] = $now; + $pw_a['bg'] = $bg; + $types = array('bits','upkts','errors'); + foreach ($types as $graph_type) + { + $pw_a['graph_type'] = "port_".$graph_type; + generate_port_thumbnail($pw_a); + } + } + echo(""); + + if ($pw_b) + { + $pw_b['width'] = "150"; + $pw_b['height'] = "30"; + $pw_b['from'] = $day; + $pw_b['to'] = $now; + $pw_b['bg'] = $bg; + $types = array('bits','upkts','errors'); + foreach ($types as $graph_type) + { + $pw_b['graph_type'] = "port_".$graph_type; + generate_port_thumbnail($pw_b); + } + } + + echo("
    "); + +?> diff --git a/includes/discovery/cisco-pw.inc.php b/includes/discovery/cisco-pw.inc.php index 1b156d1ee..88dbef16e 100755 --- a/includes/discovery/cisco-pw.inc.php +++ b/includes/discovery/cisco-pw.inc.php @@ -7,71 +7,52 @@ if ($config['enable_pseudowires'] && $device['os_group'] == "cisco") echo("Cisco Pseudowires : "); - # FIXME snmp_walk - $oids = shell_exec($config['snmpwalk'] . " -M " . $config['mibdir'] . " -m CISCO-IETF-PW-MIB -CI -Ln -Osqn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " cpwVcID"); - - $oids = str_replace(".1.3.6.1.4.1.9.10.106.1.2.1.10.", "", $oids); - - $oids = trim($oids); - foreach (explode("\n", $oids) as $oid) + /// Pre-cache the existing state of pseudowires for this device from the database + $pws_db_raw = dbFetchRows("SELECT * FROM `pseudowires` WHERE `device_id` = ?", array($device['device_id'])); + foreach($pws_db_raw as $pw_db) { - if ($oid) - { - list($cpwOid, $cpwVcID) = explode(" ", $oid); + $device['pws_db'][$pw_db['cpwVcID']] = $pw_db['pseudowire_id']; + } + unset($pws_db_raw); unset($pw_db); - if ($cpwOid) - { - list($cpw_remote_id) = explode(":", shell_exec($config['snmpget'] . " -M " . $config['mibdir'] . " -m CISCO-IETF-PW-MPLS-MIB -Ln -Osqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " cpwVcMplsPeerLdpID." . $cpwOid)); - $interface_descr = trim(shell_exec($config['snmpwalk'] . " -M " . $config['mibdir'] . " -m CISCO-IETF-PW-MIB -Oqvn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " cpwVcName." . $cpwOid)); + $pws = snmpwalk_cache_oid($device, "cpwVcID", array(), "CISCO-IETF-PW-MPLS-MIB"); + $pws = snmpwalk_cache_oid($device, "cpwVcName", $pws, "CISCO-IETF-PW-MPLS-MIB"); + $pws = snmpwalk_cache_oid($device, "cpwVcType", $pws, "CISCO-IETF-PW-MPLS-MIB"); + $pws = snmpwalk_cache_oid($device, "cpwVcPsnType", $pws, "CISCO-IETF-PW-MPLS-MIB"); + $pws = snmpwalk_cache_oid($device, "cpwVcDescr", $pws, "CISCO-IETF-PW-MPLS-MIB"); + + /// For MPLS pseudowires + $pws = snmpwalk_cache_oid($device, "cpwVcMplsPeerLdpID", $pws, "CISCO-IETF-PW-MPLS-MIB"); + + + foreach($pws as $pw_id => $pw) + { + list($cpw_remote_id) = explode(":", $pw['cpwVcMplsPeerLdpID']); $cpw_remote_device = @mysql_result(mysql_query("SELECT device_id FROM ipv4_addresses AS A, ports AS I WHERE A.ipv4_address = '".$cpw_remote_id."' AND A.interface_id = I.interface_id"),0); - $if_id = @mysql_result(mysql_query("SELECT `interface_id` FROM `ports` WHERE `ifDescr` = '$interface_descr' AND `device_id` = '".$device['device_id']."'"),0); + $if_id = @mysql_result(mysql_query("SELECT `interface_id` FROM `ports` WHERE `ifDescr` = '".$pw['cpwVcName']."' AND `device_id` = '".$device['device_id']."'"),0); - if ($cpw_remote_device && $if_id) + if (!empty($device['pws_db'][$pw['cpwVcID']])) { - $hostname = gethostbyid($cpw_remote_device); -#echo("\nOid: " . $cpwOid . " cpwVcID: " . $cpwVcID . " Remote Id: " . $cpw_remote_id . "($hostname(".$cpw_remote_device.") -> $interface_descr($if_id))"); - if (mysql_result(mysql_query("SELECT count(*) FROM pseudowires WHERE `interface_id` = '$if_id' - AND `cpwVcID`='".$cpwVcID."'"),0)) - { - echo("."); - } - else - { - $insert_query = "INSERT INTO `pseudowires` (`interface_id`,`peer_device_id`,`peer_ldp_id`,`cpwVcID`,`cpwOid`) "; - $insert_query .= "VALUES ('$if_id','$cpw_remote_device','$cpw_remote_id','$cpwVcID', '$cpwOid')"; - mysql_query($insert_query); - echo("+"); -#echo($device['device_id'] . " $cpwOid $cpw_remote_device $if_id $cpwVcID\n"); - } - $cpw_exists[] = $device['device_id'] . " $cpwOid $cpw_remote_device $if_id $cpwVcID"; + $pseudowire_id = $device['pws_db'][$pw['cpwVcID']]; + echo("."); } - } - } + else + { + $pseudowire_id = dbInsert(array('device_id' => $device['device_id'], 'interface_id' => $if_id, 'peer_device_id' => $cpw_remote_device, 'peer_ldp_id' => $cpw_remote_id, + 'cpwVcID' => $pw['cpwVcID'], 'cpwOid' => $pw_id, 'pw_type' => $pw['cpwVcType'], 'pw_descr' => $pw['cpwVcDescr'], 'pw_psntype' => $pw['cpwVcPsnType']), 'pseudowires'); + echo("+"); + } + $device['pws'][$pw['cpwVcID']] = $pseudowire_id; } - $sql = "SELECT * FROM pseudowires AS P, ports AS I, devices as D WHERE P.interface_id = I.interface_id AND I.device_id = D.device_id AND D.device_id = '".$device['device_id']."'"; - $query = mysql_query($sql); - - while ($cpw = mysql_fetch_assoc($query)) + /// Cycle the list of pseudowires we cached earlier and make sure we saw them again. + foreach($device['pws_db'] as $pw_id => $pseudowire_id) { - unset($exists); - $i = 0; - while ($i < count($cpw_exists) && !$exists) + if(empty($device['pws'][$pw_id])) { - $this_cpw = $cpw['device_id'] . " " . $cpw['cpwOid'] . " " . $cpw['peer_device_id'] . " " . $cpw['interface_id'] . " " . $cpw['cpwVcID']; - if ($cpw_exists[$i] == $this_cpw) { $exists = 1; -# echo($cpw_exists[$i]. " || $this_cpw \n"); - } - $i++; - } - if (!$exists) - { - echo("-"); -# echo($this_cpw . "\n"); - mysql_query("DELETE FROM pseudowires WHERE pseudowire_id = '" . $cpw['pseudowire_id'] . "'"); + dbDelete('vlans', "`pseudowire_id` = ?", array($pseudowire_id)); } } - echo("\n"); } # enable_pseudowires + os_group=cisco diff --git a/includes/discovery/entity-physical.inc.php b/includes/discovery/entity-physical.inc.php index 0de66064a..f86ddaab3 100755 --- a/includes/discovery/entity-physical.inc.php +++ b/includes/discovery/entity-physical.inc.php @@ -32,11 +32,6 @@ if (isset($entity_array['$entPhysicalIndex']['0']['entAliasMappingIdentifier'])) { $ifIndex = $entity_array['$entPhysicalIndex']['0']['entAliasMappingIdentifier']; } -# $ent_data = $config['snmpget'] . " -M ".$config['mibdir']." -m ENTITY-MIB:IF-MIB -Ovqs -"; -# $ent_data .= $device['snmpver'] . " -M ".$config['mibdir']." -c " . $device['community'] . " " . $device['hostname'] .":".$device['port']; -# $ent_data .= " entAliasMappingIdentifier." . $entPhysicalIndex. ".0"; -# $ifIndex = shell_exec($ent_data); - if (!strpos($ifIndex, "fIndex") || $ifIndex == "") { unset($ifIndex); } list(,$ifIndex) = explode(".", $ifIndex); @@ -45,6 +40,8 @@ $entPhysicalModelName = $entPhysicalVendorTypes[$entPhysicalVendorType]; } + ## FIXME - dbFacile + if ($entPhysicalDescr || $entPhysicalName) { $entPhysical_id = @mysql_result(mysql_query("SELECT entPhysical_id FROM `entPhysical` WHERE device_id = '".$device['device_id']."' AND entPhysicalIndex = '$entPhysicalIndex'"),0);