For those more advanced guys (and for those trying to learn), here's a list of the methods that NTCI provides. Each entry also lists what it takes as input, and short description of what it does, what it returns, and a brief example.

Again, if you have any question, please submit a support request.

new
Takes: The hostname (or IP) of the device you want NTCI to connect to.
Returns: New NTCI object.
Description:
This is the constructor method for NTCI. It is used to create a new instance of NTCI for manipulation later. It actually takes quite a few options, but "Host" is the main one to use. Another option of interest is "Errmode". See the Caveat section of the docs for more info on that.

Example:

$connection = Net::Telnet::Cisco::IOS->new( Host => 'hostname' );

login
Takes: Username and/or password to the device.
Returns: Nothing.
Description: A required method that logs into the device with the supplied credentials. It actually can take quite a few options, but "Name" and "Password" are the primary ones.

Example:

$connection->login( Name => 'username', Password => 'password' );

getModVer
Takes: Nothing.
Returns: The version of NTCI you're running.
Description: Just returns the version of NTCI you're running.

Example:

$version = $connection->getModVer();
print "You are using version $version of NTCI.\n";

getIOSVer
Takes: Nothing.
Returns: IOS version of the device.
Description: Returns the IOS version of the device.

Example:

$iosver = $connection->getIOSVer();
print "The device is running IOS version $iosver.\n";

getCPU
Takes: Nothing.
Returns: A hash of the 5-second, 1-minute, and 5-minute CPU utilization of the device.
Description: This method returns a hash of the CPU utilization. Options are "5sec", "1min", and "5min".

Example:

%cpu = $connection->getCPU();
print "The device's 5-second CPU utilization is " . $cpu{ '5sec' } . ".\n";
print "The device's 1-minute CPU utilization is " . $cpu{ '1min' } . ".\n";
print "The device's 5-minute CPU utilization is " . $cpu{ '5min' } . ".\n";

listInts
Takes: Nothing.
Returns: An array containing the full Cisco names of all the interfaces on the device.
Description: This method simply goes through the "show ip interface brief" output and gets all the interfaces for you. This is probably worthless by itself, but, when used with other methods like getIntState() and findVLAN(), you can do all sorts of stuff with it.
Example:

@interfaces = $connection->listInts(); #  Get the interfaces
foreach $int ( @interfaces )  {  #  For every interface...
	$state = $connection->getIntState( $int );  #  ...get the interface state...
	print "$int is $state.\n";  #  ...and print a little report line.
}

listVLANs
Takes: Nothing.
Returns: An array containing the numbers of all the VLANs on the box. This method is specifically for switches, but can be used with routers-on-a-stick where a single Ethernet port is on multiple VLANs. Basically, it works with any IOS device that has VLANs configured.

Example:

@vlans = $connetion->listVLANs();

getIntState
Takes: Interface name.
Returns: A hash containing interface state information.
Description: This method finds the state of the interface specified and returns a hash containing the state information. Options are "port" and "lineprotocol".

Example:

$int = "Fa0/1";
%intstate = $connection->getIntState( $int );
print "Interface $int has a port state of $intstate{ 'port' }.\n";
print "It also has a protocol state of $intstate{ 'lineprotocol' }.\n";

getIntDesc
Takes: Interface name.
Returns: The description configured on the interface.
Description: This method gets the description that has been configured in the interface. This is one of the methods that is good to use every so often, but, if you're after an automated solution, check out SNMP.
Example:

$desc = $connection->getIntDesc( $int );

getEthSpeed
Takes: Interface name.
Returns: The speed of the interace.
Description: This methods gets the speed of the interface from the "show interface" command. This is another method that's probably better served through SNMP. Also, this thing is only good on Ethernet interfaces, so using it on your POS OC-12 interface won't really work right.

Example:

$speed = $connection->getEthSpeed( $int );

getEthDuplex
Takes: Interface name.
Returns: The duplex of the interace.
Description: This methods gets the duplex of the interface from the "show interface" command. This is another method that's probably better served through SNMP. Also, this thing is only good on Ethernet interfaces, so using it on your POS OC-12 interface won't really work right.

Example:

$duplex = $connection->getEthDuplex( $int );

getIntBandwidth
Takes: Interface name.
Returns: The bandwidth of the interace.
Description: This methods gets the bandwidth of the interface from the "show interface" command. This is another method that's probably better served through SNMP.
Example:

$bandwidth = $connection->getIntBandwidth( $int );

getIntInputRate
Takes: Interface name.
Returns: The 5-minute moving input rate of the interace.
Description: This methods gets the input rate of the interface from the "show interface" command. This is another method that's probably better served through SNMP, specifically with MRTG or something similar.
Example:

$inputrate = $connection->getIntInputRate( $int );

getIntInputErrors
Takes: Interface name.
Returns: The total input errors of the interace.
Description: This methods gets the total input errors of the interface from the "show interface" command. This is another method that's probably better served through SNMP, specifically with MRTG or something similar. On an obvious note, clearing the counters on the interface will reset this to 0, so be aware.
Example:

$inputerrs = $connection->getIntInputErrors( $int );

getIntOutputRate
Takes: Interface name.
Returns: The 5-minute moving output rate of the interace.
Description: This methods gets the output rate of the interface from the "show interface" command. This is another method that's probably better served through SNMP, specifically with MRTG or something similar.
Example:

$outputrate = $connection->getIntOutputRate( $int );

getIntOutputErrors
Takes: Interface name.
Returns: The total output errors of the interace.
Description: This methods gets the total output errors of the interface from the "show interface" command. This is another method that's probably better served through SNMP, specifically with MRTG or something similar. On an obvious note, clearing the counters on the interface will reset this to 0, so be aware.
Example:

$outputerrs = $connection->getIntOutputErrors( $int );

findVLAN
Takes: Interface name.
Returns: The VLAN that the interface is on.
Description: This method find what VLAN the interface is on and returns it. This is one of those methods that will be used against a switch interface 99.99% of the time.
Example:

$vlan = $connection->findVLAN( $int );

getConfig
Takes: Nothing.
Returns: The full running config of the device.
Description: This method returns the config. It simply does a "show running-config" and returns the results in an array, one line per element.
Example:

@config = $connection->getConfig();

getModel
Takes: Nothing.
Returns: The model of the device.
Description: This method does a "show version" and returns the string that identifies the model.
Example:

$model = $connection->getModel();

getPlatform
Takes: Model of the device.
Returns: The platform of the device.
Description: I can't see this method sticking around. If you don't know what the device is, you're probably not supposed to be on the box, and I don't want to be accused of helping. For now, it's in, though. This method returns a one-character code for the device -- "s" for switch and "r" for router. I know there are more IOS device types out there, but, I can't do it all, so help me out, please. :)
Example:

$platform = $connection->getPlatform();
getIntCAM
Takes: Interface name.
Returns: CAM (MAC Address Table) entries for the interface.
Description: This is a switch-only method. It returns all the MACs that STP thinks is on the interface. See also getIntARP. This method may be compatible with APs, but who knows? I need some sample command outputs to know for sure. Hint, hint.
Example:
@macs = $connection->getIntCAM( $int );

getIntARP
Takes: Interface name.
Returns: All ARP entries on the interface.
Description: This method returns all ARP entries on an interface. If you don't know, an ARP entry is a map of MAC address to IP address. When an IP packet is sent over and Ethernet interface, it is encapsulated in an Ethernet packet and sent to the Ethernet-level destination for processing. An ARP entry tells the device what MAC to send the IP packet to. Of course, it's a lot more complicated than that, but you get the idea.
Example:

@arps = $connection->getIntARP( $int );

arpLookup
Takes: MAC address.
Returns: IP address that runs on that MAC.
Description: This method takes the MAC address and returns the corresponding IP address.
Example:

$mac = "000b.11cc.aaff";
$ip = $connection->arpLookup( $mac );

getIPRoute
Takes: IP address, network, etc.
Returns: A hash containing the nexthop and protocol of the router.
Description: This is a method that takes the host or network and returns the route for that host/network that the IOS device has. Options are "nexthop" and "protocol" (version 0.5beta will including the option "route", which will show the route entry for the queried route). The nexthop would be the IP address of the next hope (duh!) and the protocol would be the routing protocol -- "ospf", "eigrp", or "bgp 8573" for example.
Example:

$host = "1.1.1.1";
%route = $connection->getIPRoute( $host );
print "The next hop for $host if $route{ 'nexthop' }.\n";
print "The route is known via $route{ 'protocol' }.\n";

getACLs
Takes: Nothing.
Returns: An array containing the names of all the ACLs on the box.
Description: This method simply gets a list of all the access-lists on the box and returns them in an array.
Example:

@acls = $connection->getACLs();

getSNMPComm
Takes: Nothing.
Returns: An array of SNMP communities.
Description: This puppy goes through the running-configuration, gets all the SNMP community names, and returns them in an array. This is probably better served in a hash with community names and mode (RO, RW) and maybe the SNMP ACL. Look for something like that in future versions.
Example:

@comms = $connection->getSNMPComm();

getVTP
Takes: Nothing.
Returns: A hash containing the VTP domain, mode, and version.
Description: This little booger reports the VTP domain, device mode, and version. This is obviously a switch-only command, so don't run it against a switch. The options for the hash are "version", "mode", and "domain".
Example:

%vtp = $connection->getVTP();
print "This switch is running VTP domain $vtp{ 'domain' } \
	in mode $vtp{ 'mode' }, version $vtp{ 'version' }.\n";

getIntACL
Takes: Interface name.
Returns: A hash listing the inbound and outbound ACLs on the interface.
Description: This method gets the ACLs that are applied to the interface and returns them in an array. This is probably a router-only method, but it probably works on layer-3 switch or some newer switch. I don't really know, so try it out and let me know. The options on the hash are "inbound" and "outbound".
Example:

%acls = $connection->getIntACL( $int );
print "The inbound ACL is $acls{ 'inbound' } and /
	the outbound is $acls{ 'outbound' }.\n";

privLevel
Takes: Nothing.
Returns: The privilege level of the user that you used to log into the device.
Description: This puppy simply returns the privilege level that you are logged in with. Cisco privileges range from 0 to 15 with 15 being full access. This method is probably best used to check your privilege before running commands or other methods like getConfig() that require higher access privileges. Note that this method is only available in version 0.5beta and above.
Example:

$priv = $connection->privLevel();
print "You privilege level is " . $priv . "\n";

getNTP
Takes: Nothing.
Returns: A hash listing the NTP configuration details.
Description: This method finds what NTP server you have configured on the box and returns it in a hash. The options are "server" (the NTP server), "source" (the source interface), and "mode" (prefer or not). Note that this method is only available in version 0.5beta and above. Also note that this method doesn't check to see if NTP's working (that's the next version), but only checks if it's configured. It probably won't be very accurate if you're querying multiple NTP servers, but watch out for a fix in the near future.
Example:

%ntp = $connection->getNTP();
print "This device is taking time from " . $ntp{'server'} . \
		" and is sourced as " . $ntp{'source'} . "\n";

harmonizeInts
Takes: "Freeform" interface name.
Returns: Regular-form interface name.
Description: This method takes the "freeform" interface name and makes it into the full Cisco name. It's kinda complicated, but I'll explain. In a Cisco router, you can use abbreviations for, say, GigabitEthernet0/1, such as G0/1, Gig0/1, GigE0/1, etc. harmonizeInts() takes the abbreviated "freeform" interface name and turns it into the full name to be used with other methods. This method actually doesn't do anything to the device at all; it simply parses everything for you. This is not designed as a user-level method, but, since Perl doesn't have any way to privatize methods, I'm sure you can use it.
Example:

$freeformint = "Fas0/1";
$regularint = $connection->harmonizeInt( $freeformint );
© 2005-2006 -- Aaron Conaway