[TODO] how create new vendormacs?

Support questions about the MAC Track plugin

Moderators: Developers, Moderators

Post Reply
L0gRuS
Cacti User
Posts: 127
Joined: Thu Nov 06, 2008 7:57 am

[TODO] how create new vendormacs?

Post by L0gRuS »

Hi. i need create for extreme networks, avaya and etc network devices mac scanning file

i check directory lib and see file for hp. i want create with him new file

now i change OID and etc.
its right?
what i change more?

Code: Select all

/* register this functions scanning functions */
if (!isset($mactrack_scanning_functions)) { $mactrack_scanning_functions = array(); }
array_push($mactrack_scanning_functions, "get_extreme_switch_ports");

/* get_extreme_switch_ports
	obtains port associations for Extreme Switches. 
*/
function get_extreme_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("[b]OID1[/b]", $device);

	/* get VLAN Trunk status */
	$vlan_trunkstatus = xform_standard_indexed_data("[b]OID1[/b]", $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("[b]OID1[/b]", $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"] >= 6) && ($ifInterfaces[$ifIndex]["ifType"] <= 9)) {
			$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_name) {
		$active_vlans[$i]["vlan_id"] = $vlan_id;
		$active_vlans[$i]["vlan_name"] = $vlan_name;
		$active_vlans++;

		$i++;
	}

	if (sizeof($active_vlans) > 0) {
		$i = 0;
		/* get the port status information */
		$port_results = get_base_dot1dTpFdbEntry_ports($site, $device, $ifInterfaces, "", "", FALSE);
		$port_vlan_data = xform_standard_indexed_data("[b]OID1[/b]", $device);

		$i = 0;
		$j = 0;
		$port_array = array();
		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"] = $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;
}
?>
Last edited by L0gRuS on Tue Feb 24, 2009 3:08 am, edited 1 time in total.
Cacti v.087g + PAv2.9
L0gRuS
Cacti User
Posts: 127
Joined: Thu Nov 06, 2008 7:57 am

Post by L0gRuS »

60 views and no answer?
Cacti v.087g + PAv2.9
User avatar
TheWitness
Developer
Posts: 17047
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

Add this line to mactrack_vendors.php

Code: Select all

include_once(dirname(__FILE__) . "/mactrack_extreem.php");
Would you like to contribute your scanning function?

TheWitness
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests