function get_cabletron_switch_ports($site, &$device, $lowPort, $highPort)
{
    global $debug, $scan_date;
    /* initialize port counters */
    $device["ports_total"] = 0;
    $device["ports_active"] = 0;
    $device["ports_trunk"] = 0;
    $device["vlans_total"] = 0;
    /* get the ifIndexes for the device */
    $ifIndexes = xform_standard_indexed_data(".1.3.6.1.2.1.2.2.1.1", $device);
    mactrack_debug("ifIndexes data collection complete");
    /* get and store the interfaces table */
    $ifInterfaces = build_InterfacesTable($device, $ifIndexes, FALSE, TRUE);
    /* get VLAN information */
    $vlan_ids = xform_dot1q_vlan_associations($device, $device["snmp_readstring"]);
    mactrack_debug("VLAN data collected. There are " . sizeof($vlan_ids) . " VLANS.");
    /* map vlans to bridge ports */
    if (sizeof($vlan_ids) > 0) {
        /* get the port status information */
        $port_results = get_enterasys_A4_dot1dTpFdbEntry_ports($site, $device, $ifInterfaces, $device["snmp_readstring"], FALSE, $lowPort, $highPort);
        /* get the ifIndexes for the device */
        $vlan_names = xform_standard_indexed_data(".1.3.6.1.2.1.17.7.1.4.3.1.1", $device);
        $i = 0;
        $j = 0;
        $port_array = array();
        foreach ($port_results as $port_result) {
            $ifIndex = $port_result["port_number"];
            $ifType = $ifInterfaces[$ifIndex]["ifType"];
            /* only output legitamate end user ports */
            if ($ifType >= 6 && $ifType <= 9) {
                $port_array[$i]["vlan_id"] = @$vlan_ids[$port_result["key"]];
                $port_array[$i]["vlan_name"] = @$vlan_names[$port_array[$i]["vlan_id"]];
                $port_array[$i]["port_number"] = @$port_result["port_number"];
                $port_array[$i]["port_name"] = @$ifInterfaces[$ifIndex]["ifName"];
                $port_array[$i]["mac_address"] = xform_mac_address($port_result["mac_address"]);
                $device["ports_active"]++;
                mactrack_debug("VLAN: " . $port_array[$i]["vlan_id"] . ", " . "NAME: " . $port_array[$i]["vlan_name"] . ", " . "PORT: " . $ifInterfaces[$ifIndex]["ifName"] . ", " . "NAME: " . $port_array[$i]["port_name"] . ", " . "MAC: " . $port_array[$i]["mac_address"]);
                $i++;
            }
            $j++;
        }
        /* display completion message */
        print "INFO: HOST: " . $device["hostname"] . ", TYPE: " . trim(substr($device["snmp_sysDescr"], 0, 40)) . ", TOTAL PORTS: " . $device["ports_total"] . ", ACTIVE PORTS: " . $device["ports_active"] . "\n";
        $device["last_runmessage"] = "Data collection completed ok";
        $device["macs_active"] = sizeof($port_array);
        mactrack_debug("macs active on this switch:" . $device["macs_active"]);
        db_store_device_port_results($device, $port_array, $scan_date);
    } else {
        print "INFO: HOST: " . $device["hostname"] . ", TYPE: " . substr($device["snmp_sysDescr"], 0, 40) . ", No active devcies on this network device.\n";
        $device["snmp_status"] = HOST_UP;
        $device["last_runmessage"] = "Data collection completed ok. No active devices on this network device.";
    }
    return $device;
}
Esempio n. 2
0
function get_3Com_dot1dTpFdbEntry_ports($site, &$device, $lowPort = 0, $highPort = 0)
{
    global $debug, $scan_date;
    /* initialize port counters */
    $device["ports_total"] = 0;
    $device["ports_active"] = 0;
    $device["ports_trunk"] = 0;
    /* get the ifIndexes for the device */
    $ifIndexes = xform_standard_indexed_data(".1.3.6.1.2.1.2.2.1.1", $device);
    mactrack_debug("ifIndexes data collection complete");
    $ifInterfaces = build_InterfacesTable($device, $ifIndexes, TRUE, FALSE);
    complete_3com_ifName($device, $ifInterfaces);
    get_3Com_base_dot1dTpFdbEntry_ports($site, $device, $ifInterfaces, "", TRUE, $lowPort, $highPort);
    return $device;
}
Esempio n. 3
0
function get_dell_dot1q_switch_ports($site, &$device, $lowPort = 0, $highPort = 0)
{
    global $debug, $scan_date;
    /* initialize port counters */
    $device["ports_total"] = 0;
    $device["ports_active"] = 0;
    $device["ports_trunk"] = 0;
    /* get the ifIndexes for the device */
    $ifIndexes = xform_standard_indexed_data(".1.3.6.1.2.1.2.2.1.1", $device);
    mactrack_debug("ifIndexes data collection complete");
    $ifInterfaces = build_InterfacesTable($device, $ifIndexes, TRUE, TRUE);
    /* sanitize ifInterfaces by removing text from ifType field */
    if (sizeof($ifInterfaces)) {
        foreach ($ifInterfaces as $key => $tempInterfaces) {
            preg_match("/[0-9]{1,3}/", $tempInterfaces["ifType"], $newType);
            $ifInterfaces[$key]["ifType"] = $newType[0];
        }
    }
    get_base_dell_dot1qFdb_ports($site, $device, $ifInterfaces, "", TRUE, $lowPort, $highPort);
    return $device;
}
function get_cabletron_switch_ports($site, &$device, $lowPort, $highPort)
{
    global $debug, $scan_date;
    /* initialize port counters */
    $device["ports_total"] = 0;
    $device["ports_active"] = 0;
    $device["ports_trunk"] = 0;
    $device["vlans_total"] = 0;
    /* get the ifIndexes for the device */
    $ifIndexes = xform_standard_indexed_data(".1.3.6.1.2.1.2.2.1.1", $device);
    mactrack_debug("ifIndexes data collection complete");
    /* get and store the interfaces table */
    $ifInterfaces = build_InterfacesTable($device, $ifIndexes, FALSE, FALSE);
    $securefast_marker = @cacti_snmp_get($device["hostname"], $device["snmp_readstring"], ".1.3.6.1.4.1.52.4.2.4.2.1.1.1.1.1.1.1", $device["snmp_version"], $device["snmp_username"], $device["snmp_password"], $device["snmp_auth_protocol"], $device["snmp_priv_passphrase"], $device["snmp_priv_protocol"], $device["snmp_context"], $device["snmp_port"], $device["snmp_timeout"], $device["snmp_retries"]);
    mactrack_debug("Cabletron securefast marker obtained");
    if (empty($securefast_marker)) {
        get_base_dot1dTpFdbEntry_ports($site, $device, $ifInterfaces, "", TRUE, $lowPort, $highPort);
    } else {
        get_base_sfps_ports($site, $device, $ifInterfaces, "", TRUE, $lowPort, $highPort);
    }
    return $device;
}
Esempio n. 5
0
function get_JEX_switch_ports($site, &$device, $lowPort = 0, $highPort = 0)
{
    global $debug, $scan_date;
    /* initialize port counters */
    $device["ports_total"] = 0;
    $device["ports_active"] = 0;
    $device["ports_trunk"] = 0;
    /* get VLAN information */
    $vlan_ids = xform_standard_indexed_data(".1.3.6.1.4.1.2636.3.40.1.5.1.5.1.5", $device);
    $vlan_names = xform_standard_indexed_data(".1.3.6.1.4.1.2636.3.40.1.5.1.5.1.2", $device);
    /* get VLAN Trunk status */
    $device["vlans_total"] = sizeof($vlan_ids) - 1;
    mactrack_debug("VLAN data collected. There are " . (sizeof($vlan_ids) - 1) . " VLANS.");
    /* get the ifIndexes for the device */
    $ifIndexes = xform_standard_indexed_data(".1.3.6.1.2.1.2.2.1.1", $device);
    mactrack_debug("ifIndexes data collection complete");
    /* get and store the interfaces table */
    $ifInterfaces = build_InterfacesTable($device, $ifIndexes, TRUE, FALSE);
    foreach ($ifIndexes as $ifIndex) {
        $ifInterfaces[$ifIndex]["trunkPortState"] = @$vlan_trunkstatus[$ifIndex];
        if ($ifInterfaces[$ifIndex]["ifType"] == "propVirtual(53)" or $ifInterfaces[$ifIndex]["ifType"] == "ieee8023adLag(161)") {
            $device["ports_total"]++;
        }
        if ($ifInterfaces[$ifIndex]["trunkPortState"] == 3) {
            $device["ports_trunk"]++;
        }
    }
    mactrack_debug("ifInterfaces assembly complete.");
    $i = 0;
    foreach ($vlan_ids as $vlan_id => $vlan_num) {
        $active_vlans[$vlan_id]["vlan_id"] = $vlan_num;
        $active_vlans[$vlan_id]["vlan_name"] = $vlan_names[$vlan_id];
        $active_vlans++;
        $i++;
    }
    mactrack_debug("Vlan assembly complete.");
    if (sizeof($active_vlans) > 0) {
        $i = 0;
        /* get the port status information */
        //$port_results = get_base_dot1dTpFdbEntry_ports($site, $device, $ifInterfaces, "", "", FALSE);
        $mac_results = xform_stripped_oid(".1.3.6.1.2.1.17.7.1.2.2.1.2", $device);
        $port_results = xform_stripped_oid(".1.3.6.1.2.1.17.1.4.1.2", $device);
        $i = 0;
        $j = 0;
        $port_array = array();
        foreach ($mac_results as $num => $mac_result) {
            if ($mac_result != 0) {
                $Xvlanid = substr($num, 0, strpos($num, "."));
                $Xmac = mach(substr($num, strpos($num, ".") + 1));
                $ifIndex = $port_results[$mac_result];
                $ifType = $ifInterfaces[$ifIndex]["ifType"];
                $ifName = $ifInterfaces[$ifIndex]["ifName"];
                $portName = $ifName;
                $portTrunkStatus = @$ifInterfaces[$ifIndex]["trunkPortState"];
                /* only output legitamate end user ports */
                //if ((($ifType >= 6) && ($ifType <= 9)) and ( $portName != "" or $portName != "1" )) {
                if ($portName != "" and $portName != "1") {
                    $port_array[$i]["vlan_id"] = $active_vlans[$Xvlanid]["vlan_id"];
                    //@$vlan_ids[$Xvlanid];
                    $port_array[$i]["vlan_name"] = $active_vlans[$Xvlanid]["vlan_name"];
                    //@$vlan_names[$Xvlandid];
                    $port_array[$i]["port_number"] = @$port_results[$mac_result];
                    $port_array[$i]["port_name"] = trim($ifName);
                    $port_array[$i]["mac_address"] = xform_mac_address($Xmac);
                    $device["ports_active"]++;
                    mactrack_debug("VLAN: " . $port_array[$i]["vlan_id"] . ", " . "NAME: " . $port_array[$i]["vlan_name"] . ", " . "PORT: " . $ifIndex . ", " . "NAME: " . $port_array[$i]["port_name"] . ", " . "MAC: " . $port_array[$i]["mac_address"]);
                    $i++;
                }
                $j++;
            }
        }
        /* display completion message */
        print "INFO: HOST: " . $device["hostname"] . ", TYPE: " . substr($device["snmp_sysDescr"], 0, 40) . ", TOTAL PORTS: " . $device["ports_total"] . ", ACTIVE PORTS: " . $device["ports_active"];
        $device["last_runmessage"] = "Data collection completed ok";
        $device["macs_active"] = sizeof($port_array);
        db_store_device_port_results($device, $port_array, $scan_date);
    } else {
        print "INFO: HOST: " . $device["hostname"] . ", TYPE: " . substr($device["snmp_sysDescr"], 0, 40) . ", No active devcies on this network device.";
        $device["snmp_status"] = HOST_UP;
        $device["last_runmessage"] = "Data collection completed ok. No active devices on this network device.";
    }
    return $device;
}
Esempio n. 6
0
function get_IOS_dot1dTpFdbEntry_ports($site, &$device, $lowPort = 0, $highPort = 0)
{
    global $debug, $scan_date;
    /* initialize port counters */
    $device["ports_total"] = 0;
    $device["ports_active"] = 0;
    $device["ports_trunk"] = 0;
    $device["vlans_total"] = 0;
    /* Variables to determine VLAN information */
    $vlan_ids = xform_standard_indexed_data(".1.3.6.1.4.1.9.9.46.1.3.1.1.2", $device);
    $vlan_names = xform_standard_indexed_data(".1.3.6.1.4.1.9.9.46.1.3.1.1.4", $device);
    $vlan_trunkstatus = xform_standard_indexed_data(".1.3.6.1.4.1.9.9.46.1.6.1.1.14", $device);
    $device["vlans_total"] = sizeof($vlan_ids) - 3;
    mactrack_debug("There are " . (sizeof($vlan_ids) - 3) . " VLANS.");
    /* get the ifIndexes for the device */
    $ifIndexes = xform_standard_indexed_data(".1.3.6.1.2.1.2.2.1.1", $device);
    mactrack_debug("ifIndexes data collection complete");
    $ifInterfaces = build_InterfacesTable($device, $ifIndexes, TRUE, TRUE);
    /* get the Voice VLAN information if it exists */
    $portVoiceVLANs = xform_standard_indexed_data(".1.3.6.1.4.1.9.9.87.1.4.1.1.37.0", $device);
    if (sizeof($portVoiceVLANs) > 0) {
        $vvlans = TRUE;
    } else {
        $portVoiceVLANs = xform_standard_indexed_data(".1.3.6.1.4.1.9.9.68.1.5.1.1.1", $device);
        if (sizeof($portVoiceVLANs) > 0) {
            $vvlans = TRUE;
        } else {
            $vvlans = FALSE;
        }
    }
    mactrack_debug("Cisco Voice VLAN collection complete");
    if ($vvlans) {
        mactrack_debug("Voice VLANs exist on this device");
    } else {
        mactrack_debug("Voice VLANs do not exist on this device");
    }
    if (sizeof($ifIndexes)) {
        foreach ($ifIndexes as $ifIndex) {
            $ifInterfaces[$ifIndex]["trunkPortState"] = @$vlan_trunkstatus[$ifIndex];
            if ($vvlans) {
                $ifInterfaces[$ifIndex]["vVlanID"] = @$portVoiceVLANs[$ifIndex];
            }
            if ($ifInterfaces[$ifIndex]["ifType"] == 6) {
                $device["ports_total"]++;
            }
            if ($ifInterfaces[$ifIndex]["trunkPortState"] == "1") {
                $device["ports_trunk"]++;
            }
        }
    }
    mactrack_debug("ifInterfaces assembly complete.");
    /* build VLAN array from results */
    $i = 0;
    $j = 0;
    $active_vlans = array();
    if (sizeof($vlan_ids)) {
        foreach ($vlan_ids as $vlan_number => $vlanStatus) {
            $vlanName = $vlan_names[$vlan_number];
            if ($vlanStatus == 1) {
                /* vlan is operatinal */
                switch ($vlan_number) {
                    case "1002":
                    case "1003":
                    case "1004":
                    case "1005":
                        $active_vlan_ports = 0;
                        break;
                    default:
                        if ($device["snmp_version"] < "3") {
                            $snmp_readstring = $device["snmp_readstring"] . "@" . $vlan_number;
                            $active_vlan_ports = cacti_snmp_get($device["hostname"], $snmp_readstring, ".1.3.6.1.2.1.17.1.2.0", $device["snmp_version"], $device["snmp_username"], $device["snmp_password"], $device["snmp_auth_protocol"], $device["snmp_priv_passphrase"], $device["snmp_priv_protocol"], $device["snmp_context"], $device["snmp_port"], $device["snmp_timeout"], $device["snmp_retries"]);
                        } else {
                            $active_vlan_ports = cacti_snmp_get($device["hostname"], $snmp_readstring, ".1.3.6.1.2.1.17.1.2.0", $device["snmp_version"], $device["snmp_username"], $device["snmp_password"], $device["snmp_auth_protocol"], $device["snmp_priv_passphrase"], $device["snmp_priv_protocol"], $vlan_number, $device["snmp_port"], $device["snmp_timeout"], $device["snmp_retries"]);
                        }
                        if (!is_numeric($active_vlan_ports) || $active_vlan_ports < 0) {
                            $active_vlan_ports = 0;
                        }
                        mactrack_debug("VLAN Analysis for VLAN: " . $vlan_number . "/" . $vlanName . " is complete. ACTIVE PORTS: " . $active_vlan_ports);
                        if ($active_vlan_ports > 0) {
                            /* does the vlan have active ports on it */
                            $active_vlans[$j]["vlan_id"] = $vlan_number;
                            $active_vlans[$j]["vlan_name"] = $vlanName;
                            $active_vlans[$j]["active_ports"] = $active_vlan_ports;
                            $active_vlans++;
                            $j++;
                        }
                }
            }
            $i++;
        }
    }
    if (sizeof($active_vlans)) {
        $i = 0;
        /* get the port status information */
        foreach ($active_vlans as $active_vlan) {
            if ($device["snmp_version"] < "3") {
                $snmp_readstring = $device["snmp_readstring"] . "@" . $active_vlan["vlan_id"];
            } else {
                $snmp_readstring = "cisco@" . $active_vlan["vlan_id"];
            }
            mactrack_debug("Processing has begun for VLAN: " . $active_vlan["vlan_id"]);
            if ($highPort == 0) {
                $active_vlans[$i]["port_results"] = get_base_dot1dTpFdbEntry_ports($site, $device, $ifInterfaces, $snmp_readstring, FALSE);
            } else {
                $active_vlans[$i]["port_results"] = get_base_dot1dTpFdbEntry_ports($site, $device, $ifInterfaces, $snmp_readstring, FALSE, $lowPort, $highPort);
            }
            /* get bridge port mappings */
            /* get bridge port to ifIndex mappings */
            mactrack_debug("Bridge port information about to be collected.");
            mactrack_debug("VLAN_ID: " . $active_vlans[$i]["vlan_id"] . ", VLAN_NAME: " . $active_vlans[$i]["vlan_name"] . ", ACTIVE PORTS: " . sizeof($active_vlans[$i]["port_results"]));
            if (sizeof($active_vlans[$i]["port_results"]) > 0) {
                $brPorttoifIndexes[$i] = xform_standard_indexed_data(".1.3.6.1.2.1.17.1.4.1.2", $device, $snmp_readstring);
                mactrack_debug("Bridge port information collection complete.");
            }
            $i++;
        }
        $i = 0;
        $j = 0;
        $port_array = array();
        mactrack_debug("Final cross check's now being performed.");
        if (sizeof($active_vlans)) {
            foreach ($active_vlans as $active_vlan) {
                if (sizeof($active_vlan["port_results"])) {
                    foreach ($active_vlan["port_results"] as $port_result) {
                        $ifIndex = @$brPorttoifIndexes[$j][$port_result["port_number"]];
                        $ifType = @$ifInterfaces[$ifIndex]["ifType"];
                        $portNumber = @$ifInterfaces[$ifIndex]["ifName"];
                        $portName = @$ifInterfaces[$ifIndex]["ifAlias"];
                        $portTrunk = @$portTrunking[$ifName];
                        if ($vvlans) {
                            $vVlanID = @$portVoiceVLANs[$ifIndex];
                        } else {
                            $vVlanID = -1;
                        }
                        $portTrunkStatus = @$ifInterfaces[$ifIndex]["trunkPortState"];
                        /* only output legitamate end user ports */
                        if ($ifType == 6) {
                            if ($portTrunkStatus == "2" || empty($portTrunkStatus) || $vVlanID > 0 && $vVlanID <= 1000) {
                                $port_array[$i]["vlan_id"] = $active_vlan["vlan_id"];
                                $port_array[$i]["vlan_name"] = $active_vlan["vlan_name"];
                                $port_array[$i]["port_number"] = $portNumber;
                                $port_array[$i]["port_name"] = $portName;
                                $port_array[$i]["mac_address"] = xform_mac_address($port_result["mac_address"]);
                                $device["ports_active"]++;
                                $i++;
                                mactrack_debug("VLAN: " . $active_vlan["vlan_id"] . ", " . "NAME: " . $active_vlan["vlan_name"] . ", " . "PORT: " . $portNumber . ", " . "NAME: " . $portName . ", " . "MAC: " . $port_result["mac_address"]);
                            }
                        }
                    }
                }
                $j++;
            }
        }
        /* display completion message */
        print "\nINFO: HOST: " . $device["hostname"] . ", TYPE: " . substr($device["snmp_sysDescr"], 0, 40) . ", TOTAL PORTS: " . $device["ports_total"] . ", ACTIVE PORTS: " . $device["ports_active"] . "\n";
        $device["last_runmessage"] = "Data collection completed ok";
        $device["macs_active"] = sizeof($port_array);
        db_store_device_port_results($device, $port_array, $scan_date);
    } else {
        print "\nINFO: HOST: " . $device["hostname"] . ", TYPE: " . substr($device["snmp_sysDescr"], 0, 40) . ", No active end devices on this device.\n";
        $device["snmp_status"] = HOST_UP;
        $device["last_runmessage"] = "Data collection completed ok.  No active end devices on this device.";
    }
    return $device;
}
Esempio n. 7
0
function get_extreme_switch_ports($site, &$device, $lowPort = 0, $highPort = 0, $extremeware = false)
{
    global $debug, $scan_date;
    /* initialize port counters */
    $device["ports_total"] = 0;
    $device["ports_active"] = 0;
    $device["ports_trunk"] = 0;
    $device["vlans_total"] = 0;
    $device["macs_active"] = 0;
    /* get VLAN information
    	   VLAN index
    	   .1.3.6.1.4.1.1916.1.2.1.2.1.1
    	   EXTREME-VLAN-MIB::extremeVlanIfIndex.<vlanid> = index
    	   VLAN name
    	   .1.3.6.1.4.1.1916.1.2.1.2.1.2
    	   EXTREME-VLAN-MIB::extremeVlanIfDescr.<vlanid> = description
    	   VLAN ID
    	   .1.3.6.1.4.1.1916.1.2.1.2.1.10
    	   EXTREME-VLAN-MIB::extremeVlanIfVlanId.<vlanid> = tag id
    	 */
    $vlan_ids = xform_standard_indexed_data(".1.3.6.1.4.1.1916.1.2.1.2.1.10", $device);
    $vlan_names = xform_standard_indexed_data(".1.3.6.1.4.1.1916.1.2.1.2.1.2", $device);
    $device["vlans_total"] = sizeof($vlan_ids);
    mactrack_debug("There are " . sizeof($vlan_ids) . " VLANS.");
    /* get the ifIndexes for the device
    	   .1.3.6.1.2.1.2.2.1.1
    	   RFC1213-MIB::ifIndex.<index> = index
    	   .1.3.6.1.2.1.2.2.1.2
    	   RFC1213-MIB::ifDescr.<index> = description
    	   .1.3.6.1.2.1.2.2.1.3
    	   RFC1213-MIB::ifType.<index> = type (6=ether)
    	   .1.3.6.1.2.1.31.1.1.1.1
    	   IF-MIB::ifName.<index> = name
    	   .1.3.6.1.2.1.31.1.1.1.18
    	   IF-MIB::ifAlias.<index> = alias
    	 */
    $ifInterfaces = build_InterfacesTable($device, $ifIndexes, TRUE, TRUE);
    mactrack_debug("ifInterfaces assembly complete.");
    /* get VLAN details */
    $i = 0;
    foreach ($vlan_ids as $vlan_index => $vlan_id) {
        $active_vlans[$i]["vlan_id"] = $vlan_id;
        $active_vlans[$i]["vlan_name"] = $vlan_names[$vlan_index];
        $active_vlans++;
        mactrack_debug("VLAN ID = " . $active_vlans[$i]["vlan_id"] . " VLAN Name = " . $active_vlans[$i]["vlan_name"]);
        $i++;
    }
    if (sizeof($active_vlans) > 0) {
        /* get the port status information */
        /* get port_number and MAC addr */
        /*extremeXOS
        		  addr mac
        		  .1.3.6.1.4.1.1916.1.16.4.1.1
        		  EXTREME-BASE-MIB::extremeFdb.4.1.1.<MAC>.<vlanid>= hex MAC
        		  index du vlan ?
        		  .1.3.6.1.4.1.1916.1.16.4.1.2
        		  EXTREME-BASE-MIB::extremeFdb.4.1.2.<MAC>.<vlanid>=vlanid
        		  index du port
        		  .1.3.6.1.4.1.1916.1.16.4.1.3
        		  EXTREME-BASE-MIB::extremeFdb.4.1.3.<MAC>.<vlanid>=port id
        		  status
        		  .1.3.6.1.4.1.1916.1.16.4.1.4
        		  EXTREME-BASE-MIB::extremeFdb.4.1.4.<MAC>.<vlanid>= 3 learned
        
        		  extremeware
        		  .1.3.6.1.4.1.1916.1.16.1.1.3
        		  EXTREME-FDB-MIB::extremeFdbMacFdbMacAddress.<vlanid>.<id> = mac
        		  .1.3.6.1.4.1.1916.1.16.1.1.4
        		  EXTREME-FDB-MIB::extremeFdbMacFdbPortIfIndex.<vlanid>.<id> = index du port
        		  .1.3.6.1.4.1.1916.1.16.1.1.5
        		  EXTREME-FDB-MIB::extremeFdbMacFdbStatus.<vlanid>.<id> = 3 learned
        		 */
        if ($extremeware) {
            $mac_addr_list = xform_stripped_oid(".1.3.6.1.4.1.1916.1.16.1.1.3", $device);
            $mac_port_list = xform_stripped_oid(".1.3.6.1.4.1.1916.1.16.1.1.4", $device);
            $mac_status_list = xform_stripped_oid(".1.3.6.1.4.1.1916.1.16.1.1.5", $device);
        } else {
            $mac_addr_list = xform_stripped_oid(".1.3.6.1.4.1.1916.1.16.4.1.1", $device);
            $mac_vlan_list = xform_stripped_oid(".1.3.6.1.4.1.1916.1.16.4.1.2", $device);
            $mac_port_list = xform_stripped_oid(".1.3.6.1.4.1.1916.1.16.4.1.3", $device);
            $mac_status_list = xform_stripped_oid(".1.3.6.1.4.1.1916.1.16.4.1.4", $device);
        }
        $port_array = array();
        foreach ($mac_addr_list as $mac_key => $mac_addr) {
            /* check if mac addr is 'learned'  or 'mgnt' */
            if (isset($mac_status_list[$mac_key]) and $mac_status_list[$mac_key] == "3" || $mac_status_list[$mac_key] == "5") {
                $ifIndex = $mac_port_list[$mac_key];
                $ifType = $ifInterfaces[$ifIndex]["ifType"];
                //$ifType = $ifTypes[$ifIndex];
                /* only output legitimate end user ports */
                if ($ifType >= 6 && $ifType <= 9) {
                    if ($extremeware) {
                        $vlanid = substr($mac_key, 0, strpos($mac_key, "."));
                        $new_port_array["vlan_id"] = $vlan_ids[$vlanid];
                        $new_port_array["vlan_name"] = $vlan_names[$vlanid];
                    } else {
                        $new_port_array["vlan_id"] = $vlan_ids[$mac_vlan_list[$mac_key]];
                        $new_port_array["vlan_name"] = $vlan_names[$mac_vlan_list[$mac_key]];
                    }
                    //$new_port_array["port_number"]  = $ifIndex;
                    //$new_port_array["port_name"]    = $ifInterfaces[$ifIndex]["ifName"];
                    $new_port_array["port_number"] = $ifInterfaces[$ifIndex]["ifName"];
                    $new_port_array["port_name"] = $ifInterfaces[$ifIndex]["ifAlias"];
                    $new_port_array["mac_address"] = xform_mac_address($mac_addr_list[$mac_key]);
                    $ifInterfaces[$ifIndex]["Used"] = 1;
                    $port_array[] = $new_port_array;
                    mactrack_debug("VLAN: " . $new_port_array["vlan_id"] . ", " . "NAME: " . $new_port_array["vlan_name"] . ", " . "PORT: " . $ifIndex . ", " . "NAME: " . $new_port_array["port_name"] . ", " . "MAC: " . $new_port_array["mac_address"]);
                }
            }
        }
        $device["ports_total"] = sizeof($ifInterfaces);
        $device["ports_active"] = 0;
        foreach ($ifInterfaces as $interface) {
            if (isset($interface["Used"])) {
                $device["ports_active"]++;
            }
        }
        /* display completion message */
        print "INFO: HOST: " . $device["hostname"] . ", TYPE: " . substr($device["snmp_sysDescr"], 0, 40) . ", TOTAL PORTS: " . $device["ports_total"] . ", ACTIVE PORTS: " . $device["ports_active"];
        $device["last_runmessage"] = "Data collection completed ok";
        $device["macs_active"] = sizeof($port_array);
        db_store_device_port_results($device, $port_array, $scan_date);
    } else {
        print "INFO: HOST: " . $device["hostname"] . ", TYPE: " . substr($device["snmp_sysDescr"], 0, 40) . ", No active devices on this network device.";
        $device["snmp_status"] = HOST_UP;
        $device["last_runmessage"] = "Data collection completed ok. No active devices on this network device.";
    }
    return $device;
}
Esempio n. 8
0
function get_procurve_switch_ports($site, &$device, $lowPort = 0, $highPort = 0)
{
    global $debug, $scan_date;
    /* initialize port counters */
    $device["ports_total"] = 0;
    $device["ports_active"] = 0;
    $device["ports_trunk"] = 0;
    $active_vlans = array();
    /* get VLAN information */
    $vlan_ids = xform_standard_indexed_data(".1.3.6.1.4.1.11.2.14.11.5.1.3.1.1.4.1.2", $device);
    /* get VLAN Trunk status */
    $vlan_trunkstatus = xform_standard_indexed_data(".1.3.6.1.4.1.11.2.14.11.5.1.3.1.1.8.1.1.1", $device);
    $device["vlans_total"] = sizeof($vlan_ids);
    mactrack_debug("VLAN data collected. There are " . sizeof($vlan_ids) . " VLANS.");
    /* get the ifIndexes for the device */
    $ifIndexes = xform_standard_indexed_data(".1.3.6.1.2.1.2.2.1.1", $device);
    mactrack_debug("ifIndexes data collection complete");
    /* get and store the interfaces table */
    $ifInterfaces = build_InterfacesTable($device, $ifIndexes, TRUE, FALSE);
    if (sizeof($ifIndexes)) {
        foreach ($ifIndexes as $ifIndex) {
            $ifInterfaces[$ifIndex]["trunkPortState"] = @$vlan_trunkstatus[$ifIndex];
            if ($ifInterfaces[$ifIndex]["ifType"] >= 6 && $ifInterfaces[$ifIndex]["ifType"] <= 9) {
                $device["ports_total"]++;
            }
            if ($ifInterfaces[$ifIndex]["trunkPortState"] == 3) {
                $device["ports_trunk"]++;
            }
        }
    }
    mactrack_debug("ifInterfaces assembly complete.");
    $i = 0;
    if (sizeof($vlan_ids)) {
        foreach ($vlan_ids as $vlan_id => $vlan_name) {
            $active_vlans[$i]["vlan_id"] = $vlan_id;
            $active_vlans[$i]["vlan_name"] = $vlan_name;
            $active_vlans++;
            $i++;
        }
    }
    if (sizeof($active_vlans)) {
        $i = 0;
        /* get the port status information */
        $port_results = get_base_dot1dTpFdbEntry_ports($site, $device, $ifInterfaces, "", "", FALSE);
        $port_vlan_data = xform_standard_indexed_data(".1.3.6.1.4.1.11.2.14.11.5.1.3.1.1.5.1.2", $device);
        $i = 0;
        $j = 0;
        $port_array = array();
        if (sizeof($port_results)) {
            foreach ($port_results as $port_result) {
                $ifIndex = $port_result["port_number"];
                $ifType = $ifInterfaces[$ifIndex]["ifType"];
                $ifName = $ifInterfaces[$ifIndex]["ifName"];
                $portName = $ifName;
                $portTrunkStatus = @$ifInterfaces[$ifIndex]["trunkPortState"];
                /* only output legitamate end user ports */
                if ($ifType >= 6 && $ifType <= 9) {
                    $port_array[$i]["vlan_id"] = @$port_vlan_data[$port_result["port_number"]];
                    $port_array[$i]["vlan_name"] = @$vlan_ids[$port_array[$i]["vlan_id"]];
                    $port_array[$i]["port_number"] = @$port_result["port_number"];
                    $port_array[$i]["port_name"] = $portName;
                    $port_array[$i]["mac_address"] = xform_mac_address($port_result["mac_address"]);
                    $device["ports_active"]++;
                    mactrack_debug("VLAN: " . $port_array[$i]["vlan_id"] . ", " . "NAME: " . $port_array[$i]["vlan_name"] . ", " . "PORT: " . $ifIndex . ", " . "NAME: " . $port_array[$i]["port_name"] . ", " . "MAC: " . $port_array[$i]["mac_address"]);
                    $i++;
                }
                $j++;
            }
        }
        /* display completion message */
        print "INFO: HOST: " . $device["hostname"] . ", TYPE: " . substr($device["snmp_sysDescr"], 0, 40) . ", TOTAL PORTS: " . $device["ports_total"] . ", ACTIVE PORTS: " . $device["ports_active"];
        $device["last_runmessage"] = "Data collection completed ok";
        $device["macs_active"] = sizeof($port_array);
        db_store_device_port_results($device, $port_array, $scan_date);
    } else {
        print "INFO: HOST: " . $device["hostname"] . ", TYPE: " . substr($device["snmp_sysDescr"], 0, 40) . ", No active devcies on this network device.";
        $device["snmp_status"] = HOST_UP;
        $device["last_runmessage"] = "Data collection completed ok. No active devices on this network device.";
    }
    return $device;
}
Esempio n. 9
0
function get_norbay_switch_ports($site, &$device, $lowPort = 0, $highPort = 0)
{
    global $debug, $scan_date;
    /* initialize port counters */
    $device["ports_total"] = 0;
    $device["ports_active"] = 0;
    $device["ports_trunk"] = 0;
    /* get VLAN information */
    $vlan_ids = xform_standard_indexed_data(".1.3.6.1.4.1.2272.1.3.2.1.2", $device);
    $vlan_trunkstatus = xform_standard_indexed_data(".1.3.6.1.4.1.2272.1.3.3.1.4", $device);
    $device["vlans_total"] = sizeof($vlan_ids);
    mactrack_debug("There are " . sizeof($vlan_ids) . " VLANS.");
    /* get the ifIndexes for the device */
    $ifIndexes = xform_standard_indexed_data(".1.3.6.1.2.1.2.2.1.1", $device);
    mactrack_debug("ifIndexes data collection complete");
    /* get and store the interfaces table */
    $ifInterfaces = build_InterfacesTable($device, $ifIndexes, TRUE, FALSE);
    if (sizeof($ifIndexes)) {
        foreach ($ifIndexes as $ifIndex) {
            $ifInterfaces[$ifIndex]["trunkPortState"] = @$vlan_trunkstatus[$ifIndex];
            $ifInterfaces[$ifIndex]["vlannum"] = @$vlan_ids[$ifIndex];
            $ifInterfaces[$ifIndex]["ifOperStatus"] = mactrack_strip_alpha($ifInterfaces[$ifIndex]["ifOperStatus"]);
            if ($ifInterfaces[$ifIndex]["ifType"] == 6) {
                $device["ports_total"]++;
            }
            if ($ifInterfaces[$ifIndex]["ifOperStatus"] == 1) {
                $device["ports_active"]++;
            }
            if ($ifInterfaces[$ifIndex]["trunkPortState"] == 2) {
                mactrack_debug("Found Port Trunk: " . $ifInterfaces[$ifIndex]["ifDescr"]);
                $device["ports_trunk"]++;
            }
        }
    }
    mactrack_debug("ifInterfaces assembly complete.");
    $i = 0;
    if (sizeof($vlan_ids)) {
        foreach ($vlan_ids as $vlan_id => $vlan_name) {
            $active_vlans[$i]["vlan_id"] = $vlan_id;
            $active_vlans[$i]["vlan_name"] = $vlan_name;
            $active_vlans++;
            $i++;
        }
    }
    if (sizeof($active_vlans)) {
        $i = 0;
        /* get the port status information */
        $port_results = get_base_dot1dTpFdbEntry_ports($site, $device, $ifInterfaces, "", "", FALSE);
        $port_vlan_data = xform_dot1q_vlan_associations($device);
        $i = 0;
        $j = 0;
        $port_array = array();
        if (sizeof($port_results)) {
            foreach ($port_results as $port_result) {
                $ifIndex = $port_result["port_number"];
                $ifType = $ifInterfaces[$ifIndex]["ifType"];
                $ifName = $ifInterfaces[$ifIndex]["ifName"];
                $ifDescr = $ifInterfaces[$ifIndex]["ifDescr"];
                if (strpos($ifDescr, "BayStack") === false) {
                    $portName = preg_replace("/ifc[0-9]+ /", "", $ifName);
                } else {
                    $portName = preg_replace("/BayStack - /", "", $ifDescr);
                }
                $portTrunkStatus = @$ifInterfaces[$ifIndex]["trunkPortState"];
                /* only output legitamate end user ports */
                if ($ifType == 6 && $portTrunkStatus == 1) {
                    $port_array[$i]["vlan_id"] = @$port_vlan_data[$port_result["key"]];
                    $port_array[$i]["vlan_name"] = @$vlan_ids[$port_array[$i]["vlan_id"]];
                    $port_array[$i]["port_number"] = @$port_result["port_number"];
                    $port_array[$i]["port_name"] = $portName;
                    $port_array[$i]["mac_address"] = xform_mac_address($port_result["mac_address"]);
                    $device["ports_active"]++;
                    foreach ($port_array as $test_array) {
                        if ($test_array["port_name"] == $portName && $test_array["mac_address"] != $port_result["mac_address"]) {
                            $port_array[$i]["port_number"] = @$port_result["port_number"] . " - *";
                        }
                    }
                    mactrack_debug("VLAN: " . $port_array[$i]["vlan_id"] . ", " . "NAME: " . $port_array[$i]["vlan_name"] . ", " . "PORT: " . $ifInterfaces[$ifIndex]["ifName"] . ", " . "NUMBER: " . $port_array[$i]["port_number"] . ", " . "NAME: " . $port_array[$i]["port_name"] . ", " . "MAC: " . $port_array[$i]["mac_address"]);
                    $i++;
                }
                $j++;
            }
        }
        /* display completion message */
        print "INFO: HOST: " . $device["hostname"] . ", TYPE: " . trim(substr($device["snmp_sysDescr"], 0, 40)) . ", TOTAL PORTS: " . $device["ports_total"] . ", ACTIVE PORTS: " . $device["ports_active"];
        $device["last_runmessage"] = "Data collection completed ok";
        $device["macs_active"] = sizeof($port_array);
        db_store_device_port_results($device, $port_array, $scan_date);
    } else {
        print "INFO: HOST: " . $device["hostname"] . ", TYPE: " . substr($device["snmp_sysDescr"], 0, 40) . ", No active devcies on this network device.";
        $device["snmp_status"] = HOST_UP;
        $device["last_runmessage"] = "Data collection completed ok. No active devices on this network device.";
    }
    return $device;
}