Perl/SNMP : get ifIndex by ifName - perl

i'm new to Perl and SNMP and i'm trying to develop an application to visualise the network for my internship.
I have a first script, given a mac address, a community and a switch's ip, can find the correspondant interfaceSpeed, ifAlias, duplex mode...
$perl mac-ifindex.pl -m 203B697B0438 -h 192.168.1.1 -c public
Adresse mac : 203B697B0438 => (VLAN : 1, NumPortBridge : 25)
Ifindex : 10101
Vitesse : 1000
Alias : switch-cisco-3750
Interface name : Gi0/1
Duplex : 3 (full)
For my second script, I want to give interface name, community and switch's ip to find all others informations. Which oid to get a table of ifIndex corresponding to port ? or something that could help me.
Thanks,
Bye.

When it comes to interface names, there is the standard MIB-II which has ifDescr (OID: 1.3.6.1.2.1.2.2.1.2) which contains some sort of unique name for each interface, as well as ifAlias (OID: 1.3.6.1.2.1.31.1.1.1.18) which on Cisco IOS boxes usually has a more useful device name.
Do some experimentation to find out what these MIBs look like (and what names your switch insists to use for the interfaces in the ifDescr and the ifAlias fields). Get some tool for 'walking' the SNMP MIB trees and subtrees to explore what things look like in it. For windows, IIRC Getif is a good MIB-browser. If you are on a linux box (or other UNIX) I would recommend Net-SNMP, which provides a good command line tool for walking SNMP MIBs.
For perl libraries I would recommend Net::SNMP (available on CPAN), even if it is a bit heavy on various dependencies (a lot of cryptography related modules necessary to support the security features of SNMPv3) or SNMP_Session.pm+SNMP_util.pm+BER.pm (the latter three are the perl libraries MRTG (http://www.mrtg.org) relies on and they come bundled with it). In MRTG, under the bin directory, you find the utility cfgmaker. It is a perl script which talks a lot of SNMP to whatever network gear you point it to in order to figure out what interfaces the device has, so it's source is a good read if you want to understand how SNMP can be used with perl.
For gathering information about MIBs I can recommend MIBDepot (http://www.mibdepot.com). Their search function is free. If you want to download MIBs from them they require you to pay a small, reasonable amount of money (something I recommend you do, they deserve some support for their free search services).
Hope this helps!

I've found a really simple solution :
use Net::SNMP::Interfaces;
my $interfaces = Net::SNMP::Interfaces->new(Hostname => $hostname, Community => $community);
my $inter = $interfaces->interface($ifname);
So, I can get ifindex : $inter->index();
But I need to find mac address too and I don't have the VLAN.
Anyone ?
Thanks

Related

Executing g-code from file within a ST-program in the software Automation Studio from B&R

I have a 3-axis system, which resembles the CNC-axis, and a PowerPanel from B&R. Now I plan to execute the g-code, which I read from a file, which is fe located in the Downloads folder. This will be done with fbs from B&R Automation Studio.
I got confused with the help, since it says in drive engineering/mapp Motion/technologie/function block/mpcnc3axis/description the part of moveProgram, where it redirects you to MC_BR_MoveProgram \ description. There stands that you can start the program with [Program name prefix] [File device name:] [Path] Program name syntax. Now I am not sure how to include this with my MpCnc3Axis code or if I can use the syntax also in MpCnc3AxisParType ProgramName part to start the program from fe Downloads Folder, since it didn't work with McPrgAdvParType InitProgramName.
Any links to related material would be appreciated.
I would also accept a solution with C, if it is easier.
Depending on if you are willing to buy software licences from B&R, running a CNC system is more or less easy.
The state of the art implementation is with mappMotion. It requires software licenses and gives you ready to go FUBs to execute nc files, jogging, direct movements, etc. This works the same way for different robot types and CNC kinematics. I recently uploaded a small implementation of a robot on GitLab: https://gitlab.com/kirni/bur_robotic_sample
The alternative is the old ARNC0 approach. No more new features are implemented, but it is free - as long as you do not need any functions that require a Dual Use agreement (i.e. 5 Axis CNC, etc.). The implementation is rather complex and is definitely to extensive to be answered completely at stackoverflow.
However Automation Studio ships with a sample for a two axis CNC. In the logical view you can add a new object Library Samples which opens a dialog where you can select Samples/Motion/CNC system (2 axis)/LibARNC0_Basic_ST.zip. This would be the best starting point, which is also documented in the help in MotionControl/ACP10 ARNC0/Examples/CNC or guid: 4620bb1c-8694-4f27-87d0-805686d7c0c8 as of AS 4.4.4.64.
I hope this helps!

Cisco IOS command to show only interfaces in the same format as show run

What is the command to only show interface details in the same format as 'Show run'?
The other commands, show int brief etc. show the interfaces in a different format but I want the same format as when running 'show run'. I think there is a specific command for this and not a filtered existing command,
e.g., I would like the output like this:
interface TenGigabitEthernet1/1/11
description Uplink to xxxx
switchport
switchport trunk native vlan 2000
switchport trunk allowed vlan xxxxxxx
switchport mode trunk
switchport nonegotiate
ip arp inspection trust
ip dhcp snooping trust
i think you're looking for
show run int te1/1/11
if you want all the interfaces it would be something like
show run | b TenGigabitEthernet
changing "TenGigabitEthernet" to the first device. "Ethernet" might just work on most devices natively.
Now that i think about it, the following might work
show run int range te 1/1/1-12
this should show tenGigabitEthernet 1/1/1 through 1/1/12 but i can't remember if range works on show run int.
One final option is section searching
Show run | s TenGigabitEthernet
if the switch handles the section search/filter function (some don't), it should show all sections with TenGigabitEthernet in the title
show run int te1/1/11
This was exactly what i was looking for!
(although i understand i was on the wrong site!)
cheers!
Jon

Obtaining Solaris Device path

I am working on Solaris 12 and I am trying to get device path like this:
/pci#0,0/pci108e,4856#1f,2:devctl
I could obtain the this path through CLI using prtconf -v. How could I obtain the path through api using C function? I tried serveral functions in libdevinfo, such as di_devfs_path, but it didn't give the same path as the prtconf gives me. Should I use functions like di_node_name, di_instance, di_binding_name to get pieces of information and construct the path by my own. Or there is a function to get the whole device path?
Thanks.
Firstly, unless you're working for Oracle in the Systems division, you're not working on Solaris 12. (If you are working for Oracle, why haven't you asked
Oracle internal mailing lists for help?)
Secondly, the :devctl node is a minor for the device, so you'll need to walk the minor nodes using di_walk_minor() and check di_minor_name() to see if it matches your criteria.
Finally, yes, this should work on Solaris 10 and later.

Get the ADAPTOR used on a USB-to-serial connection

I want to get the adaptor which I use on a USB-to-serial. Do you know any way to get the adaptor used? I already searched on the internet however I didn't find anything useful. Currently I am using matlab to get the data from the device. I use funcion instrhwinfo.
The output of the funcion is my case is:
serialInfo =
AvailableSerialPorts: {'COM14'}
JarFileVersion: 'Version 2.8.0'
ObjectConstructorName: {'serial('COM14');'}
SerialPorts: {'COM14'}
But, this details are not enough I want to know the ADAPTOR used on the COM14 (the model of the cable which I use).
But I want to know more details about the COM14. In this case, there's only one COM PORT avaibable, but the problem is if there are more than one, I need to know the model of the cable to connect to the correct COM PORT.
You would have to look in the registry for additional info. However the entries may depend on your particular device. Most USB/serial cables use FTDI chips and create registry entries under: SYSTEM\CurrentControlSet\Enum\FTDIBUS
A less complicated solution that I've used is to loop through all the active COM ports until you find the one that gives the appropriate response.

Using IPNAT API under winCE 6

Hi I am under Windows CE and I need to write a small application for port forwarding. So I have to use the NAT (Network Address Translation) driver to do that. Does this driver have any documentation? I didn't find any thing under msdn. Probably I will only use IOCTL_IP_NAT_DELETE_TICKET and IOCTL_IP_NAT_CREATE_TICKET which are defined in ipnat.h.
As far as I know, no documentation for this feature exists in MSDN or anywhere else.
The comments in the ipnat.h header should get you some of the way though.
If you have access to Platform Builder, there's a code sample demonstrating how to use these ioctl's. For Platform Builder 7.0, this sample is located in C:\WINCE700\PUBLIC\SERVERS\OAK\SAMPLES\UPNP\IGD.
Open the NAT driver by calling CreateFile on the "NAT0:" device, then use the returned HANDLE in the DeviceIoControl calls.
IOCTL_IP_NAT_CREATE_TICKET and IOCTL_IP_NAT_DELETE_TICKET both take an input parameter of type IP_NAT_CREATE_TICKET, and return nothing in the output buffer.