当前位置: 首页>>代码示例>>PHP>>正文


PHP mactrack_debug函数代码示例

本文整理汇总了PHP中mactrack_debug函数的典型用法代码示例。如果您正苦于以下问题:PHP mactrack_debug函数的具体用法?PHP mactrack_debug怎么用?PHP mactrack_debug使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了mactrack_debug函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_netscreen_arp_table

function get_netscreen_arp_table($site, &$device)
{
    global $debug, $scan_date;
    /* get the atifIndexes for the device */
    $atifIndexes = xform_indexed_data(".1.3.6.1.2.1.3.1.1.1", $device, 6);
    if (sizeof($atifIndexes)) {
        $ifIntcount = 1;
    } else {
        $ifIntcount = 0;
    }
    if ($ifIntcount != 0) {
        $atifIndexes = xform_indexed_data(".1.3.6.1.2.1.4.22.1.1", $device, 5);
    }
    mactrack_debug("atifIndexes data collection complete");
    /* get the atPhysAddress for the device */
    if ($ifIntcount != 0) {
        $atPhysAddress = xform_indexed_data(".1.3.6.1.2.1.4.22.1.2", $device, 5);
    } else {
        $atPhysAddress = xform_indexed_data(".1.3.6.1.2.1.3.1.1.2", $device, 6);
    }
    /* convert the mac address if necessary */
    $keys = array_keys($atPhysAddress);
    $i = 0;
    if (sizeof($atPhysAddress)) {
        foreach ($atPhysAddress as $atAddress) {
            $atPhysAddress[$keys[$i]] = xform_mac_address($atAddress);
            $i++;
        }
    }
    mactrack_debug("atPhysAddress data collection complete");
    /* get the atPhysAddress for the device */
    if ($ifIntcount != 0) {
        $atNetAddress = xform_indexed_data(".1.3.6.1.2.1.4.22.1.3", $device, 5);
    } else {
        $atNetAddress = xform_indexed_data(".1.3.6.1.2.1.3.1.1.3", $device, 6);
    }
    mactrack_debug("atNetAddress data collection complete");
    /* get the ifNames for the device */
    $keys = array_keys($atifIndexes);
    $i = 0;
    if (sizeof($atifIndexes)) {
        foreach ($atifIndexes as $atifIndex) {
            $atEntries[$i]["atifIndex"] = $atifIndex;
            $atEntries[$i]["atPhysAddress"] = $atPhysAddress[$keys[$i]];
            $atEntries[$i]["atNetAddress"] = xform_net_address($atNetAddress[$keys[$i]]);
            $i++;
        }
    }
    mactrack_debug("atEntries assembly complete.");
    /* output details to database */
    if (sizeof($atEntries)) {
        foreach ($atEntries as $atEntry) {
            $insert_string = "REPLACE INTO mac_track_ips " . "(site_id,device_id,hostname,device_name,port_number," . "mac_address,ip_address,scan_date)" . " VALUES ('" . $device["site_id"] . "','" . $device["device_id"] . "','" . $device["hostname"] . "','" . $device["device_name"] . "','" . $atEntry["atifIndex"] . "','" . $atEntry["atPhysAddress"] . "','" . $atEntry["atNetAddress"] . "','" . $scan_date . "')";
            //		mactrack_debug("SQL: " . $insert_string);
            db_execute($insert_string);
        }
    }
    /* save ip information for the device */
    $device["ips_total"] = sizeof($atEntries);
    db_execute("UPDATE mac_track_devices SET ips_total ='" . $device["ips_total"] . "' WHERE device_id='" . $device["device_id"] . "'");
    mactrack_debug("HOST: " . $device["hostname"] . ", IP address information collection complete");
}
开发者ID:avillaverdec,项目名称:cacti,代码行数:62,代码来源:mactrack_functions.php

示例2: get_IOS_dot1dTpFdbEntry_ports

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"];
            }
//.........这里部分代码省略.........
开发者ID:avillaverdec,项目名称:cacti,代码行数:101,代码来源:mactrack_cisco.php

示例3: get_JEX_switch_ports

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;
}
开发者ID:avillaverdec,项目名称:cacti,代码行数:83,代码来源:mactrack_juniper.php

示例4: collect_mactrack_data

function collect_mactrack_data($start, $site_id = 0) {
	global $max_run_duration, $config, $debug, $scan_date;

	if (defined('CACTI_BASE_PATH')) {
		$config["base_path"] = CACTI_BASE_PATH;
	}

	/* reset the processes table */
	db_execute("TRUNCATE TABLE mac_track_processes");

	/* dns resolver binary */
	$resolver_launched = FALSE;

	if (read_config_option("mt_reverse_dns") == "on") {
		$dns_resolver_required = TRUE;
	}else{
		$dns_resolver_required = FALSE;
	}

	/* get php binary path */
	$command_string = read_config_option("path_php_binary");

	/* save the scan date information */
	if ($site_id == '') {
		$scan_date = date("Y-m-d H:i:s");
		db_execute("REPLACE INTO settings (name, value) VALUES ('mt_scan_date', '$scan_date')");
	}

	/* just in case we've run too long */
	$exit_mactrack = FALSE;

	/* start mainline processing, order by site_id to keep routers grouped with switches */
	if ($site_id > 0) {
		$device_ids = db_fetch_assoc("SELECT device_id FROM mac_track_devices WHERE site_id='" . $site_id . "' and disabled=''");
	}else{
		$device_ids = db_fetch_assoc("SELECT device_id FROM mac_track_devices WHERE disabled='' ORDER BY site_id");
	}

	$total_devices = sizeof($device_ids);

	$concurrent_processes = read_config_option("mt_processes");

	if ($debug == TRUE) {
		$e_debug = " -d";
	}else{
		$e_debug = "";
	}

	if ($site_id) {
		$e_site = " -sid=$site_id";
	}else{
		$e_site = "";
	}

	/* add the parent process to the process list */
	db_process_add("-1");

	if ($total_devices > 0) {
		/* grab arpwatch data */
		if (read_config_option("mt_arpwatch") == "on") {
			$arp_db     = read_config_option("mt_arpwatch_path");
			$delim      = read_config_option("mt_mac_delim");
			$mac_ip_dns = array();

			if (file_exists($arp_db)) {
				$arp_dat = fopen($arp_db, "r");

				if ($arp_dat) {
					while (!feof($arp_dat)) {
						$line = fgets($arp_dat, 4096);

						if ($line != null) {
							$line = explode ("	", $line);

							$mac_ad = explode(":",$line[0]);
							for ($k=0;$k<6;$k++) {
								$mac_ad[$k] = strtoupper($mac_ad[$k]);
								if (1 == strlen($mac_ad[$k])) {
									$mac_ad[$k] = "0" . $mac_ad[$k];
								}
							}

							/* create the mac address */
							$mac = $mac_ad[0] . $delim . $mac_ad[1] . $delim . $mac_ad[2] . $delim . $mac_ad[3] . $delim . $mac_ad[4] . $delim . $mac_ad[5];

							/* update the array */
							$mac_ip_dns[$mac]["ip"]  = $line[1];
							$mac_ip_dns[$mac]["dns"] = $line[3];
						}
					}
					fclose($arp_dat);

					mactrack_debug("ARPWATCH: IP, DNS & MAC collection complete with ArpWatch");
				}else{
					cacti_log("ERROR: cannot open file ArpWatch database '$arp_db'");exit;
				}
			}
		}

		/* scan through all devices */
//.........这里部分代码省略.........
开发者ID:avillaverdec,项目名称:cacti,代码行数:101,代码来源:poller_mactrack_backup.php

示例5: get_extreme_arp_table

function get_extreme_arp_table($site, &$device, $extremeware = false)
{
    global $debug, $scan_date;
    /*
    EXTREME-FDB-MIB::extremeFdbIpFdbIPAddress : The IP Address of the IP FDB entry.
    .1.3.6.1.4.1.1916.1.16.2.1.2
    EXTREME-FDB-MIB::extremeFdbIpFdbMacAddress : The MAC address corresponding to the IP Address.
    .1.3.6.1.4.1.1916.1.16.2.1.3
    EXTREME-FDB-MIB::extremeFdbIpFdbVlanIfIndex : The ifIndex of the Vlan on which this ip is learned.
    .1.3.6.1.4.1.1916.1.16.2.1.4
    EXTREME-FDB-MIB::extremeFdbIpFdbPortIfIndex : The IfIndex of the port on which this entry was learned.
    .1.3.6.1.4.1.1916.1.16.2.1.5
    EXTREME-VLAN-MIB::extremeVlanIfIndex.<vlanid> = index
    .1.3.6.1.4.1.1916.1.2.1.2.1.1
    EXTREME-VLAN-MIB::extremeVlanIfDescr.<vlanid> = description
    .1.3.6.1.4.1.1916.1.2.1.2.1.2
    EXTREME-VLAN-MIB::extremeVlanIfVlanId.<vlanid> = tag id
    .1.3.6.1.4.1.1916.1.2.1.2.1.10
    BRIDGE-MIB::dot1dBasePortIfIndex : get Ifindex from extremeFdbIpFdbPortIfIndex
    .1.3.6.1.2.1.17.1.4.1.2
    IF-MIB::ifName : get name of port from IfIndex
    .1.3.6.1.2.1.31.1.1.1.1
    */
    if ($extremeware) {
        // for extremeware use standard apr table + ifDescr for interface name
        /* get the atifIndexes for the device */
        $atifIndexes = xform_stripped_oid(".1.3.6.1.2.1.3.1.1.1", $device);
        $atEntries = array();
        if (sizeof($atifIndexes)) {
            mactrack_debug("atifIndexes data collection complete");
            $atPhysAddress = xform_stripped_oid(".1.3.6.1.2.1.3.1.1.2", $device);
            mactrack_debug("atPhysAddress data collection complete");
            $atNetAddress = xform_stripped_oid(".1.3.6.1.2.1.3.1.1.3", $device);
            mactrack_debug("atNetAddress data collection complete");
            $ifDescr = xform_stripped_oid(".1.3.6.1.2.1.2.2.1.2", $device);
            mactrack_debug("ifDescr data collection complete");
        }
        $i = 0;
        if (sizeof($atifIndexes)) {
            foreach ($atifIndexes as $key => $atifIndex) {
                $atEntries[$i]["atifIndex"] = $ifDescr[$atifIndex];
                $atEntries[$i]["atPhysAddress"] = xform_mac_address($atPhysAddress[$key]);
                $atEntries[$i]["atNetAddress"] = xform_net_address($atNetAddress[$key]);
                $i++;
            }
        }
    } else {
        /* get the atifIndexes for the device */
        $FdbPortIfIndex = xform_stripped_oid(".1.3.6.1.4.1.1916.1.16.2.1.5", $device);
        $atEntries = array();
        if (sizeof($FdbPortIfIndex)) {
            mactrack_debug("FdbPortIfIndex data collection complete");
            $FdbMacAddress = xform_stripped_oid(".1.3.6.1.4.1.1916.1.16.2.1.3", $device);
            mactrack_debug("FdbMacAddress data collection complete");
            $FdbIPAddress = xform_stripped_oid(".1.3.6.1.4.1.1916.1.16.2.1.2", $device);
            mactrack_debug("FdbIPAddress data collection complete");
            $FdbVlanIfIndex = xform_stripped_oid(".1.3.6.1.4.1.1916.1.16.2.1.4", $device);
            mactrack_debug("FdbVlanIfIndex data collection complete");
            $VlanIfVlanId = xform_stripped_oid(".1.3.6.1.4.1.1916.1.2.1.2.1.10", $device);
            mactrack_debug("VlanIfVlanId data collection complete");
            $BasePortIfIndex = xform_stripped_oid(".1.3.6.1.2.1.17.1.4.1.2", $device);
            mactrack_debug("BasePortIfIndex data collection complete");
            $ifName = xform_stripped_oid(".1.3.6.1.2.1.31.1.1.1.1", $device);
            mactrack_debug("ifName data collection complete");
        }
        $i = 0;
        if (sizeof($FdbPortIfIndex)) {
            foreach ($FdbPortIfIndex as $key => $PortIndex) {
                $atEntries[$i]["atifIndex"] = $ifName[$BasePortIfIndex[$PortIndex]] . ", vlan:" . $VlanIfVlanId[$FdbVlanIfIndex[$key]];
                $atEntries[$i]["atPhysAddress"] = xform_mac_address($FdbMacAddress[$key]);
                $atEntries[$i]["atNetAddress"] = xform_net_address($FdbIPAddress[$key]);
                $i++;
            }
        }
        mactrack_debug("atEntries assembly complete.");
    }
    /* output details to database */
    if (sizeof($atEntries)) {
        foreach ($atEntries as $atEntry) {
            $insert_string = "REPLACE INTO mac_track_ips " . "(site_id,device_id,hostname,device_name,port_number," . "mac_address,ip_address,scan_date)" . " VALUES ('" . $device["site_id"] . "','" . $device["device_id"] . "','" . $device["hostname"] . "','" . $device["device_name"] . "','" . $atEntry["atifIndex"] . "','" . $atEntry["atPhysAddress"] . "','" . $atEntry["atNetAddress"] . "','" . $scan_date . "')";
            //mactrack_debug("SQL: " . $insert_string);
            db_execute($insert_string);
        }
    }
    /* save ip information for the device */
    $device["ips_total"] = sizeof($atEntries);
    db_execute("UPDATE mac_track_devices SET ips_total ='" . $device["ips_total"] . "' WHERE device_id='" . $device["device_id"] . "'");
    mactrack_debug("HOST: " . $device["hostname"] . ", IP address information collection complete: nb IP=" . sizeof($atEntries) . ".");
}
开发者ID:Cacti,项目名称:plugin_mactrack,代码行数:89,代码来源:mactrack_extreme.php

示例6: get_3Com_base_dot1dTpFdbEntry_ports


//.........这里部分代码省略.........
        $device["macs_active"] = 0;
    }
    if ($ports_active > 0) {
        /* get bridge port to ifIndex mapping */
        $bridgePortIfIndexes = xform_standard_indexed_data(".1.3.6.1.2.1.17.1.4.1.2", $device, $snmp_readstring);
        $port_status = xform_stripped_oid(".1.3.6.1.2.1.17.4.3.1.3", $device, $snmp_readstring);
        /* get device active port numbers */
        $port_numbers = xform_stripped_oid(".1.3.6.1.2.1.17.4.3.1.2", $device, $snmp_readstring);
        /* get the ignore ports list from device */
        $ignore_ports = port_list_to_array($device["ignorePorts"]);
        /* determine user ports for this device and transfer user ports to
        		   a new array.
        		*/
        $i = 0;
        foreach ($port_numbers as $key => $port_number) {
            if ($highPort == 0 || $port_number >= $lowPort && $port_number <= $highPort) {
                $ifname = $ifInterfaces[$bridgePortIfIndexes[$port_number]]["ifName"];
                if (!in_array($ifname, $ignore_ports)) {
                    if (@$port_status[$key] == "3") {
                        $port_key_array[$i]["key"] = $key;
                        $port_key_array[$i]["port_number"] = $port_number;
                        $i++;
                    }
                }
            }
        }
        /* compare the user ports to the brige port data, store additional
        		   relevant data about the port.
        		*/
        $i = 0;
        foreach ($port_key_array as $port_key) {
            /* map bridge port to interface port and check type */
            if ($port_key["port_number"] > 0) {
                if (sizeof($bridgePortIfIndexes) != 0) {
                    /* some hubs do not always return a port number in the bridge table.
                    			   test for it by isset and substiture the port number from the ifTable
                    			   if it isnt in the bridge table
                    			*/
                    if (isset($bridgePortIfIndexes[$port_key["port_number"]])) {
                        $brPortIfIndex = @$bridgePortIfIndexes[$port_key["port_number"]];
                    } else {
                        $brPortIfIndex = @$port_key["port_number"];
                    }
                    $brPortIfType = @$ifInterfaces[$brPortIfIndex]["ifType"];
                } else {
                    $brPortIfIndex = $port_key["port_number"];
                    $brPortIfType = @$ifInterfaces[$port_key["port_number"]]["ifType"];
                }
                if (($brPortIfType >= 6 && $brPortIfType <= 9 || $brPortIfType == 117) && !isset($ifInterfaces[$brPortIfIndex]["portLink"])) {
                    /* set some defaults  */
                    $new_port_key_array[$i]["vlan_id"] = "N/A";
                    $new_port_key_array[$i]["vlan_name"] = "N/A";
                    $new_port_key_array[$i]["mac_address"] = "NOT USER";
                    $new_port_key_array[$i]["port_number"] = "NOT USER";
                    $new_port_key_array[$i]["port_name"] = "N/A";
                    /* now set the real data */
                    $new_port_key_array[$i]["key"] = $port_key["key"];
                    $new_port_key_array[$i]["port_number"] = $port_key["port_number"];
                    $new_port_key_array[$i]["port_name"] = $ifInterfaces[$brPortIfIndex]["ifName"];
                    $i++;
                }
            }
        }
        mactrack_debug("Port number information collected.");
        /* map mac address */
        /* only continue if there were user ports defined */
        if (sizeof($new_port_key_array) > 0) {
            /* get the bridges active MAC addresses */
            $port_macs = xform_stripped_oid(".1.3.6.1.2.1.17.4.3.1.1", $device, $snmp_readstring);
            foreach ($port_macs as $key => $port_mac) {
                $port_macs[$key] = xform_mac_address($port_mac);
            }
            foreach ($new_port_key_array as $key => $port_key) {
                $new_port_key_array[$key]["mac_address"] = @$port_macs[$port_key["key"]];
                mactrack_debug("INDEX: '" . $key . "' MAC ADDRESS: " . $new_port_key_array[$key]["mac_address"]);
            }
            mactrack_debug("Port mac address information collected.");
        } else {
            mactrack_debug("No user ports on this network.");
        }
    } else {
        mactrack_debug("No user ports on this network.");
    }
    if ($store_to_db) {
        if ($ports_active <= 0) {
            $device["last_runmessage"] = "Data collection completed ok";
        } elseif (sizeof($new_port_key_array) > 0) {
            $device["last_runmessage"] = "Data collection completed ok";
            $device["macs_active"] = sizeof($new_port_key_array);
            db_store_device_port_results($device, $new_port_key_array, $scan_date);
        } else {
            $device["last_runmessage"] = "WARNING: Poller did not find active ports on this device.";
        }
        if (!$debug) {
            print " - Complete\n";
        }
    } else {
        return $new_port_key_array;
    }
}
开发者ID:avillaverdec,项目名称:cacti,代码行数:101,代码来源:mactrack_3com.php

示例7: mactrack_debug

                mactrack_debug('ERROR: Both Primary and Seconary DNS timed out, please increase timeout. Placing both DNS servers back online now.');
                $secondary_down = FALSE;
                $primary_down = FALSE;
            }
            $unresolved_ips[$key]['dns_hostname'] = $dns_hostname;
        }
        mactrack_debug('DNS host association complete.');
        /* output updated details to database */
        foreach ($unresolved_ips as $unresolved_ip) {
            $insert_string = 'REPLACE INTO mac_track_temp_ports 
				(site_id,device_id,hostname,dns_hostname,device_name,vlan_id,vlan_name,
				mac_address,vendor_mac,ip_address,port_number,port_name,scan_date)
				VALUES (' . $unresolved_ip['site_id'] . ',' . $unresolved_ip['device_id'] . ',' . db_qstr($unresolved_ip['hostname']) . ',' . db_qstr($unresolved_ip['dns_hostname']) . ',' . db_qstr($unresolved_ip['device_name']) . ',' . $unresolved_ip['vlan_id'] . ',' . db_qstr($unresolved_ip['vlan_name']) . ',' . db_qstr($unresolved_ip['mac_address']) . ',' . db_qstr($unresolved_ip['vendor_mac']) . ',' . db_qstr($unresolved_ip['ip_address']) . ',' . db_qstr($unresolved_ip['port_number']) . ',' . db_qstr($unresolved_ip['port_name']) . ',' . db_qstr($unresolved_ip['scan_date']) . ')';
            db_execute($insert_string);
        }
        mactrack_debug('Records updated with DNS information included.');
    }
    if ($break) {
        break;
    }
}
/* allow parent to close by removing process and then exit */
db_process_remove(0);
exit;
/*	display_help - displays the usage of the function */
function display_help()
{
    $info = plugin_mactrack_version();
    print "Network MacTracker IP Resolver Version " . $info['version'] . ", " . COPYRIGHT_YEARS . "\n";
    print "usage: mactrack_resolver.php [-sid=ID] [-d] [-h] [--help] [-v] [--version]\n\n";
    print "-sid=ID       - The site id to resolve for\n";
开发者ID:Cacti,项目名称:plugin_mactrack,代码行数:31,代码来源:mactrack_resolver.php

示例8: get_dlink_l2_dot1dTpFdbEntry_ports


//.........这里部分代码省略.........
        foreach ($port_key_array as $port_key) {
            /* map bridge port to interface port and check type */
            if ($port_key["port_number"] >= 0) {
                if (sizeof($bridgePortIfIndexes) != 0) {
                    /* some hubs do not always return a port number in the bridge table.
                    			   test for it by isset and substiture the port number from the ifTable
                    			   if it isnt in the bridge table
                    			*/
                    if (isset($bridgePortIfIndexes[$port_key["port_number"]])) {
                        $brPortIfIndex = @$bridgePortIfIndexes[$port_key["port_number"]];
                    } else {
                        $brPortIfIndex = @$port_key["port_number"];
                    }
                    $brPortIfType = @$ifInterfaces[$brPortIfIndex]["ifType"];
                } else {
                    $brPortIfIndex = $port_key["port_number"];
                    $brPortIfType = @$ifInterfaces[$port_key["port_number"]]["ifType"];
                }
                if ((convert_dlink_data($brPortIfType) >= 6 && convert_dlink_data($brPortIfType) <= 9 || convert_dlink_data($brPortIfType) == 117) && !isset($ifInterfaces[$brPortIfIndex]["portLink"])) {
                    /* set some defaults  */
                    $new_port_key_array[$i]["vlan_id"] = get_dlink_vlan_id($port_key["key"]);
                    $new_port_key_array[$i]["vlan_name"] = $vlan_names[$new_port_key_array[$i]["vlan_id"]];
                    $new_port_key_array[$i]["mac_address"] = dlink_convert_macs($port_key["key"]);
                    $new_port_key_array[$i]["port_number"] = $port_key["port_number"];
                    $new_port_key_array[$i]["port_name"] = @$ifNames[$port_key["port_number"]];
                    //print ("===bef key=[". $port_key[$i]["vlan_id"] . "]\n");
                    /* now set the real data */
                    $new_port_key_array[$i]["key"] = $port_key["key"];
                    //$new_port_key_array[$i]["port_number"] = $port_key["port_number"];
                    //$new_port_key_array[$i]["mac_address"] = dlink_convert_macs($port_key["key"]);
                    //					print ("===check key=[". $new_port_key_array["key"] . "] = [" . $port_key["key"] . "]\n");
                    //					print ("===check key2[". $new_port_key_array[$i]["key"] . "] = [" . $port_key[$i]["key"] . "]\n");
                    //print ("----------key(i)=[$i]-[$key] port=[" . $new_port_key_array[$i]["port_number"] . "] vlan_id=[" . $new_port_key_array[$i]["vlan_id"] . "] mac_address=[" . $new_port_key_array[$i]["mac_address"] . "]  vlan_name=[" . $new_port_key_array[$i]["vlan_name"] . "]\n");
                    //mactrack_debug("INDEX: [$i]-[" . $port_key["key"] . "] port=[" . $new_port_key_array[$i]["port_number"] . "] vlan_id=[" . $new_port_key_array[$i]["vlan_id"] . "] mac_address=[" . $new_port_key_array[$i]["mac_address"] . "]  vlan_name=[" . $new_port_key_array[$i]["vlan_name"] . "]");
                    $i++;
                }
            }
        }
        mactrack_debug("Port number information collected.");
        /* map mac address */
        /* only continue if there were user ports defined */
        // 		if (sizeof($new_port_key_array) > 0) {
        // 			/* get the bridges active MAC addresses */
        // // 			$port_macs = xform_stripped_oid(".1.3.6.1.2.1.17.4.3.1.1", $device, $snmp_readstring);
        // 			$port_macs = xform_dlink_stripped_oid(".1.3.6.1.2.1.17.7.1.2.2.1.2", $device, $snmp_readstring);
        //
        // 			foreach ($port_macs as $key => $port_mac) {
        //
        // //print ("===bef key=[". $key . "]\n");
        // //print ("===bef port_macs[key]=[". $port_macs[$key] . "]\n");
        // 				$port_macs[$key] = xform_mac_address($port_mac);
        // //print ("===aft port_macs[key]=[". $port_macs[$key] . "]\n");
        // 			}
        //
        // 			foreach ($new_port_key_array as $key => $port_key) {
        //
        // //				print ("===++++++==[key]=[". $port_key["key"] . "]\n");
        //
        // 			}
        // 			foreach ($port_macs as $key => $port_mac) {
        //
        // //				print ("===------==[key]=[". @$port_mac[4] . "]\n");
        //
        // 			}
        //
        // 			foreach ($new_port_key_array as $key => $port_key) {
        // 				$new_port_key_array[$key]["mac_address"] = @$port_macs[$port_key["key"]];
        // 				//print ("==key=[$key] = [". $new_port_key_array[$key]["mac_address"] . "] port=[" . $new_port_key_array[$key]["port_number"] . "]\n");
        //         //print ("==2aft port_key[key]=[". $port_key["key"] . "]\n");
        //         //print ("==2aft port_macs[port_key[key]]=[". @$port_macs[$port_key["key"]] . "]\n");
        //         //$new_port_key_array[$key]["vlan_id"] = @$port_macs[$port_key["key"]]["vlan_id"];
        // //        print ("===check key3[". $new_port_key_array[$key] . "] = [ " . $port_macs[$port_key["key"]] . "]\n");
        //
        // 				mactrack_debug("INDEX: '". $key . "' MAC ADDRESS: key=" . $port_key["key"] . "=[" . $port_key["key"] . "] vlan_id=[" . $port_key["vlan_id"]);
        // 			}
        //
        // 			mactrack_debug("Port mac address information collected.");
        // 		}else{
        // 			mactrack_debug("No user ports on this network.");
        // 		}
    } else {
        mactrack_debug("No user ports on this network.");
    }
    if ($store_to_db) {
        if ($ports_active <= 0) {
            $device["last_runmessage"] = "WARNING: Poller did not find active ports on this device.";
        } elseif (sizeof($new_port_key_array) > 0) {
            $device["last_runmessage"] = "Data collection completed ok";
            $device["macs_active"] = sizeof($new_port_key_array);
            db_store_device_port_results($device, $new_port_key_array, $scan_date);
        } else {
            $device["last_runmessage"] = "WARNING: Poller did not find active ports on this device.";
        }
        if (!$debug) {
            print " - Complete\n";
        }
    } else {
        return $new_port_key_array;
    }
}
开发者ID:Cacti,项目名称:plugin_mactrack,代码行数:101,代码来源:mactrack_dlink.php

示例9: get_repeater_rev4_ports

function get_repeater_rev4_ports($site, &$device, $lowPort, $highPort)
{
    global $debug, $scan_date;
    $snmp_readstring = get_repeater_snmp_readstring($device);
    if (strlen($snmp_readstring) > 0) {
        $ports_active = @cacti_snmp_get($device["hostname"], $snmp_readstring, ".1.3.6.1.4.1.52.4.1.1.1.4.1.1.5.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"]) - 1;
        $ports_total = @cacti_snmp_get($device["hostname"], $snmp_readstring, ".1.3.6.1.4.1.52.4.1.1.1.4.1.1.4.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"]) - 1;
        /* get the ignore ports list */
        $ignore_ports = port_list_to_array($device["ignorePorts"]);
        print "INFO: HOST: " . $device["hostname"] . ", TYPE: " . substr($device["snmp_sysDescr"], 0, 40) . ", TOTAL PORTS: " . $ports_total . ", ACTIVE PORTS: " . $ports_active;
        if ($debug) {
            print "\n";
        }
        $device["vlans_total"] = 0;
        $device["ports_total"] = $ports_total;
        if ($ports_active >= 0) {
            $device["ports_active"] = $ports_active;
        } else {
            $device["ports_active"] = 0;
        }
        if ($device["snmp_version"] == 2) {
            $snmp_version = "2c";
        } else {
            $snmp_version = $device["snmp_version"];
        }
        $port_keys = array();
        $return_array = array();
        $new_port_key_array = array();
        $port_number = 0;
        $nextOID = ".1.3.6.1.4.1.52.4.1.1.1.4.1.5.2.1.2";
        $to = ceil($device["snmp_timeout"] / 1000);
        $i = 0;
        $previous_port = 0;
        while (1) {
            $exec_string = trim(read_config_option("path_snmpgetnext") . " -c " . $snmp_readstring . " -OnUQ -v " . $snmp_version . " -r " . $device["snmp_retries"] . " -t " . $to . " " . $device["hostname"] . ":" . $device["snmp_port"] . " " . $nextOID);
            exec($exec_string, $return_array, $return_code);
            list($nextOID, $port_number) = explode("=", $return_array[$i]);
            if ($port_number < $previous_port) {
                break;
            }
            if ($port_number <= $highPort && $port_number >= $lowPort) {
                if (!in_array($port_number, $ignore_ports)) {
                    /* set defaults for devices in case they don't have/support vlans */
                    $new_port_key_array[$i]["vlan_id"] = "N/A";
                    $new_port_key_array[$i]["vlan_name"] = "N/A";
                    $new_port_key_array[$i]["port_name"] = "N/A";
                    $new_port_key_array[$i]["key"] = trim(substr($nextOID, 36));
                    $new_port_key_array[$i]["port_number"] = trim(strtr($port_number, " ", ""));
                }
                $previous_port = trim(strtr($port_number, " ", ""));
            } else {
                break;
            }
            mactrack_debug("CMD: " . $exec_string . ", PORT: " . $port_number);
            $i++;
            $port_number = "";
        }
        if (sizeof($new_port_key_array) > 0) {
            /* map mac address */
            $i = 0;
            foreach ($new_port_key_array as $port_key) {
                $OID = ".1.3.6.1.4.1.52.4.1.1.1.4.1.5.2.1.1." . $port_key["key"];
                $mac_address = @cacti_snmp_get($device["hostname"], $snmp_readstring, $OID, $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"]);
                $new_port_key_array[$i]["mac_address"] = xform_mac_address($mac_address);
                mactrack_debug("OID: " . $OID . ", MAC ADDRESS: " . $new_port_key_array[$i]["mac_address"]);
                $i++;
            }
            $device["last_runmessage"] = "Data collection completed ok";
        } else {
            mactrack_debug("INFO: The following device has no active ports: " . $site . "/" . $device["hostname"] . "\n");
            $device["last_runmessage"] = "Data collection completed ok";
        }
    } else {
        mactrack_debug("ERROR: Could not determine snmp_readstring for host: " . $site . "/" . $device["hostname"] . "\n");
        $device["snmp_status"] = HOST_ERROR;
        $device["last_runmessage"] = "ERROR: Could not determine snmp_readstring for host.";
    }
    if (!$debug) {
        print " - Complete\n";
    }
    $device["ports_active"] = $ports_active;
    $device["macs_active"] = sizeof($new_port_key_array);
    db_store_device_port_results($device, $new_port_key_array, $scan_date);
    return $device;
}
开发者ID:Cacti,项目名称:plugin_mactrack,代码行数:85,代码来源:mactrack_cabletron.php

示例10: get_netscreen_arp_table

function get_netscreen_arp_table($site, &$device)
{
    global $debug, $scan_date;
    /* get the atifIndexes for the device */
    $atifIndexes = xform_indexed_data('.1.3.6.1.2.1.3.1.1.1', $device, 6);
    if (sizeof($atifIndexes)) {
        $ifIntcount = 1;
    } else {
        $ifIntcount = 0;
    }
    if ($ifIntcount != 0) {
        $atifIndexes = xform_indexed_data('.1.3.6.1.2.1.4.22.1.1', $device, 5);
    }
    mactrack_debug(__('atifIndexes data collection complete'));
    /* get the atPhysAddress for the device */
    if ($ifIntcount != 0) {
        $atPhysAddress = xform_indexed_data('.1.3.6.1.2.1.4.22.1.2', $device, 5);
    } else {
        $atPhysAddress = xform_indexed_data('.1.3.6.1.2.1.3.1.1.2', $device, 6);
    }
    /* convert the mac address if necessary */
    $keys = array_keys($atPhysAddress);
    $i = 0;
    if (sizeof($atPhysAddress)) {
        foreach ($atPhysAddress as $atAddress) {
            $atPhysAddress[$keys[$i]] = xform_mac_address($atAddress);
            $i++;
        }
    }
    mactrack_debug(__('atPhysAddress data collection complete'));
    /* get the atPhysAddress for the device */
    if ($ifIntcount != 0) {
        $atNetAddress = xform_indexed_data('.1.3.6.1.2.1.4.22.1.3', $device, 5);
    } else {
        $atNetAddress = xform_indexed_data('.1.3.6.1.2.1.3.1.1.3', $device, 6);
    }
    mactrack_debug(__('atNetAddress data collection complete'));
    /* get the ifNames for the device */
    $keys = array_keys($atifIndexes);
    $i = 0;
    if (sizeof($atifIndexes)) {
        foreach ($atifIndexes as $atifIndex) {
            $atEntries[$i]['atifIndex'] = $atifIndex;
            $atEntries[$i]['atPhysAddress'] = $atPhysAddress[$keys[$i]];
            $atEntries[$i]['atNetAddress'] = xform_net_address($atNetAddress[$keys[$i]]);
            $i++;
        }
    }
    mactrack_debug(__('atEntries assembly complete.'));
    /* output details to database */
    if (sizeof($atEntries)) {
        foreach ($atEntries as $atEntry) {
            $insert_string = 'REPLACE INTO mac_track_ips 
				(site_id,device_id,hostname,device_name,port_number,
				mac_address,ip_address,scan_date)
				 VALUES (' . $device['site_id'] . ',' . $device['device_id'] . ',' . db_qstr($device['hostname']) . ',' . db_qstr($device['device_name']) . ',' . db_qstr($atEntry['atifIndex']) . ',' . db_qstr($atEntry['atPhysAddress']) . ',' . db_qstr($atEntry['atNetAddress']) . ',' . db_qstr($scan_date) . ')';
            db_execute($insert_string);
        }
    }
    /* save ip information for the device */
    $device['ips_total'] = sizeof($atEntries);
    db_execute('UPDATE mac_track_devices SET ips_total =' . $device['ips_total'] . ' WHERE device_id=' . $device['device_id']);
    mactrack_debug(__('HOST: %s, IP address information collection complete', $device['hostname']));
}
开发者ID:Cacti,项目名称:plugin_mactrack,代码行数:64,代码来源:mactrack_functions.php

示例11: get_procurve_switch_ports

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;
}
开发者ID:avillaverdec,项目名称:cacti,代码行数:81,代码来源:mactrack_hp.php

示例12: get_norbay_switch_ports

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;
}
开发者ID:Cacti,项目名称:plugin_mactrack,代码行数:95,代码来源:mactrack_norbay.php

示例13: mactrack_debug

                    $device['last_runmessage'] = 'WARNING: Scanning Function Does Not Exist.';
                    $device['snmp_status'] = HOST_ERROR;
                }
            } else {
                mactrack_debug('WARNING: SITE: ' . $site . ', IP: ' . $device['hostname'] . ', TYPE: ' . substr($device['snmp_sysDescr'], 0, 40) . ', ERROR: IP Scanning Function in Device Type Table Is Null.');
                $device['last_runmessage'] = 'WARNING: Scanning Function in Device Type Table Is Null.';
                $device['snmp_status'] = HOST_ERROR;
            }
        } else {
            mactrack_debug('WARNING: SITE: ' . $site . ', IP: ' . $device['hostname'] . ', TYPE: ' . substr($device['snmp_sysDescr'], 0, 40) . ', ERROR: Device Type Not Found in Device Type Table.');
            $device['last_runmessage'] = 'WARNING: Device Type Not Found in Device Type Table.';
            $device['snmp_status'] = HOST_ERROR;
        }
    }
} else {
    mactrack_debug('WARNING: SITE: ' . $site . ', IP: ' . $device['hostname'] . ', TYPE: ' . substr($device['snmp_sysDescr'], 0, 40) . ', ERROR: Device unreachable.');
    $device['last_runmessage'] = 'Device unreachable.';
    $host_up = FALSE;
}
/* update the database with device status information */
db_update_device_status($device, $host_up, $scan_date, $start_time);
db_process_remove($device_id);
exit;
/*	display_help - displays the usage of the function */
function display_help()
{
    $info = plugin_mactrack_version();
    print "Network MacTracker Version " . $info['version'] . ", " . COPYRIGHT_YEARS . "\n\n";
    print "usage: mactrack_device.php -id=host_id [-w] [-d] [-h] [--help] [-v] [--version]\n\n";
    print "-id=host_id   - the mac_track_devices host_id to scan\n";
    print "-d | --debug  - Display verbose output during execution\n";
开发者ID:Cacti,项目名称:plugin_mactrack,代码行数:31,代码来源:mactrack_scanner.php

示例14: sync_cacti_to_mactrack

function sync_cacti_to_mactrack($device) {
	
	/* do we want to "Sync Cacti Device to MacTrack Device"
	 * AND has the device already been assigned a "valid" MacTrack device id 
	 * (aka: has the device been saved successfully) */
	if ((read_config_option("mt_update_policy", true) == 2) &&
		($device["id"] > 0)) {

		# $devices holds the whole row from host table
		# now fetch the related device from mac_track_devices, if any
		$mt_device = db_fetch_row("SELECT * from mac_track_devices WHERE host_id=" . $device["id"]);

		if (is_array($mt_device)) {
			# update mac_track_device
			$device_id = api_mactrack_device_save(
			$mt_device["device_id"], 			# not a host column
			$device["id"],
			$mt_device["site_id"],				# not a host column (wait for 088)
			$device["hostname"],
			$device["description"],
			$mt_device["scan_type"],			# not a host column
			$mt_device["snmp_options"],			# not a host column
			$device["snmp_community"],
			$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"],
			$mt_device["snmp_retries"],
			$device["max_oids"],
			$mt_device["ignorePorts"],			# not a host column
			$device["notes"],
			$mt_device["user_name"], 			# not a host column
			$mt_device["user_password"],		# not a host column
			$mt_device["term_type"],
			$mt_device["private_key_path"],
			(isset($mt_device["disabled"]) ? $mt_device["disabled"] : "")); # not a host column

			mactrack_debug("MacTrack device: (" . $mt_device["device_id"] . ") successfully updated");
		}
	}
	# for use with next hook in chain
	return $device;
}
开发者ID:avillaverdec,项目名称:cacti,代码行数:48,代码来源:mactrack_actions.php

示例15: substr

					$device["last_runmessage"] = "WARNING: Scanning Function Does Not Exist.";
					$device["snmp_status"] = HOST_ERROR;
				}
			}else{
				mactrack_debug("WARNING: SITE: " . $site . ", IP: " . $device["hostname"] . ", TYPE: " . substr($device["snmp_sysDescr"],0,40) . ", ERROR: IP Scanning Function in Device Type Table Is Null.");
				$device["last_runmessage"] = "WARNING: Scanning Function in Device Type Table Is Null.";
				$device["snmp_status"] = HOST_ERROR;
			}
		}else{
			mactrack_debug("WARNING: SITE: " . $site . ", IP: " . $device["hostname"] . ", TYPE: " . substr($device["snmp_sysDescr"],0,40) . ", ERROR: Device Type Not Found in Device Type Table.");
			$device["last_runmessage"] = "WARNING: Device Type Not Found in Device Type Table.";
			$device["snmp_status"] = HOST_ERROR;
		}
	}
}else{
	mactrack_debug("WARNING: SITE: " . $site . ", IP: " . $device["hostname"] . ", TYPE: " . substr($device["snmp_sysDescr"],0,40) . ", ERROR: Device unreachable.");
	$device["last_runmessage"] = "Device unreachable.";

	$host_up = FALSE;
}

/* update the database with device status information */
db_update_device_status($device, $host_up, $scan_date, $start_time);
db_process_remove($device_id);
exit;

/*	display_help - displays the usage of the function */
function display_help () {
	print "Network MacTracker Version 1.0, Copyright 2004-2010 - The Cacti Group\n\n";
	print "usage: mactrack_device.php -id=host_id [-w] [-d] [-h] [--help] [-v] [--version]\n\n";
	print "-id=host_id   - the mac_track_devices host_id to scan\n";
开发者ID:avillaverdec,项目名称:cacti,代码行数:31,代码来源:mactrack_scanner.php


注:本文中的mactrack_debug函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。