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"); }
function get_base_sfps_ports($site, &$device, &$ifInterfaces, $snmp_readstring, $store_to_db, $lowPort, $highPort) { global $debug, $scan_date; /* initialize variables */ $port_number = 0; $ports_active = 0; $ports_total = 0; /* get the operational status of the ports */ $active_ports_array = xform_standard_indexed_data(".1.3.6.1.2.1.2.2.1.8", $device); $indexes = array_keys($active_ports_array); /* get the ignore ports list */ $ignore_ports = port_list_to_array($device["ignorePorts"]); $i = 0; if (sizeof($active_ports_array)) { foreach ($active_ports_array as $port_info) { if ($ifInterfaces[$indexes[$i]]["ifType"] >= 6 && $ifInterfaces[$indexes[$i]]["ifType"] <= 9) { if ($port_info == 1) { $ports_active++; } $ports_total++; } $i++; } } if ($store_to_db) { print "INFO: HOST: " . $device["hostname"] . ", TYPE: " . substr($device["snmp_sysDescr"], 0, 40) . ", TOTAL PORTS: " . $ports_total . ", OPER PORTS: " . $ports_active; if ($debug) { print "\n"; } $device["ports_active"] = $ports_active; $device["ports_total"] = $ports_total; } /* now obtain securefast port information */ $sfps_A_ports = xform_indexed_data(".1.3.6.1.4.1.52.4.2.4.2.2.3.6.1.1.6", $device, 3); $sfps_A_mac_addresses = xform_indexed_data(".1.3.6.1.4.1.52.4.2.4.2.2.3.6.1.1.8", $device, 3); $sfps_A_keys = array_keys($sfps_A_ports); $sfps_A_size = sizeof($sfps_A_ports); $j = 0; $i = 0; while ($j < $sfps_A_size) { $port_number = $sfps_A_ports[$sfps_A_keys[$j]]; $mac_address = $sfps_A_mac_addresses[$sfps_A_keys[$j]]; if ($port_number >= $lowPort && $port_number <= $highPort) { if (!in_array($port_number, $ignore_ports)) { $temp_port_A_array[$i]["port_number"] = $port_number; $temp_port_A_array[$i]["mac_address"] = xform_mac_address($mac_address); $i++; } } $j++; } $j = 0; $port_array = array(); for ($i = 0; $i < sizeof($temp_port_A_array); $i++) { $port_array[$temp_port_A_array[$i]["port_number"]]["vlan_id"] = "N/A"; $port_array[$temp_port_A_array[$i]["port_number"]]["vlan_name"] = "N/A"; $port_array[$temp_port_A_array[$i]["port_number"]]["port_name"] = "N/A"; $port_array[$temp_port_A_array[$i]["port_number"]]["port_number"] = $temp_port_A_array[$i]["port_number"]; $port_array[$temp_port_A_array[$i]["port_number"]]["mac_address"] = $temp_port_A_array[$i]["mac_address"]; } if ($store_to_db) { if (sizeof($port_array) > 0) { $device["last_runmessage"] = "Data collection completed ok"; $device["macs_active"] = sizeof($port_array); db_store_device_port_results($device, $port_array, $scan_date); } else { $device["last_runmessage"] = "WARNING: Poller did not find active ports on this device."; } if (!$debug) { print " - Complete\n"; } } else { return $port_array; } }
function get_CTAlias_table($site, &$device) { global $debug, $scan_date; mactrack_debug("FUNCTION: get_CTAlias_table started"); /* get the CTAlias Table for the device */ $CTAliasInterfaces = xform_indexed_data(".1.3.6.1.4.1.52.4.1.3.7.1.1.1.1.3", $device, 2); mactrack_debug("CTAliasInterfaces data collection complete: " . sizeof($CTAliasInterfaces)); /* get the CTAliasMacAddress for the device */ $CTAliasMacAddress = xform_indexed_data(".1.3.6.1.4.1.52.4.1.3.7.1.1.1.1.4", $device, 2); mactrack_debug("CTAliasMacAddress data collection complete: " . sizeof($CTAliasMacAddress)); /* convert the mac address if necessary */ $keys = array_keys($CTAliasMacAddress); $i = 0; foreach ($CTAliasMacAddress as $MacAddress) { $CTAliasMacAddress[$keys[$i]] = xform_mac_address($MacAddress); $i++; } /* get the CTAliasProtocol Table for the device */ $CTAliasProtocol = xform_indexed_data(".1.3.6.1.4.1.52.4.1.3.7.1.1.1.1.6", $device, 2); mactrack_debug("CTAliasProtocol data collection complete: " . sizeof($CTAliasProtocol)); /* get the CTAliasAddressText for the device */ $CTAliasAddressText = xform_indexed_data(".1.3.6.1.4.1.52.4.1.3.7.1.1.1.1.9", $device, 2); mactrack_debug("CTAliasAddressText data collection complete: " . sizeof($CTAliasAddressText)); /* get the ifNames for the device */ $keys = array_keys($CTAliasInterfaces); $i = 0; $CTAliasEntries = array(); foreach ($CTAliasInterfaces as $ifIndex) { $CTAliasEntries[$i]["ifIndex"] = $ifIndex; # $CTAliasEntries[$i]["timestamp"] = @substr($keys[$i], 0, stripos($keys[$i], '.')); $CTAliasEntries[$i]["timestamp"] = $keys[$i]; $CTAliasEntries[$i]["CTAliasProtocol"] = @$CTAliasProtocol[$keys[$i]]; $CTAliasEntries[$i]["CTAliasMacAddress"] = @$CTAliasMacAddress[$keys[$i]]; # $CTAliasEntries[$i]["CTAliasAddressText"] = @xform_net_address($CTAliasAddressText[$keys[$i]]); $CTAliasEntries[$i]["CTAliasAddressText"] = @$CTAliasAddressText[$keys[$i]]; $i++; } mactrack_debug("CTAliasEntries assembly complete: " . sizeof($CTAliasEntries)); /* output details to database */ if (count($CTAliasEntries) > 0) { foreach ($CTAliasEntries as $CTAliasEntry) { /* drop non-IP protocols */ if ($CTAliasEntry["CTAliasProtocol"] != 1) { continue; } $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"] . "'," . db_qstr($device["device_name"]) . ",'" . $CTAliasEntry["ifIndex"] . "','" . $CTAliasEntry["CTAliasMacAddress"] . "','" . $CTAliasEntry["CTAliasAddressText"] . "','" . $scan_date . "')"; # mactrack_debug("SQL: " . $insert_string); db_execute($insert_string); } } /* save ip information for the device */ $device["ips_total"] = sizeof($CTAliasEntries); 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: " . $device["ips_total"]); }
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'])); }